@logicflow/core 2.2.0-alpha.1 → 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 -57
  2. package/.turbo/turbo-build.log +6 -6
  3. package/CHANGELOG.md +12 -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
@@ -51,11 +51,11 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
51
51
  }
52
52
  return to.concat(ar || Array.prototype.slice.call(from));
53
53
  };
54
- import { find, forEach, map, merge, isBoolean, debounce, cloneDeep, isNil, } from 'lodash-es';
54
+ import { assign, find, forEach, map, merge, isBoolean, debounce, cloneDeep, isNil, } from 'lodash-es';
55
55
  import { action, computed, observable } from 'mobx';
56
56
  import { EditConfigModel, } from '.';
57
- import { DEFAULT_VISIBLE_SPACE, ELEMENT_MAX_Z_INDEX, ElementState, ElementType, EventType, ModelType, OverlapMode, TextMode, } from '../constant';
58
- import { createEdgeGenerator, createUuid, formatData, getClosestPointOfPolyline, getMinIndex, getNodeAnchorPosition, getNodeBBox, getZIndex, isPointInArea, setupAnimation, setupTheme, snapToGrid, updateTheme, backgroundModeMap, gridModeMap, } from '../util';
57
+ import { DEFAULT_VISIBLE_SPACE, ELEMENT_MAX_Z_INDEX, ElementState, ElementType, EventType, ModelType, OverlapMode, TextMode, backgroundModeMap, gridModeMap, } from '../constant';
58
+ import { createEdgeGenerator, createUuid, formatData, getClosestPointOfPolyline, getMinIndex, getNodeAnchorPosition, getNodeBBox, getZIndex, isPointInArea, setupAnimation, setupTheme, snapToGrid, updateTheme, } from '../util';
59
59
  import EventEmitter from '../event/eventEmitter';
60
60
  import { Grid } from '../view/overlay';
61
61
  import NestedTransformModel from './NestedTransformModel';
@@ -63,6 +63,7 @@ var GraphModel = /** @class */ (function () {
63
63
  function GraphModel(options) {
64
64
  var _this = this;
65
65
  var _a, _b;
66
+ this.themeMode = 'default';
66
67
  // 维护所有节点和边类型对应的 model
67
68
  this.modelMap = new Map();
68
69
  // Remind:用于记录当前画布上所有节点和边的 model 的 Map
@@ -97,6 +98,9 @@ var GraphModel = /** @class */ (function () {
97
98
  this.partial = false;
98
99
  this.waitCleanEffects = [];
99
100
  var container = options.container, partial = options.partial, _c = options.background, background = _c === void 0 ? {} : _c, grid = options.grid, idGenerator = options.idGenerator, edgeGenerator = options.edgeGenerator, animation = options.animation, customTrajectory = options.customTrajectory, customTargetAnchor = options.customTargetAnchor;
101
+ this.themeMode = options.themeMode || 'default';
102
+ var initialGrid = gridModeMap[this.themeMode] || gridModeMap['default'];
103
+ var initialBackground = backgroundModeMap[this.themeMode] || backgroundModeMap['default'];
100
104
  this.rootEl = container;
101
105
  this.partial = !!partial;
102
106
  this.background = background;
@@ -105,11 +109,14 @@ var GraphModel = /** @class */ (function () {
105
109
  // TODO:需要让用户设置成 0 吗?后面可以讨论一下
106
110
  this.gridSize = grid.size || 1; // 默认 gridSize 设置为 1
107
111
  }
108
- this.customStyles = options.style || {};
109
- this.grid = Grid.getGridOptions(grid !== null && grid !== void 0 ? grid : false);
112
+ this.customStyles = (options.style || {});
110
113
  this.theme = setupTheme(options.style, options.themeMode);
114
+ this.grid = Grid.getGridOptions(assign({}, initialGrid, grid));
111
115
  this.theme.grid = cloneDeep(this.grid);
112
- this.theme.background = cloneDeep(this.background);
116
+ if (background) {
117
+ this.background = cloneDeep(assign({}, initialBackground, background));
118
+ this.theme.background = cloneDeep(assign({}, initialBackground, background));
119
+ }
113
120
  this.edgeType = options.edgeType || 'polyline';
114
121
  this.animation = setupAnimation(animation);
115
122
  this.overlapMode = options.overlapMode || OverlapMode.DEFAULT;
@@ -1332,6 +1339,7 @@ var GraphModel = /** @class */ (function () {
1332
1339
  GraphModel.prototype.setTheme = function (style, themeMode) {
1333
1340
  var _a;
1334
1341
  if (themeMode) {
1342
+ this.themeMode = themeMode;
1335
1343
  // 修改背景颜色
1336
1344
  backgroundModeMap[themeMode] &&
1337
1345
  this.updateBackgroundOptions(__assign(__assign({}, (typeof this.background === 'object' ? this.background : {})), backgroundModeMap[themeMode]));
@@ -1529,6 +1537,9 @@ var GraphModel = /** @class */ (function () {
1529
1537
  __decorate([
1530
1538
  observable
1531
1539
  ], GraphModel.prototype, "theme", void 0);
1540
+ __decorate([
1541
+ observable
1542
+ ], GraphModel.prototype, "themeMode", void 0);
1532
1543
  __decorate([
1533
1544
  observable
1534
1545
  ], GraphModel.prototype, "grid", void 0);
@@ -30,15 +30,15 @@ var translateLimitsMap = {
30
30
  };
31
31
  var TransformModel = /** @class */ (function () {
32
32
  function TransformModel(eventCenter, options) {
33
- this.MINI_SCALE_SIZE = 0.2;
34
- this.MAX_SCALE_SIZE = 16;
35
- this.SCALE_X = 1;
36
- this.SKEW_Y = 0;
37
- this.SKEW_X = 0;
38
- this.SCALE_Y = 1;
39
- this.TRANSLATE_X = 0;
40
- this.TRANSLATE_Y = 0;
41
- this.ZOOM_SIZE = 0.04;
33
+ this.MINI_SCALE_SIZE = 0.2; // 缩小的最小值
34
+ this.MAX_SCALE_SIZE = 16; // 放大的最大值
35
+ this.SCALE_X = 1; // x轴缩放比例
36
+ this.SKEW_Y = 0; // y轴倾斜角度
37
+ this.SKEW_X = 0; // x轴倾斜角度
38
+ this.SCALE_Y = 1; // y轴缩放比例
39
+ this.TRANSLATE_X = 0; // x轴平移距离
40
+ this.TRANSLATE_Y = 0; // y轴平移距离
41
+ this.ZOOM_SIZE = 0.04; // 缩放比例变化量
42
42
  // 限制画布可移动区域
43
43
  this.translateLimitMinX = -Infinity;
44
44
  this.translateLimitMinY = -Infinity;
@@ -192,8 +192,13 @@ var BaseEdgeModel = /** @class */ (function () {
192
192
  */
193
193
  BaseEdgeModel.prototype.getOutlineStyle = function () {
194
194
  var graphModel = this.graphModel;
195
- var outline = graphModel.theme.outline;
196
- return cloneDeep(outline);
195
+ var edgeOutline = graphModel.theme.edgeOutline;
196
+ var attributes = __assign({}, edgeOutline);
197
+ if (this.isHovered) {
198
+ var hoverStyle = edgeOutline.hover || {};
199
+ attributes = __assign(__assign({}, attributes), hoverStyle);
200
+ }
201
+ return cloneDeep(attributes);
197
202
  };
198
203
  /**
199
204
  * 重新自定义文本位置
@@ -12,6 +12,12 @@ export declare class PolylineEdgeModel extends BaseEdgeModel {
12
12
  offset?: number;
13
13
  dbClickPosition?: Point;
14
14
  initEdgeData(data: LogicFlow.EdgeConfig): void;
15
+ setAttributes(): void;
16
+ /**
17
+ * 计算默认 offset:箭头与折线重叠长度 + 5
18
+ * 重叠长度采用箭头样式中的 offset(沿边方向的长度)
19
+ */
20
+ private getDefaultOffset;
15
21
  getEdgeStyle(): {
16
22
  [x: string]: unknown;
17
23
  fill?: string | undefined;
@@ -69,12 +69,34 @@ var PolylineEdgeModel = /** @class */ (function (_super) {
69
69
  return _this;
70
70
  }
71
71
  PolylineEdgeModel.prototype.initEdgeData = function (data) {
72
- this.offset = get(data, 'properties.offset', 30);
72
+ var providedOffset = get(data, 'properties.offset');
73
+ // 当用户未传入 offset 时,按“箭头与折线重叠长度 + 5”作为默认值
74
+ // 其中“重叠长度”采用箭头样式中的 offset(沿边方向的长度)
75
+ this.offset =
76
+ typeof providedOffset === 'number'
77
+ ? providedOffset
78
+ : this.getDefaultOffset();
73
79
  if (data.pointsList) {
74
80
  this.pointsList = data.pointsList;
75
81
  }
76
82
  _super.prototype.initEdgeData.call(this, data);
77
83
  };
84
+ PolylineEdgeModel.prototype.setAttributes = function () {
85
+ var newOffset = this.properties.offset;
86
+ if (newOffset && newOffset !== this.offset) {
87
+ this.offset = newOffset;
88
+ this.updatePoints();
89
+ }
90
+ };
91
+ /**
92
+ * 计算默认 offset:箭头与折线重叠长度 + 5
93
+ * 重叠长度采用箭头样式中的 offset(沿边方向的长度)
94
+ */
95
+ PolylineEdgeModel.prototype.getDefaultOffset = function () {
96
+ var arrowStyle = this.getArrowStyle();
97
+ var arrowOverlap = typeof arrowStyle.offset === 'number' ? arrowStyle.offset : 0;
98
+ return arrowOverlap + 5;
99
+ };
78
100
  PolylineEdgeModel.prototype.getEdgeStyle = function () {
79
101
  var polyline = this.graphModel.theme.polyline;
80
102
  var style = _super.prototype.getEdgeStyle.call(this);
@@ -185,7 +185,18 @@ export declare class BaseNodeModel<P extends PropertiesType = PropertiesType> im
185
185
  * 获取当前节点缩放控制节点的样式
186
186
  */
187
187
  getResizeControlStyle(): LogicFlow.CommonTheme;
188
- getResizeOutlineStyle(): LogicFlow.CommonTheme;
188
+ getResizeOutlineStyle(): {
189
+ [x: string]: unknown;
190
+ fill?: string | undefined;
191
+ stroke?: string | undefined;
192
+ strokeWidth?: number | undefined;
193
+ radius?: number | undefined;
194
+ rx?: number | undefined;
195
+ ry?: number | undefined;
196
+ width?: number | undefined;
197
+ height?: number | undefined;
198
+ path?: string | undefined;
199
+ };
189
200
  /**
190
201
  * @overridable 支持重写
191
202
  * 获取当前节点锚点样式
@@ -379,7 +379,12 @@ var BaseNodeModel = /** @class */ (function () {
379
379
  };
380
380
  BaseNodeModel.prototype.getResizeOutlineStyle = function () {
381
381
  var resizeOutline = this.graphModel.theme.resizeOutline;
382
- return cloneDeep(resizeOutline);
382
+ var attributes = __assign({}, resizeOutline);
383
+ if (this.isHovered) {
384
+ var hoverStyle = resizeOutline.hover || {};
385
+ attributes = __assign(__assign({}, attributes), hoverStyle);
386
+ }
387
+ return cloneDeep(attributes);
383
388
  };
384
389
  /**
385
390
  * @overridable 支持重写
@@ -16,5 +16,17 @@ export declare class HtmlNodeModel<P extends IHtmlNodeProperties = IHtmlNodeProp
16
16
  constructor(data: LogicFlow.NodeConfig<P>, graphModel: GraphModel);
17
17
  setAttributes(): void;
18
18
  getDefaultAnchor(): AnchorConfig[];
19
+ getNodeStyle(): {
20
+ [x: string]: unknown;
21
+ fill?: string | undefined;
22
+ stroke?: string | undefined;
23
+ strokeWidth?: number | undefined;
24
+ radius?: number | undefined;
25
+ rx?: number | undefined;
26
+ ry?: number | undefined;
27
+ width?: number | undefined;
28
+ height?: number | undefined;
29
+ path?: string | undefined;
30
+ };
19
31
  }
20
32
  export default HtmlNodeModel;
@@ -13,6 +13,18 @@ var __extends = (this && this.__extends) || (function () {
13
13
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
14
  };
15
15
  })();
16
+ var __assign = (this && this.__assign) || function () {
17
+ __assign = Object.assign || function(t) {
18
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
19
+ s = arguments[i];
20
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
21
+ t[p] = s[p];
22
+ }
23
+ return t;
24
+ };
25
+ return __assign.apply(this, arguments);
26
+ };
27
+ import { cloneDeep } from 'lodash-es';
16
28
  import BaseNodeModel from './BaseNodeModel';
17
29
  import { ModelType } from '../../constant';
18
30
  var HtmlNodeModel = /** @class */ (function (_super) {
@@ -42,6 +54,13 @@ var HtmlNodeModel = /** @class */ (function (_super) {
42
54
  { x: x - width / 2, y: y, id: "".concat(this.id, "_3") },
43
55
  ];
44
56
  };
57
+ HtmlNodeModel.prototype.getNodeStyle = function () {
58
+ var style = _super.prototype.getNodeStyle.call(this);
59
+ var _a = this.graphModel.theme, baseNode = _a.baseNode, html = _a.html;
60
+ var _b = this.properties.style, customStyle = _b === void 0 ? {} : _b;
61
+ var finalStyle = __assign(__assign(__assign(__assign({}, style), cloneDeep(baseNode)), cloneDeep(html)), cloneDeep(customStyle));
62
+ return finalStyle;
63
+ };
45
64
  return HtmlNodeModel;
46
65
  }(BaseNodeModel));
47
66
  export { HtmlNodeModel };
@@ -88,9 +88,9 @@ var PolygonNodeModel = /** @class */ (function (_super) {
88
88
  };
89
89
  PolygonNodeModel.prototype.getNodeStyle = function () {
90
90
  var style = _super.prototype.getNodeStyle.call(this);
91
- var polygon = this.graphModel.theme.polygon;
92
- var _a = this.properties.style, customStyle = _a === void 0 ? {} : _a;
93
- return __assign(__assign(__assign({}, style), cloneDeep(polygon)), cloneDeep(customStyle));
91
+ var _a = this.graphModel, polygon = _a.theme.polygon, customPolygon = _a.customStyles.polygon;
92
+ var _b = this.properties.style, customStyle = _b === void 0 ? {} : _b;
93
+ return __assign(__assign(__assign(__assign({}, style), cloneDeep(polygon)), cloneDeep(customPolygon)), cloneDeep(customStyle));
94
94
  };
95
95
  Object.defineProperty(PolygonNodeModel.prototype, "pointsPosition", {
96
96
  /**
package/es/options.d.ts CHANGED
@@ -70,7 +70,7 @@ export declare namespace Options {
70
70
  edgeGenerator?: EdgeGeneratorType;
71
71
  customTargetAnchor?: customTargetAnchorType;
72
72
  customTrajectory?: (props: CustomAnchorLineProps) => h.JSX.Element;
73
- themeMode?: 'radius' | 'dark' | 'colorful';
73
+ themeMode?: LogicFlow.ThemeMode;
74
74
  parentTransform?: TransformModel;
75
75
  [key: string]: unknown;
76
76
  }
@@ -177,8 +177,9 @@
177
177
  }
178
178
  .lf-multiple-select {
179
179
  position: absolute;
180
- border: 2px dashed #187dffcc;
181
- box-shadow: 0 0 3px 0 #187dff80;
180
+ border: 2px dashed #4271dfcc;
181
+ border-radius: 12px;
182
+ box-shadow: 0 0 3px 0 #4271df80;
182
183
  cursor: move;
183
184
  }
184
185
  .lf-edge-adjust-point {
@@ -215,8 +215,9 @@
215
215
 
216
216
  .lf-multiple-select {
217
217
  position: absolute;
218
- border: 2px dashed #187dffcc;
219
- box-shadow: 0 0 3px 0 #187dff80;
218
+ border: 2px dashed #4271dfcc;
219
+ border-radius: 12px;
220
+ box-shadow: 0 0 3px 0 #4271df80;
220
221
  cursor: move;
221
222
  }
222
223
 
package/es/style/raw.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * Auto generated file, do not modify it!
3
3
  */
4
- export declare const content = ".lf-graph {\n position: relative;\n z-index: 0;\n width: 100%;\n height: 100%;\n background: #fff;\n user-select: none;\n}\n.lf-element-text {\n cursor: text;\n}\n.lf-text-disabled {\n pointer-events: none;\n}\n.lf-text-draggable {\n cursor: move;\n}\n*:focus {\n outline: none;\n}\n.lf-node-anchor {\n cursor: crosshair;\n}\n.lf-node-anchor-hover {\n visibility: hidden;\n}\n.lf-anchor:hover .lf-node-anchor-hover {\n visibility: visible;\n}\n.lf-edge.pointer-none {\n pointer-events: none;\n}\n.lf-edge-append {\n cursor: pointer;\n}\n.lf-edge-animation {\n stroke-dashoffset: 100%;\n animation: lf_animate_dash 5s linear infinite;\n}\n@keyframes lf_animate_dash {\n to {\n stroke-dashoffset: 0;\n }\n}\n/* node */\n.lf-node-not-allow {\n cursor: not-allowed;\n}\n.lf-polyline-append-ns-resize {\n cursor: ns-resize;\n}\n.lf-polyline-append-ew-resize {\n cursor: ew-resize;\n}\n.lf-dragging {\n cursor: move;\n}\n.lf-dragging .lf-element-text {\n cursor: move;\n}\n.lf-draggable {\n cursor: default;\n}\n.lf-bezier-adjust-anchor {\n cursor: pointer;\n}\n/* background */\n.lf-background,\n.lf-grid {\n position: absolute;\n inset: 0;\n z-index: -1;\n}\n.lf-background-area {\n width: 100%;\n height: 100%;\n}\n/* html-overlay */\n.lf-html-overlay {\n position: absolute;\n inset: 0;\n z-index: 1;\n overflow: hidden;\n user-select: none;\n pointer-events: none;\n}\n.lf-html-overlay__transform > * {\n pointer-events: all;\n}\n.lf-text-editable {\n pointer-events: all;\n}\n.lf-text-input {\n position: absolute;\n box-sizing: border-box;\n min-width: 100px;\n min-height: 20px;\n padding: 5px;\n line-height: 1.2;\n white-space: pre;\n text-align: center;\n background: #fff;\n border: 1px solid #edefed;\n border-radius: 3px;\n outline: none;\n transform: translate(-50%, -50%);\n resize: none;\n}\n.lf-get-text-height {\n display: inline-block;\n box-sizing: border-box;\n word-break: break-all;\n /* \u4E3A\u4E86\u8DDF\u8F93\u5165\u6548\u679C\u4FDD\u6301\u4E00\u81F4\uFF0C\u8BBE\u7F6E\u900F\u660E\u8FB9\u6846\u5360\u4F4D */\n border: 1px solid transparent;\n}\n.lf-node-text-auto-wrap {\n display: flex;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n /* border: 1px solid transparent; */\n}\n.lf-node-text-auto-wrap-content {\n width: 100%;\n line-height: 1.2;\n text-align: center;\n word-break: break-all;\n background: transparent;\n}\n.lf-node-text-ellipsis-content {\n width: 100%;\n line-height: 1.2;\n white-space: nowrap;\n text-align: center;\n background: transparent;\n /* overflow: hidden;\n text-overflow: ellipsis; */\n}\n.lf-node-text-ellipsis-content > div {\n overflow: hidden;\n text-overflow: ellipsis;\n}\n/* tool-overlay */\n.lf-tool-overlay {\n position: absolute;\n inset: 0;\n z-index: 2;\n overflow: hidden;\n pointer-events: none;\n}\n.lf-tool-overlay > * {\n pointer-events: all;\n}\n/* modification-overlay */\n.modification-overlay {\n position: absolute;\n inset: 0;\n z-index: 1;\n overflow: hidden;\n pointer-events: none;\n}\n.modification-overlay > * {\n pointer-events: all;\n}\n.lf-outline,\n.lf-snapline {\n pointer-events: none;\n}\n.lf-keyboard-tips {\n float: right;\n}\n.lf-node-select-decorate {\n position: absolute;\n border: 1px dashed #343435;\n transform: translate(-50%, -50%);\n pointer-events: none;\n}\n.lf-multiple-select {\n position: absolute;\n border: 2px dashed #187dffcc;\n box-shadow: 0 0 3px 0 #187dff80;\n cursor: move;\n}\n.lf-edge-adjust-point {\n cursor: move;\n}\n.lf-rotate-control {\n cursor: grabbing;\n}\n.lf-resize-control-nw {\n cursor: nw-resize;\n}\n.lf-resize-control-n {\n cursor: n-resize;\n}\n.lf-resize-control-ne {\n cursor: ne-resize;\n}\n.lf-resize-control-e {\n cursor: e-resize;\n}\n.lf-resize-control-se {\n cursor: se-resize;\n}\n.lf-resize-control-s {\n cursor: s-resize;\n}\n.lf-resize-control-sw {\n cursor: sw-resize;\n}\n.lf-resize-control-w {\n cursor: w-resize;\n}\n";
4
+ export declare const content = ".lf-graph {\n position: relative;\n z-index: 0;\n width: 100%;\n height: 100%;\n background: #fff;\n user-select: none;\n}\n.lf-element-text {\n cursor: text;\n}\n.lf-text-disabled {\n pointer-events: none;\n}\n.lf-text-draggable {\n cursor: move;\n}\n*:focus {\n outline: none;\n}\n.lf-node-anchor {\n cursor: crosshair;\n}\n.lf-node-anchor-hover {\n visibility: hidden;\n}\n.lf-anchor:hover .lf-node-anchor-hover {\n visibility: visible;\n}\n.lf-edge.pointer-none {\n pointer-events: none;\n}\n.lf-edge-append {\n cursor: pointer;\n}\n.lf-edge-animation {\n stroke-dashoffset: 100%;\n animation: lf_animate_dash 5s linear infinite;\n}\n@keyframes lf_animate_dash {\n to {\n stroke-dashoffset: 0;\n }\n}\n/* node */\n.lf-node-not-allow {\n cursor: not-allowed;\n}\n.lf-polyline-append-ns-resize {\n cursor: ns-resize;\n}\n.lf-polyline-append-ew-resize {\n cursor: ew-resize;\n}\n.lf-dragging {\n cursor: move;\n}\n.lf-dragging .lf-element-text {\n cursor: move;\n}\n.lf-draggable {\n cursor: default;\n}\n.lf-bezier-adjust-anchor {\n cursor: pointer;\n}\n/* background */\n.lf-background,\n.lf-grid {\n position: absolute;\n inset: 0;\n z-index: -1;\n}\n.lf-background-area {\n width: 100%;\n height: 100%;\n}\n/* html-overlay */\n.lf-html-overlay {\n position: absolute;\n inset: 0;\n z-index: 1;\n overflow: hidden;\n user-select: none;\n pointer-events: none;\n}\n.lf-html-overlay__transform > * {\n pointer-events: all;\n}\n.lf-text-editable {\n pointer-events: all;\n}\n.lf-text-input {\n position: absolute;\n box-sizing: border-box;\n min-width: 100px;\n min-height: 20px;\n padding: 5px;\n line-height: 1.2;\n white-space: pre;\n text-align: center;\n background: #fff;\n border: 1px solid #edefed;\n border-radius: 3px;\n outline: none;\n transform: translate(-50%, -50%);\n resize: none;\n}\n.lf-get-text-height {\n display: inline-block;\n box-sizing: border-box;\n word-break: break-all;\n /* \u4E3A\u4E86\u8DDF\u8F93\u5165\u6548\u679C\u4FDD\u6301\u4E00\u81F4\uFF0C\u8BBE\u7F6E\u900F\u660E\u8FB9\u6846\u5360\u4F4D */\n border: 1px solid transparent;\n}\n.lf-node-text-auto-wrap {\n display: flex;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n /* border: 1px solid transparent; */\n}\n.lf-node-text-auto-wrap-content {\n width: 100%;\n line-height: 1.2;\n text-align: center;\n word-break: break-all;\n background: transparent;\n}\n.lf-node-text-ellipsis-content {\n width: 100%;\n line-height: 1.2;\n white-space: nowrap;\n text-align: center;\n background: transparent;\n /* overflow: hidden;\n text-overflow: ellipsis; */\n}\n.lf-node-text-ellipsis-content > div {\n overflow: hidden;\n text-overflow: ellipsis;\n}\n/* tool-overlay */\n.lf-tool-overlay {\n position: absolute;\n inset: 0;\n z-index: 2;\n overflow: hidden;\n pointer-events: none;\n}\n.lf-tool-overlay > * {\n pointer-events: all;\n}\n/* modification-overlay */\n.modification-overlay {\n position: absolute;\n inset: 0;\n z-index: 1;\n overflow: hidden;\n pointer-events: none;\n}\n.modification-overlay > * {\n pointer-events: all;\n}\n.lf-outline,\n.lf-snapline {\n pointer-events: none;\n}\n.lf-keyboard-tips {\n float: right;\n}\n.lf-node-select-decorate {\n position: absolute;\n border: 1px dashed #343435;\n transform: translate(-50%, -50%);\n pointer-events: none;\n}\n.lf-multiple-select {\n position: absolute;\n border: 2px dashed #4271dfcc;\n border-radius: 12px;\n box-shadow: 0 0 3px 0 #4271df80;\n cursor: move;\n}\n.lf-edge-adjust-point {\n cursor: move;\n}\n.lf-rotate-control {\n cursor: grabbing;\n}\n.lf-resize-control-nw {\n cursor: nw-resize;\n}\n.lf-resize-control-n {\n cursor: n-resize;\n}\n.lf-resize-control-ne {\n cursor: ne-resize;\n}\n.lf-resize-control-e {\n cursor: e-resize;\n}\n.lf-resize-control-se {\n cursor: se-resize;\n}\n.lf-resize-control-s {\n cursor: s-resize;\n}\n.lf-resize-control-sw {\n cursor: sw-resize;\n}\n.lf-resize-control-w {\n cursor: w-resize;\n}\n";
package/es/style/raw.js CHANGED
@@ -2,4 +2,4 @@
2
2
  /**
3
3
  * Auto generated file, do not modify it!
4
4
  */
5
- export var content = ".lf-graph {\n position: relative;\n z-index: 0;\n width: 100%;\n height: 100%;\n background: #fff;\n user-select: none;\n}\n.lf-element-text {\n cursor: text;\n}\n.lf-text-disabled {\n pointer-events: none;\n}\n.lf-text-draggable {\n cursor: move;\n}\n*:focus {\n outline: none;\n}\n.lf-node-anchor {\n cursor: crosshair;\n}\n.lf-node-anchor-hover {\n visibility: hidden;\n}\n.lf-anchor:hover .lf-node-anchor-hover {\n visibility: visible;\n}\n.lf-edge.pointer-none {\n pointer-events: none;\n}\n.lf-edge-append {\n cursor: pointer;\n}\n.lf-edge-animation {\n stroke-dashoffset: 100%;\n animation: lf_animate_dash 5s linear infinite;\n}\n@keyframes lf_animate_dash {\n to {\n stroke-dashoffset: 0;\n }\n}\n/* node */\n.lf-node-not-allow {\n cursor: not-allowed;\n}\n.lf-polyline-append-ns-resize {\n cursor: ns-resize;\n}\n.lf-polyline-append-ew-resize {\n cursor: ew-resize;\n}\n.lf-dragging {\n cursor: move;\n}\n.lf-dragging .lf-element-text {\n cursor: move;\n}\n.lf-draggable {\n cursor: default;\n}\n.lf-bezier-adjust-anchor {\n cursor: pointer;\n}\n/* background */\n.lf-background,\n.lf-grid {\n position: absolute;\n inset: 0;\n z-index: -1;\n}\n.lf-background-area {\n width: 100%;\n height: 100%;\n}\n/* html-overlay */\n.lf-html-overlay {\n position: absolute;\n inset: 0;\n z-index: 1;\n overflow: hidden;\n user-select: none;\n pointer-events: none;\n}\n.lf-html-overlay__transform > * {\n pointer-events: all;\n}\n.lf-text-editable {\n pointer-events: all;\n}\n.lf-text-input {\n position: absolute;\n box-sizing: border-box;\n min-width: 100px;\n min-height: 20px;\n padding: 5px;\n line-height: 1.2;\n white-space: pre;\n text-align: center;\n background: #fff;\n border: 1px solid #edefed;\n border-radius: 3px;\n outline: none;\n transform: translate(-50%, -50%);\n resize: none;\n}\n.lf-get-text-height {\n display: inline-block;\n box-sizing: border-box;\n word-break: break-all;\n /* \u4E3A\u4E86\u8DDF\u8F93\u5165\u6548\u679C\u4FDD\u6301\u4E00\u81F4\uFF0C\u8BBE\u7F6E\u900F\u660E\u8FB9\u6846\u5360\u4F4D */\n border: 1px solid transparent;\n}\n.lf-node-text-auto-wrap {\n display: flex;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n /* border: 1px solid transparent; */\n}\n.lf-node-text-auto-wrap-content {\n width: 100%;\n line-height: 1.2;\n text-align: center;\n word-break: break-all;\n background: transparent;\n}\n.lf-node-text-ellipsis-content {\n width: 100%;\n line-height: 1.2;\n white-space: nowrap;\n text-align: center;\n background: transparent;\n /* overflow: hidden;\n text-overflow: ellipsis; */\n}\n.lf-node-text-ellipsis-content > div {\n overflow: hidden;\n text-overflow: ellipsis;\n}\n/* tool-overlay */\n.lf-tool-overlay {\n position: absolute;\n inset: 0;\n z-index: 2;\n overflow: hidden;\n pointer-events: none;\n}\n.lf-tool-overlay > * {\n pointer-events: all;\n}\n/* modification-overlay */\n.modification-overlay {\n position: absolute;\n inset: 0;\n z-index: 1;\n overflow: hidden;\n pointer-events: none;\n}\n.modification-overlay > * {\n pointer-events: all;\n}\n.lf-outline,\n.lf-snapline {\n pointer-events: none;\n}\n.lf-keyboard-tips {\n float: right;\n}\n.lf-node-select-decorate {\n position: absolute;\n border: 1px dashed #343435;\n transform: translate(-50%, -50%);\n pointer-events: none;\n}\n.lf-multiple-select {\n position: absolute;\n border: 2px dashed #187dffcc;\n box-shadow: 0 0 3px 0 #187dff80;\n cursor: move;\n}\n.lf-edge-adjust-point {\n cursor: move;\n}\n.lf-rotate-control {\n cursor: grabbing;\n}\n.lf-resize-control-nw {\n cursor: nw-resize;\n}\n.lf-resize-control-n {\n cursor: n-resize;\n}\n.lf-resize-control-ne {\n cursor: ne-resize;\n}\n.lf-resize-control-e {\n cursor: e-resize;\n}\n.lf-resize-control-se {\n cursor: se-resize;\n}\n.lf-resize-control-s {\n cursor: s-resize;\n}\n.lf-resize-control-sw {\n cursor: sw-resize;\n}\n.lf-resize-control-w {\n cursor: w-resize;\n}\n";
5
+ export var content = ".lf-graph {\n position: relative;\n z-index: 0;\n width: 100%;\n height: 100%;\n background: #fff;\n user-select: none;\n}\n.lf-element-text {\n cursor: text;\n}\n.lf-text-disabled {\n pointer-events: none;\n}\n.lf-text-draggable {\n cursor: move;\n}\n*:focus {\n outline: none;\n}\n.lf-node-anchor {\n cursor: crosshair;\n}\n.lf-node-anchor-hover {\n visibility: hidden;\n}\n.lf-anchor:hover .lf-node-anchor-hover {\n visibility: visible;\n}\n.lf-edge.pointer-none {\n pointer-events: none;\n}\n.lf-edge-append {\n cursor: pointer;\n}\n.lf-edge-animation {\n stroke-dashoffset: 100%;\n animation: lf_animate_dash 5s linear infinite;\n}\n@keyframes lf_animate_dash {\n to {\n stroke-dashoffset: 0;\n }\n}\n/* node */\n.lf-node-not-allow {\n cursor: not-allowed;\n}\n.lf-polyline-append-ns-resize {\n cursor: ns-resize;\n}\n.lf-polyline-append-ew-resize {\n cursor: ew-resize;\n}\n.lf-dragging {\n cursor: move;\n}\n.lf-dragging .lf-element-text {\n cursor: move;\n}\n.lf-draggable {\n cursor: default;\n}\n.lf-bezier-adjust-anchor {\n cursor: pointer;\n}\n/* background */\n.lf-background,\n.lf-grid {\n position: absolute;\n inset: 0;\n z-index: -1;\n}\n.lf-background-area {\n width: 100%;\n height: 100%;\n}\n/* html-overlay */\n.lf-html-overlay {\n position: absolute;\n inset: 0;\n z-index: 1;\n overflow: hidden;\n user-select: none;\n pointer-events: none;\n}\n.lf-html-overlay__transform > * {\n pointer-events: all;\n}\n.lf-text-editable {\n pointer-events: all;\n}\n.lf-text-input {\n position: absolute;\n box-sizing: border-box;\n min-width: 100px;\n min-height: 20px;\n padding: 5px;\n line-height: 1.2;\n white-space: pre;\n text-align: center;\n background: #fff;\n border: 1px solid #edefed;\n border-radius: 3px;\n outline: none;\n transform: translate(-50%, -50%);\n resize: none;\n}\n.lf-get-text-height {\n display: inline-block;\n box-sizing: border-box;\n word-break: break-all;\n /* \u4E3A\u4E86\u8DDF\u8F93\u5165\u6548\u679C\u4FDD\u6301\u4E00\u81F4\uFF0C\u8BBE\u7F6E\u900F\u660E\u8FB9\u6846\u5360\u4F4D */\n border: 1px solid transparent;\n}\n.lf-node-text-auto-wrap {\n display: flex;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n /* border: 1px solid transparent; */\n}\n.lf-node-text-auto-wrap-content {\n width: 100%;\n line-height: 1.2;\n text-align: center;\n word-break: break-all;\n background: transparent;\n}\n.lf-node-text-ellipsis-content {\n width: 100%;\n line-height: 1.2;\n white-space: nowrap;\n text-align: center;\n background: transparent;\n /* overflow: hidden;\n text-overflow: ellipsis; */\n}\n.lf-node-text-ellipsis-content > div {\n overflow: hidden;\n text-overflow: ellipsis;\n}\n/* tool-overlay */\n.lf-tool-overlay {\n position: absolute;\n inset: 0;\n z-index: 2;\n overflow: hidden;\n pointer-events: none;\n}\n.lf-tool-overlay > * {\n pointer-events: all;\n}\n/* modification-overlay */\n.modification-overlay {\n position: absolute;\n inset: 0;\n z-index: 1;\n overflow: hidden;\n pointer-events: none;\n}\n.modification-overlay > * {\n pointer-events: all;\n}\n.lf-outline,\n.lf-snapline {\n pointer-events: none;\n}\n.lf-keyboard-tips {\n float: right;\n}\n.lf-node-select-decorate {\n position: absolute;\n border: 1px dashed #343435;\n transform: translate(-50%, -50%);\n pointer-events: none;\n}\n.lf-multiple-select {\n position: absolute;\n border: 2px dashed #4271dfcc;\n border-radius: 12px;\n box-shadow: 0 0 3px 0 #4271df80;\n cursor: move;\n}\n.lf-edge-adjust-point {\n cursor: move;\n}\n.lf-rotate-control {\n cursor: grabbing;\n}\n.lf-resize-control-nw {\n cursor: nw-resize;\n}\n.lf-resize-control-n {\n cursor: n-resize;\n}\n.lf-resize-control-ne {\n cursor: ne-resize;\n}\n.lf-resize-control-e {\n cursor: e-resize;\n}\n.lf-resize-control-se {\n cursor: se-resize;\n}\n.lf-resize-control-s {\n cursor: s-resize;\n}\n.lf-resize-control-sw {\n cursor: sw-resize;\n}\n.lf-resize-control-w {\n cursor: w-resize;\n}\n";
@@ -115,8 +115,9 @@ var MultipleSelect = /** @class */ (function (_super) {
115
115
  }
116
116
  MultipleSelect.prototype.render = function () {
117
117
  var _a, _b;
118
- var _c = this.props.graphModel, selectElements = _c.selectElements, transformModel = _c.transformModel;
118
+ var _c = this.props.graphModel, selectElements = _c.selectElements, transformModel = _c.transformModel, theme = _c.theme;
119
119
  var _d = this.props.lf.getTransform(), SCALE_X = _d.SCALE_X, SCALE_Y = _d.SCALE_Y;
120
+ var _e = theme.multiSelect || {}, _f = _e.xPadding, xPadding = _f === void 0 ? 8 : _f, _g = _e.yPadding, yPadding = _g === void 0 ? 8 : _g;
120
121
  if (selectElements.size <= 1)
121
122
  return;
122
123
  var x = Number.MAX_SAFE_INTEGER;
@@ -141,10 +142,10 @@ var MultipleSelect = /** @class */ (function (_super) {
141
142
  _a = __read(transformModel.CanvasPointToHtmlPoint([x, y]), 2), x = _a[0], y = _a[1];
142
143
  _b = __read(transformModel.CanvasPointToHtmlPoint([x1, y1]), 2), x1 = _b[0], y1 = _b[1];
143
144
  var style = {
144
- left: "".concat(x - (20 * SCALE_X) / 2, "px"),
145
- top: "".concat(y - (20 * SCALE_Y) / 2, "px"),
146
- width: "".concat(x1 - x + 20 * SCALE_X, "px"),
147
- height: "".concat(y1 - y + 20 * SCALE_Y, "px"),
145
+ left: "".concat(x - (20 * SCALE_X) / 2 - xPadding / 2, "px"),
146
+ top: "".concat(y - (20 * SCALE_Y) / 2 - yPadding / 2, "px"),
147
+ width: "".concat(x1 - x + 20 * SCALE_X + xPadding, "px"),
148
+ height: "".concat(y1 - y + 20 * SCALE_Y + yPadding, "px"),
148
149
  'border-width': "".concat(2 * SCALE_X, "px"),
149
150
  };
150
151
  return (_jsx("div", { className: "lf-multiple-select", style: style, onPointerDown: this.handleMouseDown, onContextMenu: this.handleContextMenu, onWheel: this.handleWheelEvent }));
package/es/util/edge.d.ts CHANGED
@@ -16,7 +16,7 @@ export declare const getExpandedBBox: (bbox: BoxBounds, offset: number) => BoxBo
16
16
  export declare const pointDirection: (point: Point, bbox: BoxBounds) => Direction;
17
17
  export declare const getExpandedBBoxPoint: (expendBBox: BoxBounds, bbox: BoxBounds, point: Point) => Point;
18
18
  export declare const mergeBBox: (b1: BoxBounds, b2: BoxBounds) => BoxBounds;
19
- export declare const getBBoxOfPoints: (points?: Point[], offset?: number) => BoxBounds;
19
+ export declare const getBBoxOfPoints: (points?: Point[], offset?: number, heightOffset?: number) => BoxBounds;
20
20
  export declare const getPointsFromBBox: (bbox: BoxBounds) => [Point, Point, Point, Point];
21
21
  export declare const isPointOutsideBBox: (point: Point, bbox: BoxBounds) => boolean;
22
22
  export declare const getBBoxXCrossPoints: (bbox: BoxBounds, x: number) => [Point, Point] | [
package/es/util/edge.js CHANGED
@@ -155,7 +155,7 @@ export var mergeBBox = function (b1, b2) {
155
155
  * 1、获取起始终点相邻点(expendBboxPoint)的bbox
156
156
  * 2、polylineEdge, bezierEdge,获取outline边框,这种情况传入offset
157
157
  */
158
- export var getBBoxOfPoints = function (points, offset) {
158
+ export var getBBoxOfPoints = function (points, offset, heightOffset) {
159
159
  if (points === void 0) { points = []; }
160
160
  var xList = [];
161
161
  var yList = [];
@@ -171,7 +171,7 @@ export var getBBoxOfPoints = function (points, offset) {
171
171
  var height = maxY - minY;
172
172
  if (offset) {
173
173
  width += offset;
174
- height += offset;
174
+ height += heightOffset || offset;
175
175
  }
176
176
  return {
177
177
  centerX: (minX + maxX) / 2,
@@ -1,5 +1,6 @@
1
1
  import LogicFlow from '../LogicFlow';
2
2
  import PointTuple = LogicFlow.PointTuple;
3
+ import Point = LogicFlow.Point;
3
4
  export declare function snapToGrid(point: number, gridSize: number, snapGrid: boolean): number;
4
5
  export declare function getGridOffset(distance: number, gridSize: number): number;
5
6
  /**
@@ -9,3 +10,10 @@ export declare function getGridOffset(distance: number, gridSize: number): numbe
9
10
  * @param height
10
11
  */
11
12
  export declare function normalizePolygon(points?: PointTuple[], width?: number, height?: number): PointTuple[];
13
+ /**
14
+ * 通用圆角生成:为菱形、多边形、折线在转折处生成与矩形视觉一致的圆角
15
+ * - 圆角基于角平分线,切点距顶点的距离 t = r * tan(theta/2)
16
+ * - 半径会根据相邻边长度进行钳制,避免超过边长造成断裂
17
+ * - 多边形/菱形保持闭合;折线保持开口
18
+ */
19
+ export declare const generateRoundedCorners: (points: Point[], radius: number, isClosedShape: boolean) => Point[];
@@ -72,3 +72,82 @@ export function normalizePolygon(points, width, height) {
72
72
  return [x * scaleFactor, y * scaleFactor];
73
73
  });
74
74
  }
75
+ /**
76
+ * 通用圆角生成:为菱形、多边形、折线在转折处生成与矩形视觉一致的圆角
77
+ * - 圆角基于角平分线,切点距顶点的距离 t = r * tan(theta/2)
78
+ * - 半径会根据相邻边长度进行钳制,避免超过边长造成断裂
79
+ * - 多边形/菱形保持闭合;折线保持开口
80
+ */
81
+ export var generateRoundedCorners = function (points, radius, isClosedShape) {
82
+ var n = points.length;
83
+ if (n < 2 || radius <= 0)
84
+ return points.slice();
85
+ var toVec = function (a, b) { return ({ x: b.x - a.x, y: b.y - a.y }); };
86
+ var len = function (v) { return Math.hypot(v.x, v.y); };
87
+ var norm = function (v) {
88
+ var l = len(v) || 1;
89
+ return { x: v.x / l, y: v.y / l };
90
+ };
91
+ var result = [];
92
+ // 用二次贝塞尔近似圆角,控制点取角点,避免复杂圆心计算
93
+ var makeRoundCorner = function (prev, curr, next) {
94
+ var vPrev = toVec(curr, prev);
95
+ var vNext = toVec(curr, next);
96
+ var dPrev = len(vPrev);
97
+ var dNext = len(vNext);
98
+ if (dPrev < 1e-6 || dNext < 1e-6)
99
+ return [curr];
100
+ var uPrev = norm(vPrev);
101
+ var uNext = norm(vNext);
102
+ var t = Math.min(radius, dPrev * 0.45, dNext * 0.45);
103
+ var start = { x: curr.x + uPrev.x * t, y: curr.y + uPrev.y * t };
104
+ var end = { x: curr.x + uNext.x * t, y: curr.y + uNext.y * t };
105
+ // 二次贝塞尔采样:B(s) = (1-s)^2*start + 2(1-s)s*curr + s^2*end
106
+ var steps = 10; // 3段近似,简洁且效果稳定
107
+ var pts = [start];
108
+ for (var k = 1; k < steps; k++) {
109
+ var s = k / steps;
110
+ var a = 1 - s;
111
+ pts.push({
112
+ x: a * a * start.x + 2 * a * s * curr.x + s * s * end.x,
113
+ y: a * a * start.y + 2 * a * s * curr.y + s * s * end.y,
114
+ });
115
+ }
116
+ pts.push(end);
117
+ return pts;
118
+ };
119
+ for (var i = 0; i < n; i++) {
120
+ var prevIdx = i === 0 ? (isClosedShape ? n - 1 : 0) : i - 1;
121
+ var nextIdx = i === n - 1 ? (isClosedShape ? 0 : n - 1) : i + 1;
122
+ var prev = points[prevIdx];
123
+ var curr = points[i];
124
+ var next = points[nextIdx];
125
+ var isEndpoint = !isClosedShape && (i === 0 || i === n - 1);
126
+ if (isEndpoint) {
127
+ // 折线两端不处理圆角
128
+ result.push(curr);
129
+ }
130
+ else {
131
+ var arc = makeRoundCorner(prev, curr, next);
132
+ arc.forEach(function (p) { return result.push(p); });
133
+ }
134
+ }
135
+ // 去重处理:避免连续重复点
136
+ var dedup = [];
137
+ for (var i = 0; i < result.length; i++) {
138
+ var p = result[i];
139
+ if (dedup.length === 0 ||
140
+ Math.hypot(p.x - dedup[dedup.length - 1].x, p.y - dedup[dedup.length - 1].y) > 1e-6) {
141
+ dedup.push(p);
142
+ }
143
+ }
144
+ // 闭合图形:确保首尾不重复闭合
145
+ if (isClosedShape && dedup.length > 1) {
146
+ var first = dedup[0];
147
+ var last = dedup[dedup.length - 1];
148
+ if (Math.hypot(first.x - last.x, first.y - last.y) < 1e-6) {
149
+ dedup.pop();
150
+ }
151
+ }
152
+ return dedup;
153
+ };
@@ -1,69 +1,6 @@
1
1
  import LogicFlow from '../LogicFlow';
2
- export declare const defaultTheme: LogicFlow.Theme;
3
- export declare const radiusMode: any;
4
- export declare const darkMode: any;
5
- export declare const colorfulMode: any;
6
- export declare const themeModeMap: {
7
- colorful: any;
8
- dark: any;
9
- radius: any;
10
- default: LogicFlow.Theme;
11
- };
12
- export declare const darkBackground: {
13
- background: string;
14
- };
15
- export declare const colorfulBackground: {
16
- background: string;
17
- };
18
- export declare const defaultBackground: {
19
- background: string;
20
- };
21
- export declare const backgroundModeMap: {
22
- colorful: {
23
- background: string;
24
- };
25
- dark: {
26
- background: string;
27
- };
28
- radius: {
29
- background: string;
30
- };
31
- default: {
32
- background: string;
33
- };
34
- };
35
- export declare const darkGrid: {
36
- color: string;
37
- thickness: number;
38
- };
39
- export declare const colorfulGrid: {
40
- color: string;
41
- thickness: number;
42
- };
43
- export declare const defaultGrid: {
44
- color: string;
45
- thickness: number;
46
- };
47
- export declare const gridModeMap: {
48
- colorful: {
49
- color: string;
50
- thickness: number;
51
- };
52
- dark: {
53
- color: string;
54
- thickness: number;
55
- };
56
- radius: {
57
- color: string;
58
- thickness: number;
59
- };
60
- default: {
61
- color: string;
62
- thickness: number;
63
- };
64
- };
65
- export declare const setupTheme: (customTheme?: Partial<LogicFlow.Theme>, themeMode?: 'radius' | 'dark' | 'colorful' | 'default' | string) => LogicFlow.Theme;
2
+ export declare const setupTheme: (customTheme?: Partial<LogicFlow.Theme>, themeMode?: LogicFlow.ThemeMode | string) => LogicFlow.Theme;
66
3
  export declare const addThemeMode: (themeMode: string, style: Partial<LogicFlow.Theme>) => void;
67
4
  export declare const removeThemeMode: (themeMode: string) => void;
68
5
  export declare const clearThemeMode: () => void;
69
- export declare const updateTheme: (customTheme?: Partial<LogicFlow.Theme>, themeMode?: 'radius' | 'dark' | 'colorful' | 'default' | string) => LogicFlow.Theme;
6
+ export declare const updateTheme: (customTheme?: Partial<LogicFlow.Theme>, themeMode?: LogicFlow.ThemeMode | string) => LogicFlow.Theme;