@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
@@ -17,7 +17,8 @@ export declare class GraphModel {
17
17
  width: number;
18
18
  height: number;
19
19
  theme: LogicFlow.Theme;
20
- customStyles: object;
20
+ themeMode: LogicFlow.ThemeMode | string;
21
+ customStyles: LogicFlow.Theme;
21
22
  grid: Grid.GridOptions;
22
23
  readonly eventCenter: EventEmitter;
23
24
  readonly modelMap: Map<string, LogicFlow.GraphElementCtor>;
@@ -404,7 +405,7 @@ export declare class GraphModel {
404
405
  * 设置主题
405
406
  * todo docs link
406
407
  */
407
- setTheme(style: Partial<LogicFlow.Theme>, themeMode?: 'radius' | 'dark' | 'colorful' | 'default' | string): void;
408
+ setTheme(style: Partial<LogicFlow.Theme>, themeMode?: LogicFlow.ThemeMode | string): void;
408
409
  /**
409
410
  * 设置主题
410
411
  * todo docs link
@@ -419,6 +420,7 @@ export declare class GraphModel {
419
420
  diamond: LogicFlow.CommonTheme;
420
421
  ellipse: LogicFlow.CommonTheme;
421
422
  polygon: LogicFlow.CommonTheme;
423
+ html: LogicFlow.CommonTheme;
422
424
  line: LogicFlow.CommonTheme;
423
425
  polyline: LogicFlow.CommonTheme;
424
426
  bezier: LogicFlow.EdgeBezierTheme;
@@ -433,8 +435,13 @@ export declare class GraphModel {
433
435
  rotateControl: LogicFlow.CommonTheme;
434
436
  resizeControl: LogicFlow.CommonTheme;
435
437
  resizeOutline: LogicFlow.CommonTheme;
438
+ multiSelect?: {
439
+ xPadding?: number | undefined;
440
+ yPadding?: number | undefined;
441
+ } | undefined;
436
442
  edgeAdjust: LogicFlow.CommonTheme;
437
443
  outline: LogicFlow.OutlineTheme;
444
+ edgeOutline: LogicFlow.OutlineTheme;
438
445
  edgeAnimation: LogicFlow.EdgeAnimation;
439
446
  };
440
447
  /**
@@ -69,6 +69,7 @@ var GraphModel = /** @class */ (function () {
69
69
  function GraphModel(options) {
70
70
  var _this = this;
71
71
  var _a, _b;
72
+ this.themeMode = 'default';
72
73
  // 维护所有节点和边类型对应的 model
73
74
  this.modelMap = new Map();
74
75
  // Remind:用于记录当前画布上所有节点和边的 model 的 Map
@@ -103,6 +104,9 @@ var GraphModel = /** @class */ (function () {
103
104
  this.partial = false;
104
105
  this.waitCleanEffects = [];
105
106
  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;
107
+ this.themeMode = options.themeMode || 'default';
108
+ var initialGrid = constant_1.gridModeMap[this.themeMode] || constant_1.gridModeMap['default'];
109
+ var initialBackground = constant_1.backgroundModeMap[this.themeMode] || constant_1.backgroundModeMap['default'];
106
110
  this.rootEl = container;
107
111
  this.partial = !!partial;
108
112
  this.background = background;
@@ -111,11 +115,14 @@ var GraphModel = /** @class */ (function () {
111
115
  // TODO:需要让用户设置成 0 吗?后面可以讨论一下
112
116
  this.gridSize = grid.size || 1; // 默认 gridSize 设置为 1
113
117
  }
114
- this.customStyles = options.style || {};
115
- this.grid = overlay_1.Grid.getGridOptions(grid !== null && grid !== void 0 ? grid : false);
118
+ this.customStyles = (options.style || {});
116
119
  this.theme = (0, util_1.setupTheme)(options.style, options.themeMode);
120
+ this.grid = overlay_1.Grid.getGridOptions((0, lodash_es_1.assign)({}, initialGrid, grid));
117
121
  this.theme.grid = (0, lodash_es_1.cloneDeep)(this.grid);
118
- this.theme.background = (0, lodash_es_1.cloneDeep)(this.background);
122
+ if (background) {
123
+ this.background = (0, lodash_es_1.cloneDeep)((0, lodash_es_1.assign)({}, initialBackground, background));
124
+ this.theme.background = (0, lodash_es_1.cloneDeep)((0, lodash_es_1.assign)({}, initialBackground, background));
125
+ }
119
126
  this.edgeType = options.edgeType || 'polyline';
120
127
  this.animation = (0, util_1.setupAnimation)(animation);
121
128
  this.overlapMode = options.overlapMode || constant_1.OverlapMode.DEFAULT;
@@ -1338,11 +1345,12 @@ var GraphModel = /** @class */ (function () {
1338
1345
  GraphModel.prototype.setTheme = function (style, themeMode) {
1339
1346
  var _a;
1340
1347
  if (themeMode) {
1348
+ this.themeMode = themeMode;
1341
1349
  // 修改背景颜色
1342
- util_1.backgroundModeMap[themeMode] &&
1343
- this.updateBackgroundOptions(__assign(__assign({}, (typeof this.background === 'object' ? this.background : {})), util_1.backgroundModeMap[themeMode]));
1344
- util_1.gridModeMap[themeMode] &&
1345
- this.updateGridOptions(overlay_1.Grid.getGridOptions(__assign(__assign({}, this.grid), util_1.gridModeMap[themeMode])));
1350
+ constant_1.backgroundModeMap[themeMode] &&
1351
+ this.updateBackgroundOptions(__assign(__assign({}, (typeof this.background === 'object' ? this.background : {})), constant_1.backgroundModeMap[themeMode]));
1352
+ constant_1.gridModeMap[themeMode] &&
1353
+ this.updateGridOptions(overlay_1.Grid.getGridOptions(__assign(__assign({}, this.grid), constant_1.gridModeMap[themeMode])));
1346
1354
  }
1347
1355
  if (style.background) {
1348
1356
  this.updateBackgroundOptions(style.background);
@@ -1535,6 +1543,9 @@ var GraphModel = /** @class */ (function () {
1535
1543
  __decorate([
1536
1544
  mobx_1.observable
1537
1545
  ], GraphModel.prototype, "theme", void 0);
1546
+ __decorate([
1547
+ mobx_1.observable
1548
+ ], GraphModel.prototype, "themeMode", void 0);
1538
1549
  __decorate([
1539
1550
  mobx_1.observable
1540
1551
  ], GraphModel.prototype, "grid", void 0);
@@ -33,15 +33,15 @@ var translateLimitsMap = {
33
33
  };
34
34
  var TransformModel = /** @class */ (function () {
35
35
  function TransformModel(eventCenter, options) {
36
- this.MINI_SCALE_SIZE = 0.2;
37
- this.MAX_SCALE_SIZE = 16;
38
- this.SCALE_X = 1;
39
- this.SKEW_Y = 0;
40
- this.SKEW_X = 0;
41
- this.SCALE_Y = 1;
42
- this.TRANSLATE_X = 0;
43
- this.TRANSLATE_Y = 0;
44
- this.ZOOM_SIZE = 0.04;
36
+ this.MINI_SCALE_SIZE = 0.2; // 缩小的最小值
37
+ this.MAX_SCALE_SIZE = 16; // 放大的最大值
38
+ this.SCALE_X = 1; // x轴缩放比例
39
+ this.SKEW_Y = 0; // y轴倾斜角度
40
+ this.SKEW_X = 0; // x轴倾斜角度
41
+ this.SCALE_Y = 1; // y轴缩放比例
42
+ this.TRANSLATE_X = 0; // x轴平移距离
43
+ this.TRANSLATE_Y = 0; // y轴平移距离
44
+ this.ZOOM_SIZE = 0.04; // 缩放比例变化量
45
45
  // 限制画布可移动区域
46
46
  this.translateLimitMinX = -Infinity;
47
47
  this.translateLimitMinY = -Infinity;
@@ -195,8 +195,13 @@ var BaseEdgeModel = /** @class */ (function () {
195
195
  */
196
196
  BaseEdgeModel.prototype.getOutlineStyle = function () {
197
197
  var graphModel = this.graphModel;
198
- var outline = graphModel.theme.outline;
199
- return (0, lodash_es_1.cloneDeep)(outline);
198
+ var edgeOutline = graphModel.theme.edgeOutline;
199
+ var attributes = __assign({}, edgeOutline);
200
+ if (this.isHovered) {
201
+ var hoverStyle = edgeOutline.hover || {};
202
+ attributes = __assign(__assign({}, attributes), hoverStyle);
203
+ }
204
+ return (0, lodash_es_1.cloneDeep)(attributes);
200
205
  };
201
206
  /**
202
207
  * 重新自定义文本位置
@@ -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;
@@ -72,12 +72,34 @@ var PolylineEdgeModel = /** @class */ (function (_super) {
72
72
  return _this;
73
73
  }
74
74
  PolylineEdgeModel.prototype.initEdgeData = function (data) {
75
- this.offset = (0, lodash_es_1.get)(data, 'properties.offset', 30);
75
+ var providedOffset = (0, lodash_es_1.get)(data, 'properties.offset');
76
+ // 当用户未传入 offset 时,按“箭头与折线重叠长度 + 5”作为默认值
77
+ // 其中“重叠长度”采用箭头样式中的 offset(沿边方向的长度)
78
+ this.offset =
79
+ typeof providedOffset === 'number'
80
+ ? providedOffset
81
+ : this.getDefaultOffset();
76
82
  if (data.pointsList) {
77
83
  this.pointsList = data.pointsList;
78
84
  }
79
85
  _super.prototype.initEdgeData.call(this, data);
80
86
  };
87
+ PolylineEdgeModel.prototype.setAttributes = function () {
88
+ var newOffset = this.properties.offset;
89
+ if (newOffset && newOffset !== this.offset) {
90
+ this.offset = newOffset;
91
+ this.updatePoints();
92
+ }
93
+ };
94
+ /**
95
+ * 计算默认 offset:箭头与折线重叠长度 + 5
96
+ * 重叠长度采用箭头样式中的 offset(沿边方向的长度)
97
+ */
98
+ PolylineEdgeModel.prototype.getDefaultOffset = function () {
99
+ var arrowStyle = this.getArrowStyle();
100
+ var arrowOverlap = typeof arrowStyle.offset === 'number' ? arrowStyle.offset : 0;
101
+ return arrowOverlap + 5;
102
+ };
81
103
  PolylineEdgeModel.prototype.getEdgeStyle = function () {
82
104
  var polyline = this.graphModel.theme.polyline;
83
105
  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
  * 获取当前节点锚点样式
@@ -382,7 +382,12 @@ var BaseNodeModel = /** @class */ (function () {
382
382
  };
383
383
  BaseNodeModel.prototype.getResizeOutlineStyle = function () {
384
384
  var resizeOutline = this.graphModel.theme.resizeOutline;
385
- return (0, lodash_es_1.cloneDeep)(resizeOutline);
385
+ var attributes = __assign({}, resizeOutline);
386
+ if (this.isHovered) {
387
+ var hoverStyle = resizeOutline.hover || {};
388
+ attributes = __assign(__assign({}, attributes), hoverStyle);
389
+ }
390
+ return (0, lodash_es_1.cloneDeep)(attributes);
386
391
  };
387
392
  /**
388
393
  * @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;
@@ -14,11 +14,23 @@ var __extends = (this && this.__extends) || (function () {
14
14
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
15
  };
16
16
  })();
17
+ var __assign = (this && this.__assign) || function () {
18
+ __assign = Object.assign || function(t) {
19
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
20
+ s = arguments[i];
21
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
+ t[p] = s[p];
23
+ }
24
+ return t;
25
+ };
26
+ return __assign.apply(this, arguments);
27
+ };
17
28
  var __importDefault = (this && this.__importDefault) || function (mod) {
18
29
  return (mod && mod.__esModule) ? mod : { "default": mod };
19
30
  };
20
31
  Object.defineProperty(exports, "__esModule", { value: true });
21
32
  exports.HtmlNodeModel = void 0;
33
+ var lodash_es_1 = require("lodash-es");
22
34
  var BaseNodeModel_1 = __importDefault(require("./BaseNodeModel"));
23
35
  var constant_1 = require("../../constant");
24
36
  var HtmlNodeModel = /** @class */ (function (_super) {
@@ -48,6 +60,13 @@ var HtmlNodeModel = /** @class */ (function (_super) {
48
60
  { x: x - width / 2, y: y, id: "".concat(this.id, "_3") },
49
61
  ];
50
62
  };
63
+ HtmlNodeModel.prototype.getNodeStyle = function () {
64
+ var style = _super.prototype.getNodeStyle.call(this);
65
+ var _a = this.graphModel.theme, baseNode = _a.baseNode, html = _a.html;
66
+ var _b = this.properties.style, customStyle = _b === void 0 ? {} : _b;
67
+ var finalStyle = __assign(__assign(__assign(__assign({}, style), (0, lodash_es_1.cloneDeep)(baseNode)), (0, lodash_es_1.cloneDeep)(html)), (0, lodash_es_1.cloneDeep)(customStyle));
68
+ return finalStyle;
69
+ };
51
70
  return HtmlNodeModel;
52
71
  }(BaseNodeModel_1.default));
53
72
  exports.HtmlNodeModel = HtmlNodeModel;
@@ -94,9 +94,9 @@ var PolygonNodeModel = /** @class */ (function (_super) {
94
94
  };
95
95
  PolygonNodeModel.prototype.getNodeStyle = function () {
96
96
  var style = _super.prototype.getNodeStyle.call(this);
97
- var polygon = this.graphModel.theme.polygon;
98
- var _a = this.properties.style, customStyle = _a === void 0 ? {} : _a;
99
- return __assign(__assign(__assign({}, style), (0, lodash_es_1.cloneDeep)(polygon)), (0, lodash_es_1.cloneDeep)(customStyle));
97
+ var _a = this.graphModel, polygon = _a.theme.polygon, customPolygon = _a.customStyles.polygon;
98
+ var _b = this.properties.style, customStyle = _b === void 0 ? {} : _b;
99
+ return __assign(__assign(__assign(__assign({}, style), (0, lodash_es_1.cloneDeep)(polygon)), (0, lodash_es_1.cloneDeep)(customPolygon)), (0, lodash_es_1.cloneDeep)(customStyle));
100
100
  };
101
101
  Object.defineProperty(PolygonNodeModel.prototype, "pointsPosition", {
102
102
  /**
package/lib/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
 
@@ -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/lib/style/raw.js CHANGED
@@ -5,4 +5,4 @@ exports.content = void 0;
5
5
  /**
6
6
  * Auto generated file, do not modify it!
7
7
  */
8
- exports.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";
8
+ exports.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";
@@ -117,8 +117,9 @@ var MultipleSelect = /** @class */ (function (_super) {
117
117
  }
118
118
  MultipleSelect.prototype.render = function () {
119
119
  var _a, _b;
120
- var _c = this.props.graphModel, selectElements = _c.selectElements, transformModel = _c.transformModel;
120
+ var _c = this.props.graphModel, selectElements = _c.selectElements, transformModel = _c.transformModel, theme = _c.theme;
121
121
  var _d = this.props.lf.getTransform(), SCALE_X = _d.SCALE_X, SCALE_Y = _d.SCALE_Y;
122
+ var _e = theme.multiSelect || {}, _f = _e.xPadding, xPadding = _f === void 0 ? 8 : _f, _g = _e.yPadding, yPadding = _g === void 0 ? 8 : _g;
122
123
  if (selectElements.size <= 1)
123
124
  return;
124
125
  var x = Number.MAX_SAFE_INTEGER;
@@ -143,10 +144,10 @@ var MultipleSelect = /** @class */ (function (_super) {
143
144
  _a = __read(transformModel.CanvasPointToHtmlPoint([x, y]), 2), x = _a[0], y = _a[1];
144
145
  _b = __read(transformModel.CanvasPointToHtmlPoint([x1, y1]), 2), x1 = _b[0], y1 = _b[1];
145
146
  var style = {
146
- left: "".concat(x - (20 * SCALE_X) / 2, "px"),
147
- top: "".concat(y - (20 * SCALE_Y) / 2, "px"),
148
- width: "".concat(x1 - x + 20 * SCALE_X, "px"),
149
- height: "".concat(y1 - y + 20 * SCALE_Y, "px"),
147
+ left: "".concat(x - (20 * SCALE_X) / 2 - xPadding / 2, "px"),
148
+ top: "".concat(y - (20 * SCALE_Y) / 2 - yPadding / 2, "px"),
149
+ width: "".concat(x1 - x + 20 * SCALE_X + xPadding, "px"),
150
+ height: "".concat(y1 - y + 20 * SCALE_Y + yPadding, "px"),
150
151
  'border-width': "".concat(2 * SCALE_X, "px"),
151
152
  };
152
153
  return ((0, jsx_runtime_1.jsx)("div", { className: "lf-multiple-select", style: style, onPointerDown: this.handleMouseDown, onContextMenu: this.handleContextMenu, onWheel: this.handleWheelEvent }));
@@ -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/lib/util/edge.js CHANGED
@@ -166,7 +166,7 @@ exports.mergeBBox = mergeBBox;
166
166
  * 1、获取起始终点相邻点(expendBboxPoint)的bbox
167
167
  * 2、polylineEdge, bezierEdge,获取outline边框,这种情况传入offset
168
168
  */
169
- var getBBoxOfPoints = function (points, offset) {
169
+ var getBBoxOfPoints = function (points, offset, heightOffset) {
170
170
  if (points === void 0) { points = []; }
171
171
  var xList = [];
172
172
  var yList = [];
@@ -182,7 +182,7 @@ var getBBoxOfPoints = function (points, offset) {
182
182
  var height = maxY - minY;
183
183
  if (offset) {
184
184
  width += offset;
185
- height += offset;
185
+ height += heightOffset || offset;
186
186
  }
187
187
  return {
188
188
  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[];
@@ -25,7 +25,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
25
25
  return to.concat(ar || Array.prototype.slice.call(from));
26
26
  };
27
27
  Object.defineProperty(exports, "__esModule", { value: true });
28
- exports.normalizePolygon = exports.getGridOffset = exports.snapToGrid = void 0;
28
+ exports.generateRoundedCorners = exports.normalizePolygon = exports.getGridOffset = exports.snapToGrid = void 0;
29
29
  function snapToGrid(point, gridSize, snapGrid) {
30
30
  // 开启节网格对齐时才根据网格尺寸校准坐标
31
31
  if (!snapGrid)
@@ -78,3 +78,83 @@ function normalizePolygon(points, width, height) {
78
78
  });
79
79
  }
80
80
  exports.normalizePolygon = normalizePolygon;
81
+ /**
82
+ * 通用圆角生成:为菱形、多边形、折线在转折处生成与矩形视觉一致的圆角
83
+ * - 圆角基于角平分线,切点距顶点的距离 t = r * tan(theta/2)
84
+ * - 半径会根据相邻边长度进行钳制,避免超过边长造成断裂
85
+ * - 多边形/菱形保持闭合;折线保持开口
86
+ */
87
+ var generateRoundedCorners = function (points, radius, isClosedShape) {
88
+ var n = points.length;
89
+ if (n < 2 || radius <= 0)
90
+ return points.slice();
91
+ var toVec = function (a, b) { return ({ x: b.x - a.x, y: b.y - a.y }); };
92
+ var len = function (v) { return Math.hypot(v.x, v.y); };
93
+ var norm = function (v) {
94
+ var l = len(v) || 1;
95
+ return { x: v.x / l, y: v.y / l };
96
+ };
97
+ var result = [];
98
+ // 用二次贝塞尔近似圆角,控制点取角点,避免复杂圆心计算
99
+ var makeRoundCorner = function (prev, curr, next) {
100
+ var vPrev = toVec(curr, prev);
101
+ var vNext = toVec(curr, next);
102
+ var dPrev = len(vPrev);
103
+ var dNext = len(vNext);
104
+ if (dPrev < 1e-6 || dNext < 1e-6)
105
+ return [curr];
106
+ var uPrev = norm(vPrev);
107
+ var uNext = norm(vNext);
108
+ var t = Math.min(radius, dPrev * 0.45, dNext * 0.45);
109
+ var start = { x: curr.x + uPrev.x * t, y: curr.y + uPrev.y * t };
110
+ var end = { x: curr.x + uNext.x * t, y: curr.y + uNext.y * t };
111
+ // 二次贝塞尔采样:B(s) = (1-s)^2*start + 2(1-s)s*curr + s^2*end
112
+ var steps = 10; // 3段近似,简洁且效果稳定
113
+ var pts = [start];
114
+ for (var k = 1; k < steps; k++) {
115
+ var s = k / steps;
116
+ var a = 1 - s;
117
+ pts.push({
118
+ x: a * a * start.x + 2 * a * s * curr.x + s * s * end.x,
119
+ y: a * a * start.y + 2 * a * s * curr.y + s * s * end.y,
120
+ });
121
+ }
122
+ pts.push(end);
123
+ return pts;
124
+ };
125
+ for (var i = 0; i < n; i++) {
126
+ var prevIdx = i === 0 ? (isClosedShape ? n - 1 : 0) : i - 1;
127
+ var nextIdx = i === n - 1 ? (isClosedShape ? 0 : n - 1) : i + 1;
128
+ var prev = points[prevIdx];
129
+ var curr = points[i];
130
+ var next = points[nextIdx];
131
+ var isEndpoint = !isClosedShape && (i === 0 || i === n - 1);
132
+ if (isEndpoint) {
133
+ // 折线两端不处理圆角
134
+ result.push(curr);
135
+ }
136
+ else {
137
+ var arc = makeRoundCorner(prev, curr, next);
138
+ arc.forEach(function (p) { return result.push(p); });
139
+ }
140
+ }
141
+ // 去重处理:避免连续重复点
142
+ var dedup = [];
143
+ for (var i = 0; i < result.length; i++) {
144
+ var p = result[i];
145
+ if (dedup.length === 0 ||
146
+ Math.hypot(p.x - dedup[dedup.length - 1].x, p.y - dedup[dedup.length - 1].y) > 1e-6) {
147
+ dedup.push(p);
148
+ }
149
+ }
150
+ // 闭合图形:确保首尾不重复闭合
151
+ if (isClosedShape && dedup.length > 1) {
152
+ var first = dedup[0];
153
+ var last = dedup[dedup.length - 1];
154
+ if (Math.hypot(first.x - last.x, first.y - last.y) < 1e-6) {
155
+ dedup.pop();
156
+ }
157
+ }
158
+ return dedup;
159
+ };
160
+ exports.generateRoundedCorners = generateRoundedCorners;
@@ -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;