@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
@@ -19,12 +19,38 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
19
19
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
20
20
  return c > 3 && r && Object.defineProperty(target, key, r), r;
21
21
  };
22
+ var __read = (this && this.__read) || function (o, n) {
23
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
24
+ if (!m) return o;
25
+ var i = m.call(o), r, ar = [], e;
26
+ try {
27
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
28
+ }
29
+ catch (error) { e = { error: error }; }
30
+ finally {
31
+ try {
32
+ if (r && !r.done && (m = i["return"])) m.call(i);
33
+ }
34
+ finally { if (e) throw e.error; }
35
+ }
36
+ return ar;
37
+ };
38
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
39
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
40
+ if (ar || !(i in from)) {
41
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
42
+ ar[i] = from[i];
43
+ }
44
+ }
45
+ return to.concat(ar || Array.prototype.slice.call(from));
46
+ };
22
47
  import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
23
48
  import { Component } from 'preact/compat';
24
- import { cloneDeep, assign } from 'lodash-es';
49
+ import { cloneDeep, assign, isNil } from 'lodash-es';
25
50
  import { observer } from '../..';
51
+ import { mergeMajorBoldConfig } from './gridConfig';
26
52
  import { createUuid } from '../../util';
27
- import { DEFAULT_GRID_SIZE } from '../../constant';
53
+ import { defaultGrid } from '../../constant';
28
54
  var Grid = /** @class */ (function (_super) {
29
55
  __extends(Grid, _super);
30
56
  function Grid(props) {
@@ -42,21 +68,64 @@ var Grid = /** @class */ (function (_super) {
42
68
  var opacity = visible ? 1 : 0;
43
69
  return (_jsxs("g", { fill: color, opacity: opacity, children: [_jsx("circle", { cx: 0, cy: 0, r: radius / 2 }), _jsx("circle", { cx: 0, cy: size, r: radius / 2 }), _jsx("circle", { cx: size, cy: 0, r: radius / 2 }), _jsx("circle", { cx: size, cy: size, r: radius / 2 })] }));
44
70
  };
71
+ // 计算与 size 整除的虚线周期,使边长能被 (dash + gap) 完整分割
72
+ Grid.prototype.getDashArrayForSize = function (dashCfg) {
73
+ var _a;
74
+ // 若提供了直接可用的 pattern,则优先使用
75
+ var direct = (_a = dashCfg === null || dashCfg === void 0 ? void 0 : dashCfg.pattern) === null || _a === void 0 ? void 0 : _a.filter(function (n) { return typeof n === 'number' && n > 0; });
76
+ return (direct === null || direct === void 0 ? void 0 : direct.join(',')) || '2,1';
77
+ };
78
+ // 计算一个周期内的最大加粗索引(作为周期大小)
79
+ Grid.prototype.getPeriod = function (advanced) {
80
+ var list = Array.isArray(advanced === null || advanced === void 0 ? void 0 : advanced.boldIndices)
81
+ ? advanced.boldIndices.filter(function (n) { return typeof n === 'number' && n > 0; })
82
+ : [];
83
+ return list.length ? Math.max.apply(Math, __spreadArray([], __read(list), false)) : 0;
84
+ };
85
+ // 计算加粗线宽,优先使用自定义;否则根据周期与厚度估算
86
+ Grid.prototype.getBoldStrokeWidth = function (advanced, size, thickness, period) {
87
+ if (typeof (advanced === null || advanced === void 0 ? void 0 : advanced.customBoldWidth) === 'number')
88
+ return advanced.customBoldWidth;
89
+ var baseThickness = Math.max(1, thickness !== null && thickness !== void 0 ? thickness : 1);
90
+ var p = Math.max(1, period !== null && period !== void 0 ? period : this.getPeriod(advanced));
91
+ return Math.min(baseThickness, (size * p) / 2) / 2;
92
+ };
93
+ // 渲染 mesh 类型四条边的虚线,减少重复代码
94
+ Grid.prototype.renderMeshEdgeLines = function (size, color, strokeWidth, opacity, dash) {
95
+ var segments = [
96
+ { d: "M 0 0 H ".concat(size) },
97
+ { d: "M 0 ".concat(size, " H ").concat(size) },
98
+ { d: "M 0 0 V ".concat(size) },
99
+ { d: "M ".concat(size, " 0 V ").concat(size) },
100
+ ];
101
+ return (_jsx("g", { opacity: opacity, fill: "transparent", children: segments.map(function (seg) { return (_jsx("path", { d: seg.d, stroke: color, strokeWidth: strokeWidth / 2, strokeDasharray: dash, strokeLinecap: "butt", fill: "transparent" })); }) }));
102
+ };
45
103
  // 网格类型为交叉线
46
104
  // todo: 采用背景缩放的方式,实现更好的体验
47
105
  Grid.prototype.renderMesh = function () {
48
- var _a = this.gridOptions, config = _a.config, _b = _a.size, size = _b === void 0 ? 1 : _b, visible = _a.visible;
49
- var _c = config !== null && config !== void 0 ? config : {}, color = _c.color, _d = _c.thickness, thickness = _d === void 0 ? 1 : _d;
106
+ var _a, _b;
107
+ var _c = this.gridOptions, config = _c.config, _d = _c.size, size = _d === void 0 ? 1 : _d, visible = _c.visible, majorBold = _c.majorBold;
108
+ var advanced = mergeMajorBoldConfig(majorBold).config;
109
+ var baseOpacity = advanced.opacity;
110
+ var color = ((_a = config === null || config === void 0 ? void 0 : config.color) !== null && _a !== void 0 ? _a : '#D7DEEB');
111
+ var thickness = ((_b = config === null || config === void 0 ? void 0 : config.thickness) !== null && _b !== void 0 ? _b : 1);
50
112
  // 对于交叉线网格,线的宽度不能大于网格大小的一半
51
113
  var strokeWidth = Math.min(Math.max(1, thickness), size / 2);
52
- var d = "M 0 0 H ".concat(size, " V ").concat(size, " H 0 Z");
53
- var opacity = visible ? 1 : 0;
54
- return (_jsx("path", { d: d, stroke: color, strokeWidth: strokeWidth / 2, opacity: opacity, fill: "transparent" }));
114
+ var opacity = visible ? baseOpacity : 0;
115
+ // 根据 size 自动计算合适的 dash/gap 周期,使 size 能被 (dash + gap) 整除
116
+ var dash = majorBold === false
117
+ ? undefined
118
+ : this.getDashArrayForSize(advanced.dashArrayConfig);
119
+ return this.renderMeshEdgeLines(size, color, strokeWidth, opacity, dash);
55
120
  };
56
121
  Grid.prototype.render = function () {
57
- var _a = this.props.graphModel, transformModel = _a.transformModel, grid = _a.grid;
122
+ var _this = this;
123
+ var _a, _b, _c;
124
+ var _d = this.props.graphModel, transformModel = _d.transformModel, grid = _d.grid;
58
125
  this.gridOptions = grid;
59
- var _b = this.gridOptions, type = _b.type, _c = _b.size, size = _c === void 0 ? 1 : _c;
126
+ var _e = this.gridOptions, type = _e.type, _f = _e.config, config = _f === void 0 ? {} : _f, _g = _e.size, size = _g === void 0 ? 1 : _g, majorBold = _e.majorBold;
127
+ var showMajorBold = majorBold !== false && !isNil(majorBold);
128
+ var advanced = mergeMajorBoldConfig(majorBold).config;
60
129
  var SCALE_X = transformModel.SCALE_X, SKEW_Y = transformModel.SKEW_Y, SKEW_X = transformModel.SKEW_X, SCALE_Y = transformModel.SCALE_Y, TRANSLATE_X = transformModel.TRANSLATE_X, TRANSLATE_Y = transformModel.TRANSLATE_Y;
61
130
  var matrixString = [
62
131
  SCALE_X,
@@ -67,10 +136,12 @@ var Grid = /** @class */ (function (_super) {
67
136
  TRANSLATE_Y,
68
137
  ].join(',');
69
138
  var transform = "matrix(".concat(matrixString, ")");
70
- // const transitionStyle = {
71
- // transition: 'all 0.1s ease',
72
- // };
73
- return (_jsx("div", { className: "lf-grid", children: _jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", version: "1.1", width: "100%", height: "100%", children: [_jsx("defs", { children: _jsxs("pattern", { id: this.id, patternUnits: "userSpaceOnUse", patternTransform: transform, x: "0", y: "0", width: size, height: size, children: [type === 'dot' && this.renderDot(), type === 'mesh' && this.renderMesh()] }) }), _jsx("rect", { width: "100%", height: "100%", fill: "url(#".concat(this.id, ")") })] }) }));
139
+ var radius = Math.min(Math.max(2, (_a = config.thickness) !== null && _a !== void 0 ? _a : 1), size / 4);
140
+ var opacity = showMajorBold ? advanced.opacity : 1;
141
+ return (_jsx("div", { className: "lf-grid", children: _jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", version: "1.1", width: "100%", height: "100%", children: [_jsxs("defs", { children: [_jsxs("pattern", { id: this.id, patternUnits: "userSpaceOnUse", patternTransform: transform, x: "0", y: "0", width: size, height: size, children: [type === 'dot' && this.renderDot(), type === 'mesh' && this.renderMesh()] }), type === 'dot' && advanced.boldIndices.length ? (_jsx("pattern", { id: "".concat(this.id, "-dot-major"), patternUnits: "userSpaceOnUse", patternTransform: transform, x: "0", y: "0", width: size * this.getPeriod(advanced), height: size * this.getPeriod(advanced), children: _jsxs("g", { fill: (_c = (_b = this.gridOptions.config) === null || _b === void 0 ? void 0 : _b.color) !== null && _c !== void 0 ? _c : '#D7DEEB', opacity: this.gridOptions.visible ? opacity : 0, children: [_jsx("circle", { cx: 0, cy: 0, r: (radius * 1.5) / 2 }), _jsx("circle", { cx: size * this.getPeriod(advanced), cy: 0, r: (radius * 1.5) / 2 }), _jsx("circle", { cx: 0, cy: size * this.getPeriod(advanced), r: (radius * 1.5) / 2 }), _jsx("circle", { cx: size * this.getPeriod(advanced), cy: size * this.getPeriod(advanced), r: (radius * 1.5) / 2 })] }) })) : null, type === 'mesh' && advanced.boldIndices.length ? (_jsx("pattern", { id: "".concat(this.id, "-major"), patternUnits: "userSpaceOnUse", patternTransform: transform, x: "0", y: "0", width: size * this.getPeriod(advanced), height: size * this.getPeriod(advanced), children: advanced.boldIndices.map(function (i) {
142
+ var _a, _b, _c, _d, _e, _f;
143
+ return (_jsxs("g", { children: [_jsx("path", { d: "M ".concat(size * i, " 0 V ").concat(size * _this.getPeriod(advanced)), stroke: (_b = (_a = _this.gridOptions.config) === null || _a === void 0 ? void 0 : _a.color) !== null && _b !== void 0 ? _b : '#D7DEEB', strokeWidth: _this.getBoldStrokeWidth(advanced, size, ((_c = _this.gridOptions.config) !== null && _c !== void 0 ? _c : {}).thickness, _this.getPeriod(advanced)), opacity: _this.gridOptions.visible ? opacity : 0, fill: "transparent" }), _jsx("path", { d: "M 0 ".concat(size * i, " H ").concat(size * _this.getPeriod(advanced)), stroke: (_e = (_d = _this.gridOptions.config) === null || _d === void 0 ? void 0 : _d.color) !== null && _e !== void 0 ? _e : '#D7DEEB', strokeWidth: _this.getBoldStrokeWidth(advanced, size, ((_f = _this.gridOptions.config) !== null && _f !== void 0 ? _f : {}).thickness, _this.getPeriod(advanced)), opacity: _this.gridOptions.visible ? opacity : 0, fill: "transparent" })] }));
144
+ }) })) : null] }), _jsx("rect", { width: "100%", height: "100%", fill: "url(#".concat(this.id, ")") }), type === 'dot' && showMajorBold && advanced.boldIndices.length ? (_jsx("rect", { width: "100%", height: "100%", fill: "url(#".concat(this.id, "-dot-major)") })) : null, type === 'mesh' && showMajorBold && advanced.boldIndices.length ? (_jsx("rect", { width: "100%", height: "100%", fill: "url(#".concat(this.id, "-major)") })) : null] }) }));
74
145
  };
75
146
  Grid = __decorate([
76
147
  observer
@@ -79,17 +150,8 @@ var Grid = /** @class */ (function (_super) {
79
150
  }(Component));
80
151
  export { Grid };
81
152
  (function (Grid) {
82
- Grid.defaultProps = {
83
- size: DEFAULT_GRID_SIZE,
84
- visible: true,
85
- type: 'dot',
86
- config: {
87
- color: '#ababab',
88
- thickness: 1,
89
- },
90
- };
91
153
  function getGridOptions(options) {
92
- var defaultOptions = cloneDeep(Grid.defaultProps);
154
+ var defaultOptions = cloneDeep(defaultGrid);
93
155
  if (typeof options === 'number') {
94
156
  return assign(defaultOptions, { size: options });
95
157
  }
@@ -4,6 +4,7 @@ type IProps = {
4
4
  graphModel: GraphModel;
5
5
  };
6
6
  export declare class OutlineOverlay extends Component<IProps> {
7
+ private renderRectOutline;
7
8
  getNodesOutline(): any;
8
9
  getEdgeOutline(): any;
9
10
  getLineOutline(line: LineEdgeModel): import("preact/compat").JSX.Element;
@@ -41,6 +41,12 @@ var OutlineOverlay = /** @class */ (function (_super) {
41
41
  function OutlineOverlay() {
42
42
  return _super !== null && _super.apply(this, arguments) || this;
43
43
  }
44
+ // 通用渲染函数:根据点集合与样式计算包围盒并返回矩形轮廓
45
+ OutlineOverlay.prototype.renderRectOutline = function (pointsList, style, className, defaultOffsets) {
46
+ var _a = (style || {}), _b = _a.widthOffset, widthOffset = _b === void 0 ? defaultOffsets.widthOffset : _b, _c = _a.heightOffset, heightOffset = _c === void 0 ? defaultOffsets.heightOffset : _c;
47
+ var _d = getBBoxOfPoints(pointsList, widthOffset, heightOffset), x = _d.x, y = _d.y, width = _d.width, height = _d.height;
48
+ return (_jsx(Rect, __assign({ className: className, x: x, y: y, width: width, height: height }, style)));
49
+ };
44
50
  // 节点outline
45
51
  OutlineOverlay.prototype.getNodesOutline = function () {
46
52
  var graphModel = this.props.graphModel;
@@ -62,11 +68,8 @@ var OutlineOverlay = /** @class */ (function (_super) {
62
68
  var hoverStyle = style_1.hover;
63
69
  attributes_1 = __assign(__assign({}, attributes_1), hoverStyle);
64
70
  }
65
- nodeOutline.push(_jsx(Rect, __assign({ transform: element.transform, className: "lf-outline-node", x: x, y: y,
66
- // width: width + 10,
67
- // height: height + 10,
68
- width: width + 10,
69
- height: height + 10 }, attributes_1)));
71
+ nodeOutline.push(_jsx(Rect, __assign({ transform: element.transform, className: "lf-outline-node", x: x, y: y, width: width + 4,
72
+ height: height + 4 }, attributes_1)));
70
73
  }
71
74
  }
72
75
  });
@@ -96,30 +99,28 @@ var OutlineOverlay = /** @class */ (function (_super) {
96
99
  // 直线outline
97
100
  OutlineOverlay.prototype.getLineOutline = function (line) {
98
101
  var startPoint = line.startPoint, endPoint = line.endPoint;
99
- var x = (startPoint.x + endPoint.x) / 2;
100
- var y = (startPoint.y + endPoint.y) / 2;
101
- var width = Math.abs(startPoint.x - endPoint.x) + 10;
102
- var height = Math.abs(startPoint.y - endPoint.y) + 10;
103
102
  var style = line.getOutlineStyle();
104
- return (_jsx(Rect, __assign({ className: "lf-outline-edge", x: x, y: y, width: width, height: height }, style)));
103
+ return this.renderRectOutline([startPoint, endPoint], style, 'lf-outline-edge', { widthOffset: 10, heightOffset: 10 });
105
104
  };
106
105
  // 折线outline
107
106
  OutlineOverlay.prototype.getPolylineOutline = function (polyline) {
108
107
  var points = polyline.points;
109
108
  var pointsList = points2PointsList(points);
110
- var bbox = getBBoxOfPoints(pointsList, 8);
111
- var x = bbox.x, y = bbox.y, width = bbox.width, height = bbox.height;
112
109
  var style = polyline.getOutlineStyle();
113
- return (_jsx(Rect, __assign({ className: "lf-outline", x: x, y: y, width: width, height: height }, style)));
110
+ return this.renderRectOutline(pointsList, style, 'lf-outline', {
111
+ widthOffset: 8,
112
+ heightOffset: 16,
113
+ });
114
114
  };
115
115
  // 曲线outline
116
116
  OutlineOverlay.prototype.getBezierOutline = function (bezier) {
117
117
  var path = bezier.path;
118
118
  var pointsList = getBezierPoints(path);
119
- var bbox = getBBoxOfPoints(pointsList, 8);
120
- var x = bbox.x, y = bbox.y, width = bbox.width, height = bbox.height;
121
119
  var style = bezier.getOutlineStyle();
122
- return (_jsx(Rect, __assign({ className: "lf-outline", x: x, y: y, width: width, height: height }, style)));
120
+ return this.renderRectOutline(pointsList, style, 'lf-outline', {
121
+ widthOffset: 8,
122
+ heightOffset: 16,
123
+ });
123
124
  };
124
125
  OutlineOverlay.prototype.render = function () {
125
126
  return (_jsxs("g", { className: "lf-outline", children: [this.getNodesOutline(), this.getEdgeOutline()] }));
@@ -0,0 +1,46 @@
1
+ /**
2
+ * 网格高级 majorBold 配置。
3
+ *
4
+ * 示例(布尔值):
5
+ * - false:禁用特殊样式,opacity=1,无加粗,无虚线
6
+ * - true:启用默认值,opacity=0.75,每第 5 条线/点加粗/实线,
7
+ * 虚线图案通过 getDashArrayForSize(size) 计算
8
+ *
9
+ * 示例(对象):
10
+ * {
11
+ * opacity: 0.6,
12
+ * boldIndices: [4, 8],
13
+ * dashArrayConfig: { pattern: [4,2,4] },
14
+ * customBoldWidth: 2,
15
+ * }
16
+ */
17
+ export type MajorBoldConfig = {
18
+ /** 默认网格透明度 (0-1) */
19
+ opacity: number;
20
+ /** 一个周期内需要加粗/实线的索引列表 */
21
+ boldIndices: number[];
22
+ /** 虚线样式的计算配置 */
23
+ dashArrayConfig: {
24
+ /** 固定的虚线模式(可选) */
25
+ pattern: number[];
26
+ };
27
+ /** mesh 网格的自定义加粗线宽(可选) */
28
+ customBoldWidth?: number;
29
+ };
30
+ export declare const defaultGridConfig: MajorBoldConfig;
31
+ /**
32
+ * 校验并规范化 GridConfig。
33
+ * - 将 opacity 限制在 [0,1] 范围
34
+ * - boldIndices 过滤为正整数并去重
35
+ */
36
+ export declare function validateGridConfig(cfg: MajorBoldConfig): MajorBoldConfig;
37
+ /**
38
+ * 合并用户行为配置与默认值。
39
+ * - false → 关闭模式:opacity=1,bold=[],关闭虚线
40
+ * - true → 默认模式:采用 defaultGridConfig
41
+ * - object → 自定义模式:校验后使用用户配置
42
+ */
43
+ export declare function mergeMajorBoldConfig(input?: boolean | MajorBoldConfig): {
44
+ mode: 'disabled' | 'default' | 'custom';
45
+ config: MajorBoldConfig;
46
+ };
@@ -0,0 +1,99 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __values = (this && this.__values) || function(o) {
13
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
14
+ if (m) return m.call(o);
15
+ if (o && typeof o.length === "number") return {
16
+ next: function () {
17
+ if (o && i >= o.length) o = void 0;
18
+ return { value: o && o[i++], done: !o };
19
+ }
20
+ };
21
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
22
+ };
23
+ export var defaultGridConfig = {
24
+ opacity: 1,
25
+ boldIndices: [5],
26
+ dashArrayConfig: {
27
+ pattern: [2, 1],
28
+ },
29
+ customBoldWidth: 2,
30
+ };
31
+ /**
32
+ * 校验并规范化 GridConfig。
33
+ * - 将 opacity 限制在 [0,1] 范围
34
+ * - boldIndices 过滤为正整数并去重
35
+ */
36
+ export function validateGridConfig(cfg) {
37
+ var e_1, _a;
38
+ var _b, _c;
39
+ var opacity = Math.max(0, Math.min(1, (_b = cfg.opacity) !== null && _b !== void 0 ? _b : defaultGridConfig.opacity));
40
+ var boldIndicesSet = new Set();
41
+ var boldRaw = Array.isArray(cfg.boldIndices)
42
+ ? cfg.boldIndices
43
+ : defaultGridConfig.boldIndices;
44
+ try {
45
+ for (var boldRaw_1 = __values(boldRaw), boldRaw_1_1 = boldRaw_1.next(); !boldRaw_1_1.done; boldRaw_1_1 = boldRaw_1.next()) {
46
+ var n = boldRaw_1_1.value;
47
+ if (typeof n === 'number' && Number.isFinite(n) && n > 0) {
48
+ boldIndicesSet.add(Math.floor(n));
49
+ }
50
+ }
51
+ }
52
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
53
+ finally {
54
+ try {
55
+ if (boldRaw_1_1 && !boldRaw_1_1.done && (_a = boldRaw_1.return)) _a.call(boldRaw_1);
56
+ }
57
+ finally { if (e_1) throw e_1.error; }
58
+ }
59
+ var boldIndices = Array.from(boldIndicesSet);
60
+ var pattern = Array.isArray((_c = cfg.dashArrayConfig) === null || _c === void 0 ? void 0 : _c.pattern)
61
+ ? cfg.dashArrayConfig.pattern
62
+ : defaultGridConfig.dashArrayConfig.pattern;
63
+ var dashArrayConfig = {
64
+ pattern: pattern,
65
+ };
66
+ var customBoldWidth = cfg.customBoldWidth;
67
+ return {
68
+ opacity: opacity,
69
+ boldIndices: boldIndices.length
70
+ ? boldIndices
71
+ : defaultGridConfig.boldIndices,
72
+ dashArrayConfig: dashArrayConfig,
73
+ customBoldWidth: customBoldWidth,
74
+ };
75
+ }
76
+ /**
77
+ * 合并用户行为配置与默认值。
78
+ * - false → 关闭模式:opacity=1,bold=[],关闭虚线
79
+ * - true → 默认模式:采用 defaultGridConfig
80
+ * - object → 自定义模式:校验后使用用户配置
81
+ */
82
+ export function mergeMajorBoldConfig(input) {
83
+ if (input === false) {
84
+ return {
85
+ mode: 'disabled',
86
+ config: {
87
+ opacity: 1,
88
+ boldIndices: [],
89
+ dashArrayConfig: {
90
+ pattern: [],
91
+ },
92
+ },
93
+ };
94
+ }
95
+ if (input === true || input == null) {
96
+ return { mode: 'default', config: __assign({}, defaultGridConfig) };
97
+ }
98
+ return { mode: 'custom', config: validateGridConfig(input) };
99
+ }
@@ -7,12 +7,5 @@ export type IPolygonProps = {
7
7
  className?: string;
8
8
  radius?: number;
9
9
  };
10
- /**
11
- * 生成带圆角的多边形路径
12
- * @param points 多边形顶点坐标数组
13
- * @param radius 圆角半径
14
- * @returns SVG 路径字符串
15
- */
16
- export declare function createRoundedPolygonPath(points: any, radius: any): string;
17
10
  export declare function Polygon(props: IPolygonProps): h.JSX.Element;
18
11
  export default Polygon;
@@ -27,46 +27,7 @@ var __read = (this && this.__read) || function (o, n) {
27
27
  };
28
28
  import { jsx as _jsx } from "preact/jsx-runtime";
29
29
  import { forEach, toPairs } from 'lodash-es';
30
- /**
31
- * 生成带圆角的多边形路径
32
- * @param points 多边形顶点坐标数组
33
- * @param radius 圆角半径
34
- * @returns SVG 路径字符串
35
- */
36
- export function createRoundedPolygonPath(points, radius) {
37
- var pointList = points.map(function (point) { return ({ x: point[0], y: point[1] }); });
38
- var len = pointList.length;
39
- if (len < 3)
40
- return '';
41
- var r = Math.abs(radius);
42
- var path = '';
43
- for (var i = 0; i < len; i++) {
44
- var prev = pointList[(i - 1 + len) % len];
45
- var curr = pointList[i];
46
- var next = pointList[(i + 1) % len];
47
- // 向量
48
- var v1 = { x: curr.x - prev.x, y: curr.y - prev.y };
49
- var v2 = { x: next.x - curr.x, y: next.y - curr.y };
50
- // 单位向量
51
- var len1 = Math.hypot(v1.x, v1.y);
52
- var len2 = Math.hypot(v2.x, v2.y);
53
- var u1 = { x: v1.x / len1, y: v1.y / len1 };
54
- var u2 = { x: v2.x / len2, y: v2.y / len2 };
55
- // 起点 = curr - u1 * r,终点 = curr + u2 * r
56
- var start = { x: curr.x - u1.x * r, y: curr.y - u1.y * r };
57
- var end = { x: curr.x + u2.x * r, y: curr.y + u2.y * r };
58
- if (i === 0) {
59
- path += "M ".concat(start.x, " ").concat(start.y, " ");
60
- }
61
- else {
62
- path += "L ".concat(start.x, " ").concat(start.y, " ");
63
- }
64
- // Q 控制点是当前拐角点
65
- path += "Q ".concat(curr.x, " ").concat(curr.y, " ").concat(end.x, " ").concat(end.y, " ");
66
- }
67
- path += 'Z';
68
- return path;
69
- }
30
+ import { generateRoundedCorners } from '../../util/geometry';
70
31
  export function Polygon(props) {
71
32
  var _a = props.points, points = _a === void 0 ? [] : _a, className = props.className, radius = props.radius;
72
33
  var attrs = {
@@ -84,14 +45,22 @@ export function Polygon(props) {
84
45
  }
85
46
  });
86
47
  if (className) {
87
- attrs.classNmae = "lf-basic-shape ".concat(className);
48
+ attrs.className = "lf-basic-shape ".concat(className);
88
49
  }
89
50
  else {
90
51
  attrs.className = 'lf-basic-shape';
91
52
  }
92
53
  if (radius) {
93
- var path = createRoundedPolygonPath(points, radius);
94
- attrs.d = path;
54
+ var pointList = points.map(function (point) { return ({ x: point[0], y: point[1] }); });
55
+ var rounded = generateRoundedCorners(pointList, radius, true);
56
+ var d = rounded.length
57
+ ? "M ".concat(rounded[0].x, " ").concat(rounded[0].y, " ").concat(rounded
58
+ .slice(1)
59
+ .map(function (p) { return "L ".concat(p.x, " ").concat(p.y); })
60
+ .join(' '), " Z")
61
+ : '';
62
+ attrs.d = d;
63
+ delete attrs.points;
95
64
  return _jsx("path", __assign({}, attrs));
96
65
  }
97
66
  else {
@@ -899,6 +899,8 @@ export declare namespace LogicFlow {
899
899
  };
900
900
  type OutlineTheme = {
901
901
  hover?: CommonTheme;
902
+ widthOffset?: number;
903
+ heightOffset?: number;
902
904
  } & CommonTheme & EdgeAnimation;
903
905
  type ArrowTheme = {
904
906
  /**
@@ -933,6 +935,7 @@ export declare namespace LogicFlow {
933
935
  diamond: PolygonTheme;
934
936
  ellipse: EllipseTheme;
935
937
  polygon: PolygonTheme;
938
+ html: RectTheme;
936
939
  /**
937
940
  * 基础图形线相关主题
938
941
  */
@@ -956,6 +959,10 @@ export declare namespace LogicFlow {
956
959
  rotateControl: CommonTheme;
957
960
  resizeControl: CommonTheme;
958
961
  resizeOutline: CommonTheme;
962
+ multiSelect?: {
963
+ xPadding?: number;
964
+ yPadding?: number;
965
+ };
959
966
  /**
960
967
  * REMIND: 当开启了跳转边的起点和终点(adjustEdgeStartAndEnd:true)后
961
968
  * 边的两端会出现调整按钮
@@ -963,10 +970,12 @@ export declare namespace LogicFlow {
963
970
  */
964
971
  edgeAdjust: CircleTheme;
965
972
  outline: OutlineTheme;
973
+ edgeOutline: OutlineTheme;
966
974
  edgeAnimation: EdgeAnimation;
967
975
  background?: boolean | Partial<LFOptions.BackgroundConfig>;
968
976
  grid?: boolean | Partial<Grid.GridOptions>;
969
977
  }
978
+ type ThemeMode = 'default' | 'retro' | 'dark' | 'colorful';
970
979
  }
971
980
  export declare namespace LogicFlow {
972
981
  type FocusOnById = {
@@ -1,6 +1,5 @@
1
1
  export declare const DEFAULT_VISIBLE_SPACE = 200;
2
2
  export declare const ELEMENT_MAX_Z_INDEX = 9999;
3
- export declare const DEFAULT_GRID_SIZE = 10;
4
3
  export declare enum ElementState {
5
4
  DEFAULT = 1,// 默认显示
6
5
  TEXT_EDIT = 2,// 此元素正在进行文本编辑
@@ -147,3 +146,4 @@ export declare enum TextMode {
147
146
  TEXT = "text",
148
147
  LABEL = "label"
149
148
  }
149
+ export * from './theme';
@@ -1,9 +1,22 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TextMode = exports.SegmentDirection = exports.OverlapMode = exports.EventType = exports.ModelType = exports.ElementType = exports.ElementState = exports.DEFAULT_GRID_SIZE = exports.ELEMENT_MAX_Z_INDEX = exports.DEFAULT_VISIBLE_SPACE = void 0;
17
+ exports.TextMode = exports.SegmentDirection = exports.OverlapMode = exports.EventType = exports.ModelType = exports.ElementType = exports.ElementState = exports.ELEMENT_MAX_Z_INDEX = exports.DEFAULT_VISIBLE_SPACE = void 0;
4
18
  exports.DEFAULT_VISIBLE_SPACE = 200;
5
19
  exports.ELEMENT_MAX_Z_INDEX = 9999;
6
- exports.DEFAULT_GRID_SIZE = 10;
7
20
  var ElementState;
8
21
  (function (ElementState) {
9
22
  ElementState[ElementState["DEFAULT"] = 1] = "DEFAULT";
@@ -167,3 +180,4 @@ var TextMode;
167
180
  TextMode["TEXT"] = "text";
168
181
  TextMode["LABEL"] = "label";
169
182
  })(TextMode || (exports.TextMode = TextMode = {}));
183
+ __exportStar(require("./theme"), exports);