@logicflow/core 2.2.0-alpha.2 → 2.2.0-alpha.3

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 (119) hide show
  1. package/.turbo/turbo-build$colon$dev.log +2 -2
  2. package/.turbo/turbo-build.log +6 -6
  3. package/CHANGELOG.md +6 -0
  4. package/dist/index.css +3 -2
  5. package/dist/index.min.js +1 -1
  6. package/dist/index.min.js.map +1 -1
  7. package/es/LogicFlow.d.ts +9 -0
  8. package/es/constant/index.d.ts +1 -1
  9. package/es/constant/index.js +1 -1
  10. package/es/constant/theme.d.ts +136 -0
  11. package/es/constant/theme.js +680 -0
  12. package/es/index.css +3 -2
  13. package/es/model/GraphModel.d.ts +9 -2
  14. package/es/model/GraphModel.js +17 -6
  15. package/es/model/TransformModel.js +9 -9
  16. package/es/model/edge/BaseEdgeModel.js +7 -2
  17. package/es/model/edge/PolylineEdgeModel.d.ts +6 -0
  18. package/es/model/edge/PolylineEdgeModel.js +23 -1
  19. package/es/model/node/BaseNodeModel.d.ts +12 -1
  20. package/es/model/node/BaseNodeModel.js +6 -1
  21. package/es/model/node/HtmlNodeModel.d.ts +12 -0
  22. package/es/model/node/HtmlNodeModel.js +19 -0
  23. package/es/model/node/PolygonNodeModel.js +3 -3
  24. package/es/options.d.ts +1 -1
  25. package/es/style/index.css +3 -2
  26. package/es/style/index.less +3 -2
  27. package/es/style/raw.d.ts +1 -1
  28. package/es/style/raw.js +1 -1
  29. package/es/tool/MultipleSelectTool.js +6 -5
  30. package/es/util/edge.d.ts +1 -1
  31. package/es/util/edge.js +2 -2
  32. package/es/util/geometry.d.ts +8 -0
  33. package/es/util/geometry.js +79 -0
  34. package/es/util/theme.d.ts +2 -65
  35. package/es/util/theme.js +4 -281
  36. package/es/view/Control.d.ts +5 -0
  37. package/es/view/Control.js +44 -57
  38. package/es/view/edge/PolylineEdge.js +13 -2
  39. package/es/view/node/BaseNode.d.ts +1 -0
  40. package/es/view/node/BaseNode.js +14 -10
  41. package/es/view/node/HtmlNode.js +2 -4
  42. package/es/view/overlay/Grid.d.ts +12 -1
  43. package/es/view/overlay/Grid.js +85 -23
  44. package/es/view/overlay/OutlineOverlay.d.ts +1 -0
  45. package/es/view/overlay/OutlineOverlay.js +17 -16
  46. package/es/view/overlay/gridConfig.d.ts +46 -0
  47. package/es/view/overlay/gridConfig.js +99 -0
  48. package/es/view/shape/Polygon.d.ts +0 -7
  49. package/es/view/shape/Polygon.js +12 -43
  50. package/lib/LogicFlow.d.ts +9 -0
  51. package/lib/constant/index.d.ts +1 -1
  52. package/lib/constant/index.js +16 -2
  53. package/lib/constant/theme.d.ts +136 -0
  54. package/lib/constant/theme.js +683 -0
  55. package/lib/index.css +3 -2
  56. package/lib/model/GraphModel.d.ts +9 -2
  57. package/lib/model/GraphModel.js +18 -7
  58. package/lib/model/TransformModel.js +9 -9
  59. package/lib/model/edge/BaseEdgeModel.js +7 -2
  60. package/lib/model/edge/PolylineEdgeModel.d.ts +6 -0
  61. package/lib/model/edge/PolylineEdgeModel.js +23 -1
  62. package/lib/model/node/BaseNodeModel.d.ts +12 -1
  63. package/lib/model/node/BaseNodeModel.js +6 -1
  64. package/lib/model/node/HtmlNodeModel.d.ts +12 -0
  65. package/lib/model/node/HtmlNodeModel.js +19 -0
  66. package/lib/model/node/PolygonNodeModel.js +3 -3
  67. package/lib/options.d.ts +1 -1
  68. package/lib/style/index.css +3 -2
  69. package/lib/style/index.less +3 -2
  70. package/lib/style/raw.d.ts +1 -1
  71. package/lib/style/raw.js +1 -1
  72. package/lib/tool/MultipleSelectTool.js +6 -5
  73. package/lib/util/edge.d.ts +1 -1
  74. package/lib/util/edge.js +2 -2
  75. package/lib/util/geometry.d.ts +8 -0
  76. package/lib/util/geometry.js +81 -1
  77. package/lib/util/theme.d.ts +2 -65
  78. package/lib/util/theme.js +15 -292
  79. package/lib/view/Control.d.ts +5 -0
  80. package/lib/view/Control.js +44 -57
  81. package/lib/view/edge/PolylineEdge.js +13 -2
  82. package/lib/view/node/BaseNode.d.ts +1 -0
  83. package/lib/view/node/BaseNode.js +14 -10
  84. package/lib/view/node/HtmlNode.js +1 -3
  85. package/lib/view/overlay/Grid.d.ts +12 -1
  86. package/lib/view/overlay/Grid.js +83 -21
  87. package/lib/view/overlay/OutlineOverlay.d.ts +1 -0
  88. package/lib/view/overlay/OutlineOverlay.js +17 -16
  89. package/lib/view/overlay/gridConfig.d.ts +46 -0
  90. package/lib/view/overlay/gridConfig.js +104 -0
  91. package/lib/view/shape/Polygon.d.ts +0 -7
  92. package/lib/view/shape/Polygon.js +13 -45
  93. package/package.json +1 -1
  94. package/src/LogicFlow.tsx +10 -0
  95. package/src/constant/index.ts +2 -2
  96. package/src/constant/theme.ts +708 -0
  97. package/src/model/GraphModel.ts +19 -7
  98. package/src/model/TransformModel.ts +9 -9
  99. package/src/model/edge/BaseEdgeModel.ts +10 -2
  100. package/src/model/edge/PolylineEdgeModel.ts +26 -1
  101. package/src/model/node/BaseNodeModel.ts +9 -1
  102. package/src/model/node/HtmlNodeModel.ts +14 -0
  103. package/src/model/node/PolygonNodeModel.ts +2 -0
  104. package/src/options.ts +1 -1
  105. package/src/style/index.less +3 -2
  106. package/src/style/raw.ts +3 -2
  107. package/src/tool/MultipleSelectTool.tsx +6 -5
  108. package/src/util/edge.ts +2 -1
  109. package/src/util/geometry.ts +99 -0
  110. package/src/util/theme.ts +12 -303
  111. package/src/view/Control.tsx +61 -63
  112. package/src/view/edge/PolylineEdge.tsx +14 -2
  113. package/src/view/node/BaseNode.tsx +8 -3
  114. package/src/view/node/HtmlNode.tsx +27 -10
  115. package/src/view/overlay/Grid.tsx +187 -30
  116. package/src/view/overlay/OutlineOverlay.tsx +35 -47
  117. package/src/view/overlay/gridConfig.ts +103 -0
  118. package/src/view/shape/Polygon.tsx +12 -49
  119. package/stats.html +1 -1
package/lib/util/theme.js CHANGED
@@ -1,289 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.updateTheme = exports.clearThemeMode = exports.removeThemeMode = exports.addThemeMode = exports.setupTheme = exports.gridModeMap = exports.defaultGrid = exports.colorfulGrid = exports.darkGrid = exports.backgroundModeMap = exports.defaultBackground = exports.colorfulBackground = exports.darkBackground = exports.themeModeMap = exports.colorfulMode = exports.darkMode = exports.radiusMode = exports.defaultTheme = void 0;
3
+ exports.updateTheme = exports.clearThemeMode = exports.removeThemeMode = exports.addThemeMode = exports.setupTheme = void 0;
4
4
  var lodash_es_1 = require("lodash-es");
5
- exports.defaultTheme = {
6
- baseNode: {
7
- fill: '#fff',
8
- stroke: '#000',
9
- strokeWidth: 2,
10
- },
11
- baseEdge: {
12
- stroke: '#000',
13
- strokeWidth: 2,
14
- },
15
- rect: {},
16
- circle: {},
17
- diamond: {},
18
- ellipse: {},
19
- polygon: {},
20
- text: {
21
- color: '#000',
22
- stroke: 'none',
23
- fontSize: 12,
24
- background: {
25
- fill: 'transparent',
26
- },
27
- },
28
- anchor: {
29
- stroke: '#000',
30
- fill: '#fff',
31
- r: 4,
32
- hover: {
33
- r: 10,
34
- fill: '#949494',
35
- fillOpacity: 0.5,
36
- stroke: '#949494',
37
- },
38
- },
39
- anchorLine: {
40
- stroke: '#000',
41
- strokeWidth: 2,
42
- strokeDasharray: '3,2',
43
- },
44
- nodeText: {
45
- color: '#000',
46
- overflowMode: 'default',
47
- fontSize: 12,
48
- lineHeight: 1.2,
49
- },
50
- edgeText: {
51
- textWidth: 100,
52
- overflowMode: 'default',
53
- fontSize: 12,
54
- background: {
55
- fill: '#fff',
56
- },
57
- },
58
- line: {},
59
- polyline: {},
60
- bezier: {
61
- fill: 'none',
62
- adjustLine: {
63
- stroke: '#949494',
64
- },
65
- adjustAnchor: {
66
- r: 4,
67
- fill: '#949494',
68
- fillOpacity: 1,
69
- stroke: '#949494',
70
- },
71
- },
72
- arrow: {
73
- offset: 10,
74
- verticalLength: 5, // 箭头垂直于边的距离
75
- },
76
- snapline: {
77
- stroke: '#949494',
78
- strokeWidth: 1,
79
- },
80
- edgeAdjust: {
81
- r: 4,
82
- fill: '#fff',
83
- stroke: '#949494',
84
- strokeWidth: 2,
85
- },
86
- outline: {
87
- fill: 'transparent',
88
- stroke: '#949494',
89
- strokeDasharray: '3,3',
90
- hover: {
91
- stroke: '#949494',
92
- },
93
- },
94
- edgeAnimation: {
95
- stroke: 'red',
96
- strokeDasharray: '10,10',
97
- strokeDashoffset: '100%',
98
- animationName: 'lf_animate_dash',
99
- animationDuration: '20s',
100
- animationIterationCount: 'infinite',
101
- animationTimingFunction: 'linear',
102
- animationDirection: 'normal',
103
- },
104
- rotateControl: {
105
- stroke: '#000',
106
- fill: '#fff',
107
- strokeWidth: 1.5,
108
- },
109
- resizeControl: {
110
- width: 7,
111
- height: 7,
112
- fill: '#fff',
113
- stroke: '#000',
114
- },
115
- resizeOutline: {
116
- fill: 'none',
117
- stroke: 'transparent', // 矩形默认不显示调整边框
118
- strokeWidth: 1,
119
- strokeDasharray: '3,3',
120
- },
121
- };
122
- exports.radiusMode = {
123
- rect: { radius: 8 },
124
- diamond: { radius: 8 },
125
- polygon: { radius: 8 },
126
- polyline: { radius: 8 },
127
- arrow: {
128
- strokeLinecap: 'round',
129
- strokeLinejoin: 'round',
130
- offset: 10,
131
- verticalLength: 5, // 箭头垂直于边的距离
132
- },
133
- snapline: {
134
- strokeLinecap: 'round',
135
- strokeLinejoin: 'round',
136
- stroke: '#949494',
137
- strokeWidth: 1,
138
- },
139
- outline: {
140
- radius: 8,
141
- fill: 'transparent',
142
- stroke: '#949494',
143
- strokeDasharray: '3,3',
144
- hover: {
145
- stroke: '#949494',
146
- },
147
- },
148
- resizeOutline: {
149
- radius: 8,
150
- fill: 'none',
151
- stroke: 'transparent', // 矩形默认不显示调整边框
152
- strokeWidth: 1,
153
- strokeDasharray: '3,3',
154
- },
155
- };
156
- exports.darkMode = {
157
- baseNode: {
158
- fill: '#23272e',
159
- stroke: '#fefeff',
160
- },
161
- baseEdge: {
162
- stroke: '#fefeff',
163
- },
164
- rect: { radius: 8 },
165
- diamond: { radius: 8 },
166
- polygon: { radius: 8 },
167
- polyline: { radius: 8 },
168
- nodeText: {
169
- color: '#fefeff',
170
- overflowMode: 'default',
171
- fontSize: 12,
172
- lineHeight: 1.2,
173
- },
174
- arrow: {
175
- strokeLinecap: 'round',
176
- strokeLinejoin: 'round',
177
- offset: 10,
178
- verticalLength: 5, // 箭头垂直于边的距离
179
- },
180
- snapline: {
181
- strokeLinecap: 'round',
182
- strokeLinejoin: 'round',
183
- stroke: '#949494',
184
- strokeWidth: 1,
185
- },
186
- outline: {
187
- radius: 8,
188
- fill: 'transparent',
189
- stroke: '#949494',
190
- strokeDasharray: '3,3',
191
- hover: {
192
- stroke: '#949494',
193
- },
194
- },
195
- resizeOutline: {
196
- radius: 8,
197
- fill: 'none',
198
- stroke: 'transparent', // 矩形默认不显示调整边框
199
- strokeWidth: 1,
200
- strokeDasharray: '3,3',
201
- },
202
- };
203
- exports.colorfulMode = {
204
- rect: { fill: '#72CBFF', stroke: '#3ABDF9', radius: 8 },
205
- circle: { fill: '#FFE075', stroke: '#F9CE3A', radius: 8 },
206
- ellipse: { fill: '#FFA8A8', stroke: '#FF6B66', radius: 8 },
207
- text: { fill: '#72CBFF', radius: 8 },
208
- diamond: { fill: '#96F7AF', stroke: '#40EF7E', radius: 8 },
209
- polygon: { fill: '#E0A8FF', stroke: '#C271FF', radius: 8 },
210
- polyline: { radius: 8 },
211
- arrow: {
212
- strokeLinecap: 'round',
213
- strokeLinejoin: 'round',
214
- offset: 10,
215
- verticalLength: 5, // 箭头垂直于边的距离
216
- },
217
- snapline: {
218
- strokeLinecap: 'round',
219
- strokeLinejoin: 'round',
220
- stroke: '#949494',
221
- strokeWidth: 1,
222
- },
223
- outline: {
224
- radius: 8,
225
- fill: 'transparent',
226
- stroke: '#949494',
227
- strokeDasharray: '3,3',
228
- hover: {
229
- stroke: '#949494',
230
- },
231
- },
232
- resizeOutline: {
233
- radius: 8,
234
- fill: 'none',
235
- stroke: 'transparent', // 矩形默认不显示调整边框
236
- strokeWidth: 1,
237
- strokeDasharray: '3,3',
238
- },
239
- };
240
- exports.themeModeMap = {
241
- colorful: exports.colorfulMode,
242
- dark: exports.darkMode,
243
- radius: exports.radiusMode,
244
- default: exports.defaultTheme,
245
- };
246
- // 不同主题的背景色
247
- exports.darkBackground = {
248
- background: '#23272e',
249
- };
250
- exports.colorfulBackground = {
251
- background: '#fefeff',
252
- };
253
- exports.defaultBackground = {
254
- background: '#ffffff',
255
- };
256
- exports.backgroundModeMap = {
257
- colorful: exports.colorfulBackground,
258
- dark: exports.darkBackground,
259
- radius: exports.defaultBackground,
260
- default: exports.defaultBackground,
261
- };
262
- // 不同主题的网格样式
263
- exports.darkGrid = {
264
- color: '#66676a',
265
- thickness: 1,
266
- };
267
- exports.colorfulGrid = {
268
- color: '#dadada',
269
- thickness: 1,
270
- };
271
- exports.defaultGrid = {
272
- color: '#acacac',
273
- thickness: 1,
274
- };
275
- exports.gridModeMap = {
276
- colorful: exports.colorfulGrid,
277
- dark: exports.darkGrid,
278
- radius: exports.defaultGrid,
279
- default: exports.defaultGrid,
280
- };
5
+ var theme_1 = require("../constant/theme");
281
6
  /* 主题(全局样式)相关工具方法 */
282
7
  var setupTheme = function (customTheme, themeMode) {
283
- var theme = (0, lodash_es_1.cloneDeep)(exports.defaultTheme);
284
- if (themeMode) {
285
- theme = (0, lodash_es_1.merge)(theme, exports.themeModeMap[themeMode]);
286
- }
8
+ var theme = (0, lodash_es_1.cloneDeep)(theme_1.themeModeMap[themeMode || 'default']) ||
9
+ (0, lodash_es_1.cloneDeep)(theme_1.themeModeMap.default);
287
10
  if (customTheme) {
288
11
  /**
289
12
  * 为了不让默认样式被覆盖,使用 merge 方法
@@ -318,31 +41,31 @@ var setupTheme = function (customTheme, themeMode) {
318
41
  };
319
42
  exports.setupTheme = setupTheme;
320
43
  var addThemeMode = function (themeMode, style) {
321
- if (exports.themeModeMap[themeMode]) {
44
+ if (theme_1.themeModeMap[themeMode]) {
322
45
  console.warn("theme mode ".concat(themeMode, " already exists"));
323
46
  return;
324
47
  }
325
- exports.themeModeMap[themeMode] = style;
326
- exports.backgroundModeMap[themeMode] = style.background || exports.defaultBackground;
327
- exports.gridModeMap[themeMode] = style.grid || exports.defaultGrid;
48
+ theme_1.themeModeMap[themeMode] = style;
49
+ theme_1.backgroundModeMap[themeMode] = style.background || theme_1.defaultBackground;
50
+ theme_1.gridModeMap[themeMode] = style.grid || theme_1.defaultGrid;
328
51
  };
329
52
  exports.addThemeMode = addThemeMode;
330
53
  var removeThemeMode = function (themeMode) {
331
- delete exports.themeModeMap[themeMode];
332
- delete exports.backgroundModeMap[themeMode];
333
- delete exports.gridModeMap[themeMode];
54
+ delete theme_1.themeModeMap[themeMode];
55
+ delete theme_1.backgroundModeMap[themeMode];
56
+ delete theme_1.gridModeMap[themeMode];
334
57
  };
335
58
  exports.removeThemeMode = removeThemeMode;
336
59
  var clearThemeMode = function () {
337
60
  var resetTheme = {
338
61
  colorful: {},
339
62
  dark: {},
340
- radius: {},
63
+ retro: {},
341
64
  default: {},
342
65
  };
343
- (0, lodash_es_1.assign)(exports.themeModeMap, resetTheme);
344
- (0, lodash_es_1.assign)(exports.backgroundModeMap, resetTheme);
345
- (0, lodash_es_1.assign)(exports.gridModeMap, resetTheme);
66
+ (0, lodash_es_1.assign)(theme_1.themeModeMap, resetTheme);
67
+ (0, lodash_es_1.assign)(theme_1.backgroundModeMap, resetTheme);
68
+ (0, lodash_es_1.assign)(theme_1.gridModeMap, resetTheme);
346
69
  };
347
70
  exports.clearThemeMode = clearThemeMode;
348
71
  /* 更新 theme 方法 */
@@ -50,6 +50,11 @@ export declare class ResizeControl extends Component<IResizeControlProps, IResiz
50
50
  onDragStart: () => void;
51
51
  onDragging: ({ deltaX, deltaY }: IDragParams) => void;
52
52
  onDragEnd: () => void;
53
+ onPointerDown: (e: PointerEvent) => void;
54
+ getViewPosition(direction: any, x: any, y: any): {
55
+ x: any;
56
+ y: any;
57
+ };
53
58
  render(): h.JSX.Element;
54
59
  }
55
60
  interface IResizeControlGroupProps {
@@ -246,61 +246,6 @@ var ResizeControl = /** @class */ (function (_super) {
246
246
  _this.dragHandler.cancelDrag();
247
247
  },
248
248
  });
249
- // 1. 计算当前 Control 的一些信息,
250
- // const {
251
- // r, // circle
252
- // rx, // ellipse/diamond
253
- // ry,
254
- // width, // rect/html
255
- // height,
256
- // PCTResizeInfo,
257
- //
258
- // minWidth,
259
- // minHeight,
260
- // maxWidth,
261
- // maxHeight,
262
- // } = this.nodeModel
263
- // const isFreezeWidth = minWidth === maxWidth
264
- // const isFreezeHeight = minHeight === maxHeight
265
- //
266
- // const resizeInfo = {
267
- // width: r || rx || width,
268
- // height: r || ry || height,
269
- // deltaX,
270
- // deltaY,
271
- // PCTResizeInfo,
272
- // }
273
- //
274
- // const pct = r || (rx && ry) ? 1 / 2 : 1
275
- // const nextSize = this.recalcResizeInfo(
276
- // this.index,
277
- // resizeInfo,
278
- // pct,
279
- // isFreezeWidth,
280
- // isFreezeHeight,
281
- // )
282
- //
283
- // // 限制放大缩小的最大最小范围
284
- // if (
285
- // nextSize.width < minWidth ||
286
- // nextSize.width > maxWidth ||
287
- // nextSize.height < minHeight ||
288
- // nextSize.height > maxHeight
289
- // ) {
290
- // this.dragHandler.cancelDrag()
291
- // return
292
- // }
293
- // // 如果限制了宽高不变,对应的 x/y 不产生位移
294
- // nextSize.deltaX = isFreezeWidth ? 0 : nextSize.deltaX
295
- // nextSize.deltaY = isFreezeWidth ? 0 : nextSize.deltaY
296
- //
297
- // const preNodeData = this.nodeModel.getData()
298
- // const curNodeData = this.nodeModel.resize(nextSize)
299
- //
300
- // // 更新边
301
- // this.updateEdgePointByAnchors()
302
- // // 触发 resize 事件
303
- // this.triggerResizeEvent(preNodeData, curNodeData, deltaX, deltaY, this.index, this.nodeModel)
304
249
  };
305
250
  _this.onDragStart = function () {
306
251
  _this.graphModel.selectNodeById(_this.nodeModel.id);
@@ -328,6 +273,10 @@ var ResizeControl = /** @class */ (function (_super) {
328
273
  // 此时拿到的 anchors 是最新的
329
274
  _this.updateEdgePointByAnchors();
330
275
  };
276
+ _this.onPointerDown = function (e) {
277
+ e.stopPropagation();
278
+ _this.dragHandler.handleMouseDown(e);
279
+ };
331
280
  var index = props.index, model = props.model, graphModel = props.graphModel;
332
281
  _this.index = index;
333
282
  _this.nodeModel = model;
@@ -346,10 +295,46 @@ var ResizeControl = /** @class */ (function (_super) {
346
295
  document.removeEventListener('keydown', this.handleKeyDown);
347
296
  document.removeEventListener('keyup', this.handleKeyUp);
348
297
  };
298
+ ResizeControl.prototype.getViewPosition = function (direction, x, y) {
299
+ var _a = this.props.model.getResizeControlStyle(), _b = _a.width, width = _b === void 0 ? 8 : _b, _c = _a.height, height = _c === void 0 ? 8 : _c;
300
+ switch (direction) {
301
+ case 'nw':
302
+ return {
303
+ x: x - width / 2,
304
+ y: y - height / 2,
305
+ };
306
+ case 'ne': {
307
+ return {
308
+ x: x + width / 2,
309
+ y: y - height / 2,
310
+ };
311
+ }
312
+ case 'se': {
313
+ return {
314
+ x: x + width / 2,
315
+ y: y + height / 2,
316
+ };
317
+ }
318
+ case 'sw': {
319
+ return {
320
+ x: x - width / 2,
321
+ y: y + height / 2,
322
+ };
323
+ }
324
+ default: {
325
+ return {
326
+ x: x,
327
+ y: y,
328
+ };
329
+ }
330
+ }
331
+ };
349
332
  ResizeControl.prototype.render = function () {
350
333
  var _a = this.props, x = _a.x, y = _a.y, direction = _a.direction, model = _a.model;
351
334
  var _b = model.getResizeControlStyle(), width = _b.width, height = _b.height, restStyle = __rest(_b, ["width", "height"]);
352
- return ((0, jsx_runtime_1.jsxs)("g", { className: "lf-resize-control lf-resize-control-".concat(direction), children: [(0, jsx_runtime_1.jsx)(shape_1.Rect, __assign({ className: "lf-resize-control-content", x: x, y: y, width: width !== null && width !== void 0 ? width : 7, height: height !== null && height !== void 0 ? height : 7 }, restStyle)), (0, jsx_runtime_1.jsx)(shape_1.Rect, { className: "lf-resize-control-content", x: x, y: y, width: 25, height: 25, fill: "transparent", stroke: "transparent", onPointerDown: this.dragHandler.handleMouseDown })] }));
335
+ // 为了让调整点在视觉上在调整外框的中间,因此在渲染时转换一下
336
+ var _c = this.getViewPosition(direction, x, y), viewX = _c.x, viewY = _c.y;
337
+ return ((0, jsx_runtime_1.jsxs)("g", { className: "lf-resize-control lf-resize-control-".concat(direction), children: [(0, jsx_runtime_1.jsx)(shape_1.Rect, __assign({ className: "lf-resize-control-content", x: viewX, y: viewY, width: width !== null && width !== void 0 ? width : 7, height: height !== null && height !== void 0 ? height : 7 }, restStyle)), (0, jsx_runtime_1.jsx)(shape_1.Rect, { className: "lf-resize-control-content", x: viewX, y: viewY, width: width ? width + 5 : 25, height: width ? width + 5 : 25, fill: "transparent", stroke: "transparent", onPointerDown: this.onPointerDown })] }));
353
338
  };
354
339
  return ResizeControl;
355
340
  }(compat_1.Component));
@@ -394,7 +379,9 @@ var ResizeControlGroup = /** @class */ (function (_super) {
394
379
  var model = this.props.model;
395
380
  var x = model.x, y = model.y, width = model.width, height = model.height;
396
381
  var style = model.getResizeOutlineStyle();
397
- return (0, jsx_runtime_1.jsx)(shape_1.Rect, __assign({}, style, { x: x, y: y, width: width, height: height }));
382
+ return ((0, jsx_runtime_1.jsx)(shape_1.Rect, __assign({}, style, { "pointer-events": "none", x: x, y: y,
383
+ // TODO:宽高padding后续改成配置化的
384
+ width: width + 10, height: height + 10 })));
398
385
  };
399
386
  ResizeControlGroup.prototype.render = function () {
400
387
  return ((0, jsx_runtime_1.jsxs)("g", { className: "lf-resize-control-group", children: [this.getResizeOutline(), this.getResizeControl()] }));
@@ -51,6 +51,7 @@ var BaseEdge_1 = __importDefault(require("./BaseEdge"));
51
51
  var shape_1 = require("../shape");
52
52
  var constant_1 = require("../../constant");
53
53
  var util_1 = require("../../util");
54
+ var geometry_1 = require("../../util/geometry");
54
55
  var algorithm_1 = require("../../algorithm");
55
56
  var PolylineEdge = /** @class */ (function (_super) {
56
57
  __extends(PolylineEdge, _super);
@@ -131,12 +132,22 @@ var PolylineEdge = /** @class */ (function (_super) {
131
132
  * @example https://docs.logic-flow.cn/docs/#/zh/guide/basic/edge?id=%e5%9f%ba%e4%ba%8e-react-%e7%bb%84%e4%bb%b6%e8%87%aa%e5%ae%9a%e4%b9%89%e8%be%b9
132
133
  */
133
134
  PolylineEdge.prototype.getEdge = function () {
135
+ var _a, _b;
134
136
  var model = this.props.model;
135
- var points = model.points, isAnimation = model.isAnimation, arrowConfig = model.arrowConfig;
137
+ var points = model.points, isAnimation = model.isAnimation, arrowConfig = model.arrowConfig, properties = model.properties;
136
138
  var style = model.getEdgeStyle();
137
139
  var animationStyle = model.getEdgeAnimationStyle();
138
140
  var strokeDasharray = animationStyle.strokeDasharray, stroke = animationStyle.stroke, strokeDashoffset = animationStyle.strokeDashoffset, animationName = animationStyle.animationName, animationDuration = animationStyle.animationDuration, animationIterationCount = animationStyle.animationIterationCount, animationTimingFunction = animationStyle.animationTimingFunction, animationDirection = animationStyle.animationDirection;
139
- return ((0, jsx_runtime_1.jsx)(shape_1.Polyline, __assign({ points: points }, style, arrowConfig, (isAnimation
141
+ // 应用通用圆角:当存在样式半径时,为折线拐点生成圆角
142
+ var radius = ((_b = (_a = properties === null || properties === void 0 ? void 0 : properties.radius) !== null && _a !== void 0 ? _a : style === null || style === void 0 ? void 0 : style.radius) !== null && _b !== void 0 ? _b : 0);
143
+ var roundedPointsStr = (function () {
144
+ if (!radius || radius <= 0)
145
+ return points;
146
+ var list = (0, util_1.points2PointsList)(points);
147
+ var rounded = (0, geometry_1.generateRoundedCorners)(list, radius, false);
148
+ return rounded.map(function (p) { return "".concat(p.x, ",").concat(p.y); }).join(' ');
149
+ })();
150
+ return ((0, jsx_runtime_1.jsx)(shape_1.Polyline, __assign({ points: roundedPointsStr }, style, arrowConfig, (isAnimation
140
151
  ? {
141
152
  strokeDasharray: strokeDasharray,
142
153
  stroke: stroke,
@@ -20,6 +20,7 @@ export declare abstract class BaseNode<P extends IProps = IProps> extends Compon
20
20
  startTime?: number;
21
21
  modelDisposer: IReactionDisposer;
22
22
  longPressTimer?: number;
23
+ mouseDownPosition?: LogicFlow.Position;
23
24
  constructor(props: IProps);
24
25
  componentWillUnmount(): void;
25
26
  componentDidMount(): void;
@@ -90,13 +90,16 @@ var BaseNode = /** @class */ (function (_super) {
90
90
  var event = _a.event;
91
91
  var _f = _this.props, model = _f.model, graphModel = _f.graphModel;
92
92
  var _g = graphModel.editConfigModel, stopMoveGraph = _g.stopMoveGraph, autoExpand = _g.autoExpand, snapGrid = _g.snapGrid, transformModel = graphModel.transformModel, selectNodes = graphModel.selectNodes, width = graphModel.width, height = graphModel.height, gridSize = graphModel.gridSize;
93
- model.isDragging = true;
94
93
  var _h = event, clientX = _h.clientX, clientY = _h.clientY;
95
- var _j = graphModel.getPointByClient({
94
+ var _j = _this.mouseDownPosition, mouseDownX = _j.x, mouseDownY = _j.y;
95
+ if (clientX - mouseDownX > gridSize || clientY - mouseDownY > gridSize) {
96
+ model.isDragging = true;
97
+ }
98
+ var _k = graphModel.getPointByClient({
96
99
  x: clientX,
97
100
  y: clientY,
98
- }).canvasOverlayPosition, x = _j.x, y = _j.y;
99
- var _k = __read(transformModel.CanvasPointToHtmlPoint([x, y]), 2), x1 = _k[0], y1 = _k[1];
101
+ }).canvasOverlayPosition, x = _k.x, y = _k.y;
102
+ var _l = __read(transformModel.CanvasPointToHtmlPoint([x, y]), 2), x1 = _l[0], y1 = _l[1];
100
103
  // 1. 考虑画布被缩放
101
104
  // 2. 考虑鼠标位置不再节点中心
102
105
  x = x + ((_c = (_b = _this.moveOffset) === null || _b === void 0 ? void 0 : _b.dx) !== null && _c !== void 0 ? _c : 0);
@@ -114,14 +117,14 @@ var BaseNode = /** @class */ (function (_super) {
114
117
  return;
115
118
  }
116
119
  // 取节点左上角和右下角,计算节点移动是否超出范围
117
- var _l = __read(transformModel.CanvasPointToHtmlPoint([
120
+ var _m = __read(transformModel.CanvasPointToHtmlPoint([
118
121
  x - model.width / 2,
119
122
  y - model.height / 2,
120
- ]), 2), leftTopX = _l[0], leftTopY = _l[1];
121
- var _m = __read(transformModel.CanvasPointToHtmlPoint([
123
+ ]), 2), leftTopX = _m[0], leftTopY = _m[1];
124
+ var _o = __read(transformModel.CanvasPointToHtmlPoint([
122
125
  x + model.width / 2,
123
126
  y + model.height / 2,
124
- ]), 2), rightBottomX = _m[0], rightBottomY = _m[1];
127
+ ]), 2), rightBottomX = _o[0], rightBottomY = _o[1];
125
128
  var size = Math.max(gridSize, 20);
126
129
  var nearBoundary = [];
127
130
  if (leftTopX < 0) {
@@ -188,7 +191,7 @@ var BaseNode = /** @class */ (function (_super) {
188
191
  var _a = _this.props, model = _a.model, graphModel = _a.graphModel;
189
192
  // 这里会有一种极端情况:当网格大小是1或者关闭网格吸附时,用触摸板点击节点会触发拖拽事件导致节点无法选中
190
193
  // 当触摸板点击节点时,为了防止误触发拖拽导致节点无法选中,允许在非拖拽状态且时间间隔小于100ms时触发点击事件
191
- if (!isDragging && timeInterval > 100)
194
+ if (!isDragging && timeInterval > 300)
192
195
  return;
193
196
  if (!isDragging) {
194
197
  _this.onDragEnd();
@@ -271,6 +274,7 @@ var BaseNode = /** @class */ (function (_super) {
271
274
  };
272
275
  _this.handleMouseDown = function (ev) {
273
276
  var _a = _this.props, model = _a.model, graphModel = _a.graphModel;
277
+ _this.mouseDownPosition = { x: ev.clientX, y: ev.clientY };
274
278
  _this.startTime = new Date().getTime();
275
279
  var editConfigModel = graphModel.editConfigModel;
276
280
  if (editConfigModel.adjustNodePosition && model.draggable) {
@@ -458,7 +462,7 @@ var BaseNode = /** @class */ (function (_super) {
458
462
  var _b = graphModel.editConfigModel, hideAnchors = _b.hideAnchors, adjustNodePosition = _b.adjustNodePosition, allowRotate = _b.allowRotate, allowResize = _b.allowResize, gridSize = graphModel.gridSize, SCALE_X = graphModel.transformModel.SCALE_X;
459
463
  var isHitable = model.isHitable, draggable = model.draggable, transform = model.transform;
460
464
  var _c = model.getOuterGAttributes(), _d = _c.className, className = _d === void 0 ? '' : _d, restAttributes = __rest(_c, ["className"]);
461
- var nodeShapeInner = ((0, jsx_runtime_1.jsxs)("g", { className: "lf-node-content", children: [(0, jsx_runtime_1.jsxs)("g", { transform: transform, children: [this.getShape(), this.getText(), allowRotate && this.getRotateControl(), allowResize && this.getResizeControl()] }), !hideAnchors && this.getAnchors()] }));
465
+ var nodeShapeInner = ((0, jsx_runtime_1.jsxs)("g", { className: "lf-node-content", children: [(0, jsx_runtime_1.jsxs)("g", { transform: transform, children: [this.getShape(), this.getText(), allowResize && this.getResizeControl(), allowRotate && this.getRotateControl()] }), !hideAnchors && this.getAnchors()] }));
462
466
  var nodeShape;
463
467
  if (!isHitable) {
464
468
  nodeShape = ((0, jsx_runtime_1.jsx)("g", __assign({ className: "".concat(this.getStateClassName(), " ").concat(className) }, restAttributes, { children: nodeShapeInner })));
@@ -105,13 +105,11 @@ var HtmlNode = /** @class */ (function (_super) {
105
105
  return true;
106
106
  };
107
107
  HtmlNode.prototype.componentDidMount = function () {
108
- // console.log('HtmlNode --->>> componentDidMount - 初始化内容')
109
108
  if (this.shouldUpdate() && this.rootEl) {
110
109
  this.setHtml(this.rootEl);
111
110
  }
112
111
  };
113
112
  HtmlNode.prototype.componentDidUpdate = function () {
114
- // console.log('HtmlNode --->>> componentDidUpdate - 更新节点内容')
115
113
  // DONE: 将 componentDidMount 和 componentDidUpdate 区分开,如果写在一次,渲染 React 组件会重复初始化,消耗过多资源
116
114
  // 为了保证历史兼容性,先将默认 HTML 节点的 setHtml 和 confirmUpdate 保持一直,用户可通过自定义的方式重新定义
117
115
  if (this.shouldUpdate() && this.rootEl) {
@@ -127,7 +125,7 @@ var HtmlNode = /** @class */ (function (_super) {
127
125
  var x = model.x, y = model.y, height = model.height, width = model.width;
128
126
  var style = model.getNodeStyle();
129
127
  this.currentProperties = JSON.stringify(model.properties);
130
- return ((0, jsx_runtime_1.jsx)("foreignObject", __assign({}, style, { x: x - width / 2, y: y - height / 2, width: width, height: height, ref: this.ref })));
128
+ return ((0, jsx_runtime_1.jsxs)("g", { children: [style.shadow && ((0, jsx_runtime_1.jsx)("defs", { children: (0, jsx_runtime_1.jsx)("filter", { id: "shadow", x: "-50%", y: "-50%", width: "200%", height: "200%", children: (0, jsx_runtime_1.jsx)("feDropShadow", __assign({}, style.shadow)) }) })), (0, jsx_runtime_1.jsx)("rect", __assign({ x: x - width / 2, y: y - height / 2, width: width, height: height, rx: style.radius, ry: style.radius }, style, { filter: "url(#shadow)" })), (0, jsx_runtime_1.jsx)("foreignObject", __assign({}, style, { x: x - width / 2, y: y - height / 2, width: width, height: height, ref: this.ref }))] }));
131
129
  };
132
130
  return HtmlNode;
133
131
  }(BaseNode_1.default));
@@ -1,4 +1,5 @@
1
1
  import { Component } from 'preact/compat';
2
+ import { MajorBoldConfig } from './gridConfig';
2
3
  import { GraphModel } from '../../model';
3
4
  type IProps = {
4
5
  graphModel: GraphModel;
@@ -8,6 +9,10 @@ export declare class Grid extends Component<IProps> {
8
9
  readonly id: string;
9
10
  constructor(props: IProps);
10
11
  renderDot(): import("preact/compat").JSX.Element;
12
+ private getDashArrayForSize;
13
+ private getPeriod;
14
+ private getBoldStrokeWidth;
15
+ private renderMeshEdgeLines;
11
16
  renderMesh(): import("preact/compat").JSX.Element;
12
17
  render(): import("preact/compat").JSX.Element;
13
18
  }
@@ -39,8 +44,14 @@ export declare namespace Grid {
39
44
  */
40
45
  thickness?: number;
41
46
  };
47
+ /**
48
+ * 行为配置:支持 boolean 或高级对象
49
+ * - false: 禁用特殊样式,opacity=1,无加粗,无虚线
50
+ * - true: 启用默认样式,opacity=0.75,每第5个加粗/实线,虚线动态计算
51
+ * - object: 高级配置,详见 MajorBoldConfig
52
+ */
53
+ majorBold?: boolean | MajorBoldConfig;
42
54
  };
43
- const defaultProps: GridOptions;
44
55
  function getGridOptions(options: number | boolean | GridOptions): GridOptions;
45
56
  }
46
57
  export {};