@logicflow/core 2.0.13 → 2.0.14
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.
- package/.turbo/turbo-build$colon$dev.log +2 -2
- package/.turbo/turbo-build.log +6 -6
- package/CHANGELOG.md +6 -0
- package/__tests__/algorithm/index.test.ts +22 -17
- package/__tests__/algorithm/outline.test.ts +9 -9
- package/__tests__/event/event.test.ts +18 -18
- package/__tests__/history/history.test.ts +23 -23
- package/__tests__/logicflow.test.ts +236 -228
- package/__tests__/model/graphmodel.test.ts +51 -31
- package/__tests__/util/compatible.test.ts +5 -5
- package/__tests__/util/geometry.test.ts +10 -10
- package/__tests__/util/graph.test.ts +12 -12
- package/__tests__/util/matrix.test.ts +26 -26
- package/__tests__/util/node.test.ts +22 -22
- package/__tests__/util/sampling.test.ts +6 -10
- package/__tests__/util/vector.test.ts +36 -36
- package/__tests__/util/zIndex.test.ts +6 -6
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/es/LogicFlow.d.ts +24 -4
- package/es/LogicFlow.js +28 -6
- package/es/model/GraphModel.d.ts +34 -1
- package/es/model/GraphModel.js +36 -5
- package/es/model/node/RectNodeModel.js +3 -0
- package/es/options.d.ts +1 -0
- package/es/util/theme.d.ts +67 -2
- package/es/util/theme.js +189 -2
- package/es/view/edge/BaseEdge.d.ts +4 -0
- package/es/view/edge/BaseEdge.js +45 -3
- package/es/view/overlay/Grid.js +3 -2
- package/es/view/shape/Polygon.d.ts +8 -0
- package/es/view/shape/Polygon.js +50 -3
- package/lib/LogicFlow.d.ts +24 -4
- package/lib/LogicFlow.js +27 -5
- package/lib/model/GraphModel.d.ts +34 -1
- package/lib/model/GraphModel.js +34 -3
- package/lib/model/node/RectNodeModel.js +3 -0
- package/lib/options.d.ts +1 -0
- package/lib/util/theme.d.ts +67 -2
- package/lib/util/theme.js +192 -2
- package/lib/view/edge/BaseEdge.d.ts +4 -0
- package/lib/view/edge/BaseEdge.js +45 -3
- package/lib/view/overlay/Grid.js +3 -2
- package/lib/view/shape/Polygon.d.ts +8 -0
- package/lib/view/shape/Polygon.js +52 -4
- package/package.json +1 -1
- package/src/LogicFlow.tsx +48 -6
- package/src/model/GraphModel.ts +48 -3
- package/src/model/edge/index.ts +4 -4
- package/src/model/index.ts +7 -7
- package/src/model/node/RectNodeModel.ts +2 -1
- package/src/model/node/index.ts +8 -8
- package/src/options.ts +1 -0
- package/src/util/theme.ts +198 -3
- package/src/view/edge/BaseEdge.tsx +96 -12
- package/src/view/overlay/Grid.tsx +2 -1
- package/src/view/shape/Polygon.tsx +56 -4
- package/stats.html +1 -1
|
@@ -5,6 +5,14 @@ export type IPolygonProps = {
|
|
|
5
5
|
x?: number;
|
|
6
6
|
y?: number;
|
|
7
7
|
className?: string;
|
|
8
|
+
radius?: number;
|
|
8
9
|
};
|
|
10
|
+
/**
|
|
11
|
+
* 生成带圆角的多边形路径
|
|
12
|
+
* @param points 多边形顶点坐标数组
|
|
13
|
+
* @param radius 圆角半径
|
|
14
|
+
* @returns SVG 路径字符串
|
|
15
|
+
*/
|
|
16
|
+
export declare function createRoundedPolygonPath(points: any, radius: any): string;
|
|
9
17
|
export declare function Polygon(props: IPolygonProps): h.JSX.Element;
|
|
10
18
|
export default Polygon;
|
package/es/view/shape/Polygon.js
CHANGED
|
@@ -27,8 +27,48 @@ 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
70
|
export function Polygon(props) {
|
|
31
|
-
var _a = props.points, points = _a === void 0 ? [] : _a, className = props.className;
|
|
71
|
+
var _a = props.points, points = _a === void 0 ? [] : _a, className = props.className, radius = props.radius;
|
|
32
72
|
var attrs = {
|
|
33
73
|
fill: 'transparent',
|
|
34
74
|
fillOpacity: 1,
|
|
@@ -49,7 +89,14 @@ export function Polygon(props) {
|
|
|
49
89
|
else {
|
|
50
90
|
attrs.className = 'lf-basic-shape';
|
|
51
91
|
}
|
|
52
|
-
|
|
53
|
-
|
|
92
|
+
if (radius) {
|
|
93
|
+
var path = createRoundedPolygonPath(points, radius);
|
|
94
|
+
attrs.d = path;
|
|
95
|
+
return _jsx("path", __assign({}, attrs));
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
attrs.points = points.map(function (point) { return point.join(','); }).join(' ');
|
|
99
|
+
return _jsx("polygon", __assign({}, attrs));
|
|
100
|
+
}
|
|
54
101
|
}
|
|
55
102
|
export default Polygon;
|
package/lib/LogicFlow.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import History from './history';
|
|
|
8
8
|
import Keyboard from './keyboard';
|
|
9
9
|
import { EventCallback, CallbackArgs, EventArgs } from './event/eventEmitter';
|
|
10
10
|
import { EventType, SegmentDirection } from './constant';
|
|
11
|
+
import { Grid } from './view/overlay';
|
|
11
12
|
import Extension = LogicFlow.Extension;
|
|
12
13
|
import ExtensionConfig = LogicFlow.ExtensionConfig;
|
|
13
14
|
import ExtensionConstructor = LogicFlow.ExtensionConstructor;
|
|
@@ -314,7 +315,7 @@ export declare class LogicFlow {
|
|
|
314
315
|
getAreaElement(leftTopPoint: PointTuple, rightBottomPoint: PointTuple, wholeEdge?: boolean, wholeNode?: boolean, ignoreHideElement?: boolean): (EdgeData | NodeData)[];
|
|
315
316
|
/**
|
|
316
317
|
* 设置元素的自定义属性
|
|
317
|
-
* @see
|
|
318
|
+
* @see http://logicflow.cn/api/detail#setproperties
|
|
318
319
|
* @param id 元素的id
|
|
319
320
|
* @param properties 自定义属性
|
|
320
321
|
*/
|
|
@@ -356,12 +357,12 @@ export declare class LogicFlow {
|
|
|
356
357
|
/**
|
|
357
358
|
* 更新流程图编辑相关设置
|
|
358
359
|
* @param {object} config 编辑配置
|
|
359
|
-
* @see
|
|
360
|
+
* @see http://logicflow.cn/api/detail#updateeditconfig
|
|
360
361
|
*/
|
|
361
362
|
updateEditConfig(config: Partial<IEditConfigType>): void;
|
|
362
363
|
/**
|
|
363
364
|
* 获取流程图当前编辑相关设置
|
|
364
|
-
* @see
|
|
365
|
+
* @see http://logicflow.cn/api/detail#geteditconfig
|
|
365
366
|
*/
|
|
366
367
|
getEditConfig(): _Model.IEditConfigType;
|
|
367
368
|
/*********************************************************
|
|
@@ -372,7 +373,12 @@ export declare class LogicFlow {
|
|
|
372
373
|
* @param { object } style 自定义主题样式
|
|
373
374
|
* todo docs link
|
|
374
375
|
*/
|
|
375
|
-
setTheme(style: Partial<LogicFlow.Theme
|
|
376
|
+
setTheme(style: Partial<LogicFlow.Theme>, themeMode?: 'radius' | 'dark' | 'colorful' | 'default' | string): void;
|
|
377
|
+
/**
|
|
378
|
+
* 获取当前主题样式
|
|
379
|
+
* @see todo docs link
|
|
380
|
+
*/
|
|
381
|
+
getTheme(): LogicFlow.Theme;
|
|
376
382
|
private focusByElement;
|
|
377
383
|
private focusByCoordinate;
|
|
378
384
|
/**
|
|
@@ -568,6 +574,14 @@ export declare class LogicFlow {
|
|
|
568
574
|
* @param props
|
|
569
575
|
*/
|
|
570
576
|
static use(extension: ExtensionConstructor | ExtensionDefinition, props?: Record<string, unknown>): void;
|
|
577
|
+
/**
|
|
578
|
+
* 添加主题模式
|
|
579
|
+
* @param themeMode 主题模式
|
|
580
|
+
* @param style 主题样式
|
|
581
|
+
*/
|
|
582
|
+
static addThemeMode(themeMode: string, style: Partial<LogicFlow.Theme>): void;
|
|
583
|
+
static removeThemeMode(themeMode: string): void;
|
|
584
|
+
static clearThemeMode(): void;
|
|
571
585
|
private installPlugins;
|
|
572
586
|
/**
|
|
573
587
|
* 加载插件-内部方法
|
|
@@ -898,6 +912,10 @@ export declare namespace LogicFlow {
|
|
|
898
912
|
refX?: number;
|
|
899
913
|
refY?: number;
|
|
900
914
|
verticalLength: number;
|
|
915
|
+
endArrowType?: 'solid' | 'hollow' | 'diamond' | 'circle' | 'none';
|
|
916
|
+
startArrowType?: 'solid' | 'hollow' | 'diamond' | 'circle' | 'none';
|
|
917
|
+
strokeLinecap?: 'butt' | 'round' | 'square';
|
|
918
|
+
strokeLinejoin?: 'miter' | 'round' | 'bevel';
|
|
901
919
|
} & CommonTheme;
|
|
902
920
|
type ArrowAttributesType = {
|
|
903
921
|
d: string;
|
|
@@ -945,6 +963,8 @@ export declare namespace LogicFlow {
|
|
|
945
963
|
edgeAdjust: CircleTheme;
|
|
946
964
|
outline: OutlineTheme;
|
|
947
965
|
edgeAnimation: EdgeAnimation;
|
|
966
|
+
background?: boolean | Partial<LFOptions.BackgroundConfig>;
|
|
967
|
+
grid?: boolean | Partial<Grid.GridOptions>;
|
|
948
968
|
}
|
|
949
969
|
}
|
|
950
970
|
export declare namespace LogicFlow {
|
package/lib/LogicFlow.js
CHANGED
|
@@ -752,7 +752,7 @@ var LogicFlow = /** @class */ (function () {
|
|
|
752
752
|
};
|
|
753
753
|
/**
|
|
754
754
|
* 设置元素的自定义属性
|
|
755
|
-
* @see
|
|
755
|
+
* @see http://logicflow.cn/api/detail#setproperties
|
|
756
756
|
* @param id 元素的id
|
|
757
757
|
* @param properties 自定义属性
|
|
758
758
|
*/
|
|
@@ -809,7 +809,7 @@ var LogicFlow = /** @class */ (function () {
|
|
|
809
809
|
/**
|
|
810
810
|
* 更新流程图编辑相关设置
|
|
811
811
|
* @param {object} config 编辑配置
|
|
812
|
-
* @see
|
|
812
|
+
* @see http://logicflow.cn/api/detail#updateeditconfig
|
|
813
813
|
*/
|
|
814
814
|
LogicFlow.prototype.updateEditConfig = function (config) {
|
|
815
815
|
var _a = this.graphModel, editConfigModel = _a.editConfigModel, transformModel = _a.transformModel;
|
|
@@ -828,7 +828,7 @@ var LogicFlow = /** @class */ (function () {
|
|
|
828
828
|
};
|
|
829
829
|
/**
|
|
830
830
|
* 获取流程图当前编辑相关设置
|
|
831
|
-
* @see
|
|
831
|
+
* @see http://logicflow.cn/api/detail#geteditconfig
|
|
832
832
|
*/
|
|
833
833
|
LogicFlow.prototype.getEditConfig = function () {
|
|
834
834
|
return this.graphModel.editConfigModel.getConfig();
|
|
@@ -841,8 +841,15 @@ var LogicFlow = /** @class */ (function () {
|
|
|
841
841
|
* @param { object } style 自定义主题样式
|
|
842
842
|
* todo docs link
|
|
843
843
|
*/
|
|
844
|
-
LogicFlow.prototype.setTheme = function (style) {
|
|
845
|
-
this.graphModel.setTheme(style);
|
|
844
|
+
LogicFlow.prototype.setTheme = function (style, themeMode) {
|
|
845
|
+
this.graphModel.setTheme(style, themeMode);
|
|
846
|
+
};
|
|
847
|
+
/**
|
|
848
|
+
* 获取当前主题样式
|
|
849
|
+
* @see todo docs link
|
|
850
|
+
*/
|
|
851
|
+
LogicFlow.prototype.getTheme = function () {
|
|
852
|
+
return this.graphModel.getTheme();
|
|
846
853
|
};
|
|
847
854
|
LogicFlow.prototype.focusByElement = function (id) {
|
|
848
855
|
var coordinate = undefined;
|
|
@@ -1157,6 +1164,20 @@ var LogicFlow = /** @class */ (function () {
|
|
|
1157
1164
|
_a.props = props,
|
|
1158
1165
|
_a));
|
|
1159
1166
|
};
|
|
1167
|
+
/**
|
|
1168
|
+
* 添加主题模式
|
|
1169
|
+
* @param themeMode 主题模式
|
|
1170
|
+
* @param style 主题样式
|
|
1171
|
+
*/
|
|
1172
|
+
LogicFlow.addThemeMode = function (themeMode, style) {
|
|
1173
|
+
(0, util_1.addThemeMode)(themeMode, style);
|
|
1174
|
+
};
|
|
1175
|
+
LogicFlow.removeThemeMode = function (themeMode) {
|
|
1176
|
+
(0, util_1.removeThemeMode)(themeMode);
|
|
1177
|
+
};
|
|
1178
|
+
LogicFlow.clearThemeMode = function () {
|
|
1179
|
+
(0, util_1.clearThemeMode)();
|
|
1180
|
+
};
|
|
1160
1181
|
LogicFlow.prototype.installPlugins = function (disabledPlugins) {
|
|
1161
1182
|
var _this = this;
|
|
1162
1183
|
if (disabledPlugins === void 0) { disabledPlugins = []; }
|
|
@@ -1219,6 +1240,7 @@ var LogicFlow = /** @class */ (function () {
|
|
|
1219
1240
|
this.graphModel.destroy();
|
|
1220
1241
|
this.tool.destroy();
|
|
1221
1242
|
this.history.destroy();
|
|
1243
|
+
this.clearThemeMode();
|
|
1222
1244
|
for (var extensionName in this.extension) {
|
|
1223
1245
|
var extensionInstance = this.extension[extensionName];
|
|
1224
1246
|
if ('destroy' in extensionInstance) {
|
|
@@ -17,6 +17,7 @@ export declare class GraphModel {
|
|
|
17
17
|
width: number;
|
|
18
18
|
height: number;
|
|
19
19
|
theme: LogicFlow.Theme;
|
|
20
|
+
customStyles: object;
|
|
20
21
|
grid: Grid.GridOptions;
|
|
21
22
|
readonly eventCenter: EventEmitter;
|
|
22
23
|
readonly modelMap: Map<string, LogicFlow.GraphElementCtor>;
|
|
@@ -394,7 +395,39 @@ export declare class GraphModel {
|
|
|
394
395
|
* 设置主题
|
|
395
396
|
* todo docs link
|
|
396
397
|
*/
|
|
397
|
-
setTheme(style: Partial<LogicFlow.Theme
|
|
398
|
+
setTheme(style: Partial<LogicFlow.Theme>, themeMode?: 'radius' | 'dark' | 'colorful' | 'default' | string): void;
|
|
399
|
+
/**
|
|
400
|
+
* 设置主题
|
|
401
|
+
* todo docs link
|
|
402
|
+
*/
|
|
403
|
+
getTheme(): {
|
|
404
|
+
background: boolean | LFOptions.BackgroundConfig | undefined;
|
|
405
|
+
grid: Grid.GridOptions;
|
|
406
|
+
baseNode: LogicFlow.CommonTheme;
|
|
407
|
+
baseEdge: LogicFlow.CommonTheme;
|
|
408
|
+
rect: LogicFlow.CommonTheme;
|
|
409
|
+
circle: LogicFlow.CommonTheme;
|
|
410
|
+
diamond: LogicFlow.CommonTheme;
|
|
411
|
+
ellipse: LogicFlow.CommonTheme;
|
|
412
|
+
polygon: LogicFlow.CommonTheme;
|
|
413
|
+
line: LogicFlow.CommonTheme;
|
|
414
|
+
polyline: LogicFlow.CommonTheme;
|
|
415
|
+
bezier: LogicFlow.EdgeBezierTheme;
|
|
416
|
+
anchorLine: LogicFlow.AnchorLineTheme;
|
|
417
|
+
text: LogicFlow.TextNodeTheme;
|
|
418
|
+
nodeText: LogicFlow.NodeTextTheme;
|
|
419
|
+
edgeText: LogicFlow.EdgeTextTheme;
|
|
420
|
+
inputText?: LogicFlow.CommonTheme | undefined;
|
|
421
|
+
anchor: LogicFlow.AnchorTheme;
|
|
422
|
+
arrow: LogicFlow.ArrowTheme;
|
|
423
|
+
snapline: LogicFlow.CommonTheme;
|
|
424
|
+
rotateControl: LogicFlow.CommonTheme;
|
|
425
|
+
resizeControl: LogicFlow.CommonTheme;
|
|
426
|
+
resizeOutline: LogicFlow.CommonTheme;
|
|
427
|
+
edgeAdjust: LogicFlow.CommonTheme;
|
|
428
|
+
outline: LogicFlow.OutlineTheme;
|
|
429
|
+
edgeAnimation: LogicFlow.EdgeAnimation;
|
|
430
|
+
};
|
|
398
431
|
/**
|
|
399
432
|
* 更新网格配置
|
|
400
433
|
*/
|
package/lib/model/GraphModel.js
CHANGED
|
@@ -110,8 +110,11 @@ var GraphModel = /** @class */ (function () {
|
|
|
110
110
|
// TODO:需要让用户设置成 0 吗?后面可以讨论一下
|
|
111
111
|
this.gridSize = grid.size || 1; // 默认 gridSize 设置为 1
|
|
112
112
|
}
|
|
113
|
-
this.
|
|
113
|
+
this.customStyles = options.style || {};
|
|
114
114
|
this.grid = overlay_1.Grid.getGridOptions(grid !== null && grid !== void 0 ? grid : false);
|
|
115
|
+
this.theme = (0, util_1.setupTheme)(options.style, options.themeMode);
|
|
116
|
+
this.theme.grid = (0, lodash_es_1.cloneDeep)(this.grid);
|
|
117
|
+
this.theme.background = (0, lodash_es_1.cloneDeep)(this.background);
|
|
115
118
|
this.edgeType = options.edgeType || 'polyline';
|
|
116
119
|
this.animation = (0, util_1.setupAnimation)(animation);
|
|
117
120
|
this.overlapMode = options.overlapMode || constant_1.OverlapMode.DEFAULT;
|
|
@@ -1304,8 +1307,33 @@ var GraphModel = /** @class */ (function () {
|
|
|
1304
1307
|
* 设置主题
|
|
1305
1308
|
* todo docs link
|
|
1306
1309
|
*/
|
|
1307
|
-
GraphModel.prototype.setTheme = function (style) {
|
|
1308
|
-
|
|
1310
|
+
GraphModel.prototype.setTheme = function (style, themeMode) {
|
|
1311
|
+
var _a;
|
|
1312
|
+
if (themeMode) {
|
|
1313
|
+
// 修改背景颜色
|
|
1314
|
+
util_1.backgroundModeMap[themeMode] &&
|
|
1315
|
+
this.updateBackgroundOptions(__assign(__assign({}, (typeof this.background === 'object' ? this.background : {})), util_1.backgroundModeMap[themeMode]));
|
|
1316
|
+
util_1.gridModeMap[themeMode] &&
|
|
1317
|
+
this.updateGridOptions(overlay_1.Grid.getGridOptions(__assign(__assign({}, this.grid), util_1.gridModeMap[themeMode])));
|
|
1318
|
+
}
|
|
1319
|
+
if (style.background) {
|
|
1320
|
+
this.updateBackgroundOptions(style.background);
|
|
1321
|
+
}
|
|
1322
|
+
if (style.grid) {
|
|
1323
|
+
var formattedGrid = overlay_1.Grid.getGridOptions((_a = style.grid) !== null && _a !== void 0 ? _a : false);
|
|
1324
|
+
this.updateGridOptions(formattedGrid);
|
|
1325
|
+
}
|
|
1326
|
+
this.theme = (0, util_1.updateTheme)(__assign(__assign({}, this.customStyles), style), themeMode);
|
|
1327
|
+
this.customStyles = __assign(__assign({}, this.customStyles), style);
|
|
1328
|
+
};
|
|
1329
|
+
/**
|
|
1330
|
+
* 设置主题
|
|
1331
|
+
* todo docs link
|
|
1332
|
+
*/
|
|
1333
|
+
GraphModel.prototype.getTheme = function () {
|
|
1334
|
+
var _a = this, background = _a.background, grid = _a.grid;
|
|
1335
|
+
var theme = __assign(__assign({}, (0, lodash_es_1.cloneDeep)(this.theme)), { background: background, grid: grid });
|
|
1336
|
+
return theme;
|
|
1309
1337
|
};
|
|
1310
1338
|
/**
|
|
1311
1339
|
* 更新网格配置
|
|
@@ -1641,6 +1669,9 @@ var GraphModel = /** @class */ (function () {
|
|
|
1641
1669
|
__decorate([
|
|
1642
1670
|
mobx_1.action
|
|
1643
1671
|
], GraphModel.prototype, "setTheme", null);
|
|
1672
|
+
__decorate([
|
|
1673
|
+
mobx_1.action
|
|
1674
|
+
], GraphModel.prototype, "getTheme", null);
|
|
1644
1675
|
__decorate([
|
|
1645
1676
|
mobx_1.action
|
|
1646
1677
|
], GraphModel.prototype, "resize", null);
|
|
@@ -57,6 +57,7 @@ var RectNodeModel = /** @class */ (function (_super) {
|
|
|
57
57
|
RectNodeModel.prototype.setAttributes = function () {
|
|
58
58
|
_super.prototype.setAttributes.call(this);
|
|
59
59
|
var _a = this.properties, width = _a.width, height = _a.height, radius = _a.radius;
|
|
60
|
+
var styleRadius = this.getNodeStyle().radius;
|
|
60
61
|
if (!(0, lodash_es_1.isNil)(width))
|
|
61
62
|
this.width = width;
|
|
62
63
|
if (!(0, lodash_es_1.isNil)(height))
|
|
@@ -64,6 +65,8 @@ var RectNodeModel = /** @class */ (function (_super) {
|
|
|
64
65
|
// 矩形特有
|
|
65
66
|
if (!(0, lodash_es_1.isNil)(radius))
|
|
66
67
|
this.radius = radius;
|
|
68
|
+
if (!(0, lodash_es_1.isNil)(styleRadius))
|
|
69
|
+
this.radius = styleRadius;
|
|
67
70
|
};
|
|
68
71
|
RectNodeModel.prototype.getDefaultAnchor = function () {
|
|
69
72
|
var _a = this, x = _a.x, y = _a.y, width = _a.width, height = _a.height;
|
package/lib/options.d.ts
CHANGED
|
@@ -66,6 +66,7 @@ export declare namespace Options {
|
|
|
66
66
|
idGenerator?: (type?: string) => string;
|
|
67
67
|
edgeGenerator?: EdgeGeneratorType;
|
|
68
68
|
customTrajectory?: (props: CustomAnchorLineProps) => h.JSX.Element;
|
|
69
|
+
themeMode?: 'radius' | 'dark' | 'colorful';
|
|
69
70
|
[key: string]: unknown;
|
|
70
71
|
}
|
|
71
72
|
interface ManualBooleans {
|
package/lib/util/theme.d.ts
CHANGED
|
@@ -1,4 +1,69 @@
|
|
|
1
1
|
import LogicFlow from '../LogicFlow';
|
|
2
2
|
export declare const defaultTheme: LogicFlow.Theme;
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
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;
|
|
66
|
+
export declare const addThemeMode: (themeMode: string, style: Partial<LogicFlow.Theme>) => void;
|
|
67
|
+
export declare const removeThemeMode: (themeMode: string) => void;
|
|
68
|
+
export declare const clearThemeMode: () => void;
|
|
69
|
+
export declare const updateTheme: (customTheme?: Partial<LogicFlow.Theme>, themeMode?: 'radius' | 'dark' | 'colorful' | 'default' | string) => LogicFlow.Theme;
|
package/lib/util/theme.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.updateTheme = exports.setupTheme = exports.defaultTheme = void 0;
|
|
3
|
+
exports.updateTheme = exports.clearThemeMode = exports.removeThemeMode = exports.addThemeMode = exports.setupTheme = exports.gridModeMap = exports.defaultGrid = exports.colorfulGrid = exports.darkGrid = exports.backgroundModeMap = exports.defaultBackground = exports.colorfulBackground = exports.darkBackground = exports.themeModeMap = exports.colorfulMode = exports.darkMode = exports.radiusMode = exports.defaultTheme = void 0;
|
|
4
4
|
var lodash_es_1 = require("lodash-es");
|
|
5
5
|
exports.defaultTheme = {
|
|
6
6
|
baseNode: {
|
|
@@ -119,9 +119,171 @@ exports.defaultTheme = {
|
|
|
119
119
|
strokeDasharray: '3,3',
|
|
120
120
|
},
|
|
121
121
|
};
|
|
122
|
+
exports.radiusMode = {
|
|
123
|
+
rect: { radius: 8 },
|
|
124
|
+
diamond: { radius: 8 },
|
|
125
|
+
polygon: { radius: 8 },
|
|
126
|
+
polyline: { radius: 8 },
|
|
127
|
+
arrow: {
|
|
128
|
+
strokeLinecap: 'round',
|
|
129
|
+
strokeLinejoin: 'round',
|
|
130
|
+
offset: 10,
|
|
131
|
+
verticalLength: 5, // 箭头垂直于边的距离
|
|
132
|
+
},
|
|
133
|
+
snapline: {
|
|
134
|
+
strokeLinecap: 'round',
|
|
135
|
+
strokeLinejoin: 'round',
|
|
136
|
+
stroke: '#949494',
|
|
137
|
+
strokeWidth: 1,
|
|
138
|
+
},
|
|
139
|
+
outline: {
|
|
140
|
+
radius: 8,
|
|
141
|
+
fill: 'transparent',
|
|
142
|
+
stroke: '#949494',
|
|
143
|
+
strokeDasharray: '3,3',
|
|
144
|
+
hover: {
|
|
145
|
+
stroke: '#949494',
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
resizeOutline: {
|
|
149
|
+
radius: 8,
|
|
150
|
+
fill: 'none',
|
|
151
|
+
stroke: 'transparent', // 矩形默认不显示调整边框
|
|
152
|
+
strokeWidth: 1,
|
|
153
|
+
strokeDasharray: '3,3',
|
|
154
|
+
},
|
|
155
|
+
};
|
|
156
|
+
exports.darkMode = {
|
|
157
|
+
baseNode: {
|
|
158
|
+
fill: '#23272e',
|
|
159
|
+
stroke: '#fefeff',
|
|
160
|
+
},
|
|
161
|
+
baseEdge: {
|
|
162
|
+
stroke: '#fefeff',
|
|
163
|
+
},
|
|
164
|
+
rect: { radius: 8 },
|
|
165
|
+
diamond: { radius: 8 },
|
|
166
|
+
polygon: { radius: 8 },
|
|
167
|
+
polyline: { radius: 8 },
|
|
168
|
+
nodeText: {
|
|
169
|
+
color: '#fefeff',
|
|
170
|
+
overflowMode: 'default',
|
|
171
|
+
fontSize: 12,
|
|
172
|
+
lineHeight: 1.2,
|
|
173
|
+
},
|
|
174
|
+
arrow: {
|
|
175
|
+
strokeLinecap: 'round',
|
|
176
|
+
strokeLinejoin: 'round',
|
|
177
|
+
offset: 10,
|
|
178
|
+
verticalLength: 5, // 箭头垂直于边的距离
|
|
179
|
+
},
|
|
180
|
+
snapline: {
|
|
181
|
+
strokeLinecap: 'round',
|
|
182
|
+
strokeLinejoin: 'round',
|
|
183
|
+
stroke: '#949494',
|
|
184
|
+
strokeWidth: 1,
|
|
185
|
+
},
|
|
186
|
+
outline: {
|
|
187
|
+
radius: 8,
|
|
188
|
+
fill: 'transparent',
|
|
189
|
+
stroke: '#949494',
|
|
190
|
+
strokeDasharray: '3,3',
|
|
191
|
+
hover: {
|
|
192
|
+
stroke: '#949494',
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
resizeOutline: {
|
|
196
|
+
radius: 8,
|
|
197
|
+
fill: 'none',
|
|
198
|
+
stroke: 'transparent', // 矩形默认不显示调整边框
|
|
199
|
+
strokeWidth: 1,
|
|
200
|
+
strokeDasharray: '3,3',
|
|
201
|
+
},
|
|
202
|
+
};
|
|
203
|
+
exports.colorfulMode = {
|
|
204
|
+
rect: { fill: '#72CBFF', stroke: '#3ABDF9', radius: 8 },
|
|
205
|
+
circle: { fill: '#FFE075', stroke: '#F9CE3A', radius: 8 },
|
|
206
|
+
ellipse: { fill: '#FFA8A8', stroke: '#FF6B66', radius: 8 },
|
|
207
|
+
text: { fill: '#72CBFF', radius: 8 },
|
|
208
|
+
diamond: { fill: '#96F7AF', stroke: '#40EF7E', radius: 8 },
|
|
209
|
+
polygon: { fill: '#E0A8FF', stroke: '#C271FF', radius: 8 },
|
|
210
|
+
polyline: { radius: 8 },
|
|
211
|
+
arrow: {
|
|
212
|
+
strokeLinecap: 'round',
|
|
213
|
+
strokeLinejoin: 'round',
|
|
214
|
+
offset: 10,
|
|
215
|
+
verticalLength: 5, // 箭头垂直于边的距离
|
|
216
|
+
},
|
|
217
|
+
snapline: {
|
|
218
|
+
strokeLinecap: 'round',
|
|
219
|
+
strokeLinejoin: 'round',
|
|
220
|
+
stroke: '#949494',
|
|
221
|
+
strokeWidth: 1,
|
|
222
|
+
},
|
|
223
|
+
outline: {
|
|
224
|
+
radius: 8,
|
|
225
|
+
fill: 'transparent',
|
|
226
|
+
stroke: '#949494',
|
|
227
|
+
strokeDasharray: '3,3',
|
|
228
|
+
hover: {
|
|
229
|
+
stroke: '#949494',
|
|
230
|
+
},
|
|
231
|
+
},
|
|
232
|
+
resizeOutline: {
|
|
233
|
+
radius: 8,
|
|
234
|
+
fill: 'none',
|
|
235
|
+
stroke: 'transparent', // 矩形默认不显示调整边框
|
|
236
|
+
strokeWidth: 1,
|
|
237
|
+
strokeDasharray: '3,3',
|
|
238
|
+
},
|
|
239
|
+
};
|
|
240
|
+
exports.themeModeMap = {
|
|
241
|
+
colorful: exports.colorfulMode,
|
|
242
|
+
dark: exports.darkMode,
|
|
243
|
+
radius: exports.radiusMode,
|
|
244
|
+
default: exports.defaultTheme,
|
|
245
|
+
};
|
|
246
|
+
// 不同主题的背景色
|
|
247
|
+
exports.darkBackground = {
|
|
248
|
+
background: '#23272e',
|
|
249
|
+
};
|
|
250
|
+
exports.colorfulBackground = {
|
|
251
|
+
background: '#fefeff',
|
|
252
|
+
};
|
|
253
|
+
exports.defaultBackground = {
|
|
254
|
+
background: '#ffffff',
|
|
255
|
+
};
|
|
256
|
+
exports.backgroundModeMap = {
|
|
257
|
+
colorful: exports.colorfulBackground,
|
|
258
|
+
dark: exports.darkBackground,
|
|
259
|
+
radius: exports.defaultBackground,
|
|
260
|
+
default: exports.defaultBackground,
|
|
261
|
+
};
|
|
262
|
+
// 不同主题的网格样式
|
|
263
|
+
exports.darkGrid = {
|
|
264
|
+
color: '#66676a',
|
|
265
|
+
thickness: 1,
|
|
266
|
+
};
|
|
267
|
+
exports.colorfulGrid = {
|
|
268
|
+
color: '#dadada',
|
|
269
|
+
thickness: 1,
|
|
270
|
+
};
|
|
271
|
+
exports.defaultGrid = {
|
|
272
|
+
color: '#acacac',
|
|
273
|
+
thickness: 1,
|
|
274
|
+
};
|
|
275
|
+
exports.gridModeMap = {
|
|
276
|
+
colorful: exports.colorfulGrid,
|
|
277
|
+
dark: exports.darkGrid,
|
|
278
|
+
radius: exports.defaultGrid,
|
|
279
|
+
default: exports.defaultGrid,
|
|
280
|
+
};
|
|
122
281
|
/* 主题(全局样式)相关工具方法 */
|
|
123
|
-
var setupTheme = function (customTheme) {
|
|
282
|
+
var setupTheme = function (customTheme, themeMode) {
|
|
124
283
|
var theme = (0, lodash_es_1.cloneDeep)(exports.defaultTheme);
|
|
284
|
+
if (themeMode) {
|
|
285
|
+
theme = (0, lodash_es_1.merge)(theme, exports.themeModeMap[themeMode]);
|
|
286
|
+
}
|
|
125
287
|
if (customTheme) {
|
|
126
288
|
/**
|
|
127
289
|
* 为了不让默认样式被覆盖,使用 merge 方法
|
|
@@ -155,5 +317,33 @@ var setupTheme = function (customTheme) {
|
|
|
155
317
|
return theme;
|
|
156
318
|
};
|
|
157
319
|
exports.setupTheme = setupTheme;
|
|
320
|
+
var addThemeMode = function (themeMode, style) {
|
|
321
|
+
if (exports.themeModeMap[themeMode]) {
|
|
322
|
+
console.warn("theme mode ".concat(themeMode, " already exists"));
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
exports.themeModeMap[themeMode] = style;
|
|
326
|
+
exports.backgroundModeMap[themeMode] = style.background || exports.defaultBackground;
|
|
327
|
+
exports.gridModeMap[themeMode] = style.grid || exports.defaultGrid;
|
|
328
|
+
};
|
|
329
|
+
exports.addThemeMode = addThemeMode;
|
|
330
|
+
var removeThemeMode = function (themeMode) {
|
|
331
|
+
delete exports.themeModeMap[themeMode];
|
|
332
|
+
delete exports.backgroundModeMap[themeMode];
|
|
333
|
+
delete exports.gridModeMap[themeMode];
|
|
334
|
+
};
|
|
335
|
+
exports.removeThemeMode = removeThemeMode;
|
|
336
|
+
var clearThemeMode = function () {
|
|
337
|
+
var resetTheme = {
|
|
338
|
+
colorful: {},
|
|
339
|
+
dark: {},
|
|
340
|
+
radius: {},
|
|
341
|
+
default: {},
|
|
342
|
+
};
|
|
343
|
+
(0, lodash_es_1.assign)(exports.themeModeMap, resetTheme);
|
|
344
|
+
(0, lodash_es_1.assign)(exports.backgroundModeMap, resetTheme);
|
|
345
|
+
(0, lodash_es_1.assign)(exports.gridModeMap, resetTheme);
|
|
346
|
+
};
|
|
347
|
+
exports.clearThemeMode = clearThemeMode;
|
|
158
348
|
/* 更新 theme 方法 */
|
|
159
349
|
exports.updateTheme = exports.setupTheme;
|
|
@@ -44,6 +44,10 @@ export declare abstract class BaseEdge<P extends IProps> extends Component<P, IE
|
|
|
44
44
|
* 定义边的箭头,不支持重写。请使用getStartArrow和getEndArrow
|
|
45
45
|
*/
|
|
46
46
|
private getArrow;
|
|
47
|
+
/**
|
|
48
|
+
* Private helper method to generate arrow path based on type and parameters
|
|
49
|
+
*/
|
|
50
|
+
private getArrowPath;
|
|
47
51
|
/**
|
|
48
52
|
* @overridable 可重写,自定义边起点箭头形状。
|
|
49
53
|
* @example
|