@logicflow/core 2.0.13 → 2.0.15
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 +12 -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
package/es/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/es/LogicFlow.js
CHANGED
|
@@ -43,7 +43,7 @@ import * as _Model from './model';
|
|
|
43
43
|
import { GraphModel, SnaplineModel, } from './model';
|
|
44
44
|
import Graph from './view/Graph';
|
|
45
45
|
import * as _View from './view';
|
|
46
|
-
import { formatData } from './util';
|
|
46
|
+
import { formatData, addThemeMode, removeThemeMode, clearThemeMode, } from './util';
|
|
47
47
|
import { Dnd, snapline } from './view/behavior';
|
|
48
48
|
import Tool from './tool';
|
|
49
49
|
import History from './history';
|
|
@@ -723,7 +723,7 @@ var LogicFlow = /** @class */ (function () {
|
|
|
723
723
|
};
|
|
724
724
|
/**
|
|
725
725
|
* 设置元素的自定义属性
|
|
726
|
-
* @see
|
|
726
|
+
* @see http://logicflow.cn/api/detail#setproperties
|
|
727
727
|
* @param id 元素的id
|
|
728
728
|
* @param properties 自定义属性
|
|
729
729
|
*/
|
|
@@ -780,7 +780,7 @@ var LogicFlow = /** @class */ (function () {
|
|
|
780
780
|
/**
|
|
781
781
|
* 更新流程图编辑相关设置
|
|
782
782
|
* @param {object} config 编辑配置
|
|
783
|
-
* @see
|
|
783
|
+
* @see http://logicflow.cn/api/detail#updateeditconfig
|
|
784
784
|
*/
|
|
785
785
|
LogicFlow.prototype.updateEditConfig = function (config) {
|
|
786
786
|
var _a = this.graphModel, editConfigModel = _a.editConfigModel, transformModel = _a.transformModel;
|
|
@@ -799,7 +799,7 @@ var LogicFlow = /** @class */ (function () {
|
|
|
799
799
|
};
|
|
800
800
|
/**
|
|
801
801
|
* 获取流程图当前编辑相关设置
|
|
802
|
-
* @see
|
|
802
|
+
* @see http://logicflow.cn/api/detail#geteditconfig
|
|
803
803
|
*/
|
|
804
804
|
LogicFlow.prototype.getEditConfig = function () {
|
|
805
805
|
return this.graphModel.editConfigModel.getConfig();
|
|
@@ -812,8 +812,15 @@ var LogicFlow = /** @class */ (function () {
|
|
|
812
812
|
* @param { object } style 自定义主题样式
|
|
813
813
|
* todo docs link
|
|
814
814
|
*/
|
|
815
|
-
LogicFlow.prototype.setTheme = function (style) {
|
|
816
|
-
this.graphModel.setTheme(style);
|
|
815
|
+
LogicFlow.prototype.setTheme = function (style, themeMode) {
|
|
816
|
+
this.graphModel.setTheme(style, themeMode);
|
|
817
|
+
};
|
|
818
|
+
/**
|
|
819
|
+
* 获取当前主题样式
|
|
820
|
+
* @see todo docs link
|
|
821
|
+
*/
|
|
822
|
+
LogicFlow.prototype.getTheme = function () {
|
|
823
|
+
return this.graphModel.getTheme();
|
|
817
824
|
};
|
|
818
825
|
LogicFlow.prototype.focusByElement = function (id) {
|
|
819
826
|
var coordinate = undefined;
|
|
@@ -1128,6 +1135,20 @@ var LogicFlow = /** @class */ (function () {
|
|
|
1128
1135
|
_a.props = props,
|
|
1129
1136
|
_a));
|
|
1130
1137
|
};
|
|
1138
|
+
/**
|
|
1139
|
+
* 添加主题模式
|
|
1140
|
+
* @param themeMode 主题模式
|
|
1141
|
+
* @param style 主题样式
|
|
1142
|
+
*/
|
|
1143
|
+
LogicFlow.addThemeMode = function (themeMode, style) {
|
|
1144
|
+
addThemeMode(themeMode, style);
|
|
1145
|
+
};
|
|
1146
|
+
LogicFlow.removeThemeMode = function (themeMode) {
|
|
1147
|
+
removeThemeMode(themeMode);
|
|
1148
|
+
};
|
|
1149
|
+
LogicFlow.clearThemeMode = function () {
|
|
1150
|
+
clearThemeMode();
|
|
1151
|
+
};
|
|
1131
1152
|
LogicFlow.prototype.installPlugins = function (disabledPlugins) {
|
|
1132
1153
|
var _this = this;
|
|
1133
1154
|
if (disabledPlugins === void 0) { disabledPlugins = []; }
|
|
@@ -1190,6 +1211,7 @@ var LogicFlow = /** @class */ (function () {
|
|
|
1190
1211
|
this.graphModel.destroy();
|
|
1191
1212
|
this.tool.destroy();
|
|
1192
1213
|
this.history.destroy();
|
|
1214
|
+
this.clearThemeMode();
|
|
1193
1215
|
for (var extensionName in this.extension) {
|
|
1194
1216
|
var extensionInstance = this.extension[extensionName];
|
|
1195
1217
|
if ('destroy' in extensionInstance) {
|
package/es/model/GraphModel.d.ts
CHANGED
|
@@ -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/es/model/GraphModel.js
CHANGED
|
@@ -51,11 +51,11 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
51
51
|
}
|
|
52
52
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
53
53
|
};
|
|
54
|
-
import { find, forEach, map, merge, isBoolean, debounce, isNil, } from 'lodash-es';
|
|
54
|
+
import { find, forEach, map, merge, isBoolean, debounce, cloneDeep, isNil, } from 'lodash-es';
|
|
55
55
|
import { action, computed, observable } from 'mobx';
|
|
56
56
|
import { EditConfigModel, TransformModel, } from '.';
|
|
57
57
|
import { DEFAULT_VISIBLE_SPACE, ELEMENT_MAX_Z_INDEX, ElementState, ElementType, EventType, ModelType, OverlapMode, TextMode, } from '../constant';
|
|
58
|
-
import { createEdgeGenerator, createUuid, formatData, getClosestPointOfPolyline, getMinIndex, getNodeAnchorPosition, getNodeBBox, getZIndex, isPointInArea, setupAnimation, setupTheme, snapToGrid, updateTheme, } from '../util';
|
|
58
|
+
import { createEdgeGenerator, createUuid, formatData, getClosestPointOfPolyline, getMinIndex, getNodeAnchorPosition, getNodeBBox, getZIndex, isPointInArea, setupAnimation, setupTheme, snapToGrid, updateTheme, backgroundModeMap, gridModeMap, } from '../util';
|
|
59
59
|
import EventEmitter from '../event/eventEmitter';
|
|
60
60
|
import { Grid } from '../view/overlay';
|
|
61
61
|
var GraphModel = /** @class */ (function () {
|
|
@@ -104,8 +104,11 @@ var GraphModel = /** @class */ (function () {
|
|
|
104
104
|
// TODO:需要让用户设置成 0 吗?后面可以讨论一下
|
|
105
105
|
this.gridSize = grid.size || 1; // 默认 gridSize 设置为 1
|
|
106
106
|
}
|
|
107
|
-
this.
|
|
107
|
+
this.customStyles = options.style || {};
|
|
108
108
|
this.grid = Grid.getGridOptions(grid !== null && grid !== void 0 ? grid : false);
|
|
109
|
+
this.theme = setupTheme(options.style, options.themeMode);
|
|
110
|
+
this.theme.grid = cloneDeep(this.grid);
|
|
111
|
+
this.theme.background = cloneDeep(this.background);
|
|
109
112
|
this.edgeType = options.edgeType || 'polyline';
|
|
110
113
|
this.animation = setupAnimation(animation);
|
|
111
114
|
this.overlapMode = options.overlapMode || OverlapMode.DEFAULT;
|
|
@@ -1298,8 +1301,33 @@ var GraphModel = /** @class */ (function () {
|
|
|
1298
1301
|
* 设置主题
|
|
1299
1302
|
* todo docs link
|
|
1300
1303
|
*/
|
|
1301
|
-
GraphModel.prototype.setTheme = function (style) {
|
|
1302
|
-
|
|
1304
|
+
GraphModel.prototype.setTheme = function (style, themeMode) {
|
|
1305
|
+
var _a;
|
|
1306
|
+
if (themeMode) {
|
|
1307
|
+
// 修改背景颜色
|
|
1308
|
+
backgroundModeMap[themeMode] &&
|
|
1309
|
+
this.updateBackgroundOptions(__assign(__assign({}, (typeof this.background === 'object' ? this.background : {})), backgroundModeMap[themeMode]));
|
|
1310
|
+
gridModeMap[themeMode] &&
|
|
1311
|
+
this.updateGridOptions(Grid.getGridOptions(__assign(__assign({}, this.grid), gridModeMap[themeMode])));
|
|
1312
|
+
}
|
|
1313
|
+
if (style.background) {
|
|
1314
|
+
this.updateBackgroundOptions(style.background);
|
|
1315
|
+
}
|
|
1316
|
+
if (style.grid) {
|
|
1317
|
+
var formattedGrid = Grid.getGridOptions((_a = style.grid) !== null && _a !== void 0 ? _a : false);
|
|
1318
|
+
this.updateGridOptions(formattedGrid);
|
|
1319
|
+
}
|
|
1320
|
+
this.theme = updateTheme(__assign(__assign({}, this.customStyles), style), themeMode);
|
|
1321
|
+
this.customStyles = __assign(__assign({}, this.customStyles), style);
|
|
1322
|
+
};
|
|
1323
|
+
/**
|
|
1324
|
+
* 设置主题
|
|
1325
|
+
* todo docs link
|
|
1326
|
+
*/
|
|
1327
|
+
GraphModel.prototype.getTheme = function () {
|
|
1328
|
+
var _a = this, background = _a.background, grid = _a.grid;
|
|
1329
|
+
var theme = __assign(__assign({}, cloneDeep(this.theme)), { background: background, grid: grid });
|
|
1330
|
+
return theme;
|
|
1303
1331
|
};
|
|
1304
1332
|
/**
|
|
1305
1333
|
* 更新网格配置
|
|
@@ -1635,6 +1663,9 @@ var GraphModel = /** @class */ (function () {
|
|
|
1635
1663
|
__decorate([
|
|
1636
1664
|
action
|
|
1637
1665
|
], GraphModel.prototype, "setTheme", null);
|
|
1666
|
+
__decorate([
|
|
1667
|
+
action
|
|
1668
|
+
], GraphModel.prototype, "getTheme", null);
|
|
1638
1669
|
__decorate([
|
|
1639
1670
|
action
|
|
1640
1671
|
], GraphModel.prototype, "resize", null);
|
|
@@ -51,6 +51,7 @@ var RectNodeModel = /** @class */ (function (_super) {
|
|
|
51
51
|
RectNodeModel.prototype.setAttributes = function () {
|
|
52
52
|
_super.prototype.setAttributes.call(this);
|
|
53
53
|
var _a = this.properties, width = _a.width, height = _a.height, radius = _a.radius;
|
|
54
|
+
var styleRadius = this.getNodeStyle().radius;
|
|
54
55
|
if (!isNil(width))
|
|
55
56
|
this.width = width;
|
|
56
57
|
if (!isNil(height))
|
|
@@ -58,6 +59,8 @@ var RectNodeModel = /** @class */ (function (_super) {
|
|
|
58
59
|
// 矩形特有
|
|
59
60
|
if (!isNil(radius))
|
|
60
61
|
this.radius = radius;
|
|
62
|
+
if (!isNil(styleRadius))
|
|
63
|
+
this.radius = styleRadius;
|
|
61
64
|
};
|
|
62
65
|
RectNodeModel.prototype.getDefaultAnchor = function () {
|
|
63
66
|
var _a = this, x = _a.x, y = _a.y, width = _a.width, height = _a.height;
|
package/es/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/es/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/es/util/theme.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { cloneDeep, merge } from 'lodash-es';
|
|
1
|
+
import { cloneDeep, merge, assign } from 'lodash-es';
|
|
2
2
|
export var defaultTheme = {
|
|
3
3
|
baseNode: {
|
|
4
4
|
fill: '#fff',
|
|
@@ -116,9 +116,171 @@ export var defaultTheme = {
|
|
|
116
116
|
strokeDasharray: '3,3',
|
|
117
117
|
},
|
|
118
118
|
};
|
|
119
|
+
export var radiusMode = {
|
|
120
|
+
rect: { radius: 8 },
|
|
121
|
+
diamond: { radius: 8 },
|
|
122
|
+
polygon: { radius: 8 },
|
|
123
|
+
polyline: { radius: 8 },
|
|
124
|
+
arrow: {
|
|
125
|
+
strokeLinecap: 'round',
|
|
126
|
+
strokeLinejoin: 'round',
|
|
127
|
+
offset: 10,
|
|
128
|
+
verticalLength: 5, // 箭头垂直于边的距离
|
|
129
|
+
},
|
|
130
|
+
snapline: {
|
|
131
|
+
strokeLinecap: 'round',
|
|
132
|
+
strokeLinejoin: 'round',
|
|
133
|
+
stroke: '#949494',
|
|
134
|
+
strokeWidth: 1,
|
|
135
|
+
},
|
|
136
|
+
outline: {
|
|
137
|
+
radius: 8,
|
|
138
|
+
fill: 'transparent',
|
|
139
|
+
stroke: '#949494',
|
|
140
|
+
strokeDasharray: '3,3',
|
|
141
|
+
hover: {
|
|
142
|
+
stroke: '#949494',
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
resizeOutline: {
|
|
146
|
+
radius: 8,
|
|
147
|
+
fill: 'none',
|
|
148
|
+
stroke: 'transparent', // 矩形默认不显示调整边框
|
|
149
|
+
strokeWidth: 1,
|
|
150
|
+
strokeDasharray: '3,3',
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
export var darkMode = {
|
|
154
|
+
baseNode: {
|
|
155
|
+
fill: '#23272e',
|
|
156
|
+
stroke: '#fefeff',
|
|
157
|
+
},
|
|
158
|
+
baseEdge: {
|
|
159
|
+
stroke: '#fefeff',
|
|
160
|
+
},
|
|
161
|
+
rect: { radius: 8 },
|
|
162
|
+
diamond: { radius: 8 },
|
|
163
|
+
polygon: { radius: 8 },
|
|
164
|
+
polyline: { radius: 8 },
|
|
165
|
+
nodeText: {
|
|
166
|
+
color: '#fefeff',
|
|
167
|
+
overflowMode: 'default',
|
|
168
|
+
fontSize: 12,
|
|
169
|
+
lineHeight: 1.2,
|
|
170
|
+
},
|
|
171
|
+
arrow: {
|
|
172
|
+
strokeLinecap: 'round',
|
|
173
|
+
strokeLinejoin: 'round',
|
|
174
|
+
offset: 10,
|
|
175
|
+
verticalLength: 5, // 箭头垂直于边的距离
|
|
176
|
+
},
|
|
177
|
+
snapline: {
|
|
178
|
+
strokeLinecap: 'round',
|
|
179
|
+
strokeLinejoin: 'round',
|
|
180
|
+
stroke: '#949494',
|
|
181
|
+
strokeWidth: 1,
|
|
182
|
+
},
|
|
183
|
+
outline: {
|
|
184
|
+
radius: 8,
|
|
185
|
+
fill: 'transparent',
|
|
186
|
+
stroke: '#949494',
|
|
187
|
+
strokeDasharray: '3,3',
|
|
188
|
+
hover: {
|
|
189
|
+
stroke: '#949494',
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
resizeOutline: {
|
|
193
|
+
radius: 8,
|
|
194
|
+
fill: 'none',
|
|
195
|
+
stroke: 'transparent', // 矩形默认不显示调整边框
|
|
196
|
+
strokeWidth: 1,
|
|
197
|
+
strokeDasharray: '3,3',
|
|
198
|
+
},
|
|
199
|
+
};
|
|
200
|
+
export var colorfulMode = {
|
|
201
|
+
rect: { fill: '#72CBFF', stroke: '#3ABDF9', radius: 8 },
|
|
202
|
+
circle: { fill: '#FFE075', stroke: '#F9CE3A', radius: 8 },
|
|
203
|
+
ellipse: { fill: '#FFA8A8', stroke: '#FF6B66', radius: 8 },
|
|
204
|
+
text: { fill: '#72CBFF', radius: 8 },
|
|
205
|
+
diamond: { fill: '#96F7AF', stroke: '#40EF7E', radius: 8 },
|
|
206
|
+
polygon: { fill: '#E0A8FF', stroke: '#C271FF', radius: 8 },
|
|
207
|
+
polyline: { radius: 8 },
|
|
208
|
+
arrow: {
|
|
209
|
+
strokeLinecap: 'round',
|
|
210
|
+
strokeLinejoin: 'round',
|
|
211
|
+
offset: 10,
|
|
212
|
+
verticalLength: 5, // 箭头垂直于边的距离
|
|
213
|
+
},
|
|
214
|
+
snapline: {
|
|
215
|
+
strokeLinecap: 'round',
|
|
216
|
+
strokeLinejoin: 'round',
|
|
217
|
+
stroke: '#949494',
|
|
218
|
+
strokeWidth: 1,
|
|
219
|
+
},
|
|
220
|
+
outline: {
|
|
221
|
+
radius: 8,
|
|
222
|
+
fill: 'transparent',
|
|
223
|
+
stroke: '#949494',
|
|
224
|
+
strokeDasharray: '3,3',
|
|
225
|
+
hover: {
|
|
226
|
+
stroke: '#949494',
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
resizeOutline: {
|
|
230
|
+
radius: 8,
|
|
231
|
+
fill: 'none',
|
|
232
|
+
stroke: 'transparent', // 矩形默认不显示调整边框
|
|
233
|
+
strokeWidth: 1,
|
|
234
|
+
strokeDasharray: '3,3',
|
|
235
|
+
},
|
|
236
|
+
};
|
|
237
|
+
export var themeModeMap = {
|
|
238
|
+
colorful: colorfulMode,
|
|
239
|
+
dark: darkMode,
|
|
240
|
+
radius: radiusMode,
|
|
241
|
+
default: defaultTheme,
|
|
242
|
+
};
|
|
243
|
+
// 不同主题的背景色
|
|
244
|
+
export var darkBackground = {
|
|
245
|
+
background: '#23272e',
|
|
246
|
+
};
|
|
247
|
+
export var colorfulBackground = {
|
|
248
|
+
background: '#fefeff',
|
|
249
|
+
};
|
|
250
|
+
export var defaultBackground = {
|
|
251
|
+
background: '#ffffff',
|
|
252
|
+
};
|
|
253
|
+
export var backgroundModeMap = {
|
|
254
|
+
colorful: colorfulBackground,
|
|
255
|
+
dark: darkBackground,
|
|
256
|
+
radius: defaultBackground,
|
|
257
|
+
default: defaultBackground,
|
|
258
|
+
};
|
|
259
|
+
// 不同主题的网格样式
|
|
260
|
+
export var darkGrid = {
|
|
261
|
+
color: '#66676a',
|
|
262
|
+
thickness: 1,
|
|
263
|
+
};
|
|
264
|
+
export var colorfulGrid = {
|
|
265
|
+
color: '#dadada',
|
|
266
|
+
thickness: 1,
|
|
267
|
+
};
|
|
268
|
+
export var defaultGrid = {
|
|
269
|
+
color: '#acacac',
|
|
270
|
+
thickness: 1,
|
|
271
|
+
};
|
|
272
|
+
export var gridModeMap = {
|
|
273
|
+
colorful: colorfulGrid,
|
|
274
|
+
dark: darkGrid,
|
|
275
|
+
radius: defaultGrid,
|
|
276
|
+
default: defaultGrid,
|
|
277
|
+
};
|
|
119
278
|
/* 主题(全局样式)相关工具方法 */
|
|
120
|
-
export var setupTheme = function (customTheme) {
|
|
279
|
+
export var setupTheme = function (customTheme, themeMode) {
|
|
121
280
|
var theme = cloneDeep(defaultTheme);
|
|
281
|
+
if (themeMode) {
|
|
282
|
+
theme = merge(theme, themeModeMap[themeMode]);
|
|
283
|
+
}
|
|
122
284
|
if (customTheme) {
|
|
123
285
|
/**
|
|
124
286
|
* 为了不让默认样式被覆盖,使用 merge 方法
|
|
@@ -151,5 +313,30 @@ export var setupTheme = function (customTheme) {
|
|
|
151
313
|
}
|
|
152
314
|
return theme;
|
|
153
315
|
};
|
|
316
|
+
export var addThemeMode = function (themeMode, style) {
|
|
317
|
+
if (themeModeMap[themeMode]) {
|
|
318
|
+
console.warn("theme mode ".concat(themeMode, " already exists"));
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
themeModeMap[themeMode] = style;
|
|
322
|
+
backgroundModeMap[themeMode] = style.background || defaultBackground;
|
|
323
|
+
gridModeMap[themeMode] = style.grid || defaultGrid;
|
|
324
|
+
};
|
|
325
|
+
export var removeThemeMode = function (themeMode) {
|
|
326
|
+
delete themeModeMap[themeMode];
|
|
327
|
+
delete backgroundModeMap[themeMode];
|
|
328
|
+
delete gridModeMap[themeMode];
|
|
329
|
+
};
|
|
330
|
+
export var clearThemeMode = function () {
|
|
331
|
+
var resetTheme = {
|
|
332
|
+
colorful: {},
|
|
333
|
+
dark: {},
|
|
334
|
+
radius: {},
|
|
335
|
+
default: {},
|
|
336
|
+
};
|
|
337
|
+
assign(themeModeMap, resetTheme);
|
|
338
|
+
assign(backgroundModeMap, resetTheme);
|
|
339
|
+
assign(gridModeMap, resetTheme);
|
|
340
|
+
};
|
|
154
341
|
/* 更新 theme 方法 */
|
|
155
342
|
export var updateTheme = 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
|
package/es/view/edge/BaseEdge.js
CHANGED
|
@@ -291,6 +291,31 @@ var BaseEdge = /** @class */ (function (_super) {
|
|
|
291
291
|
}
|
|
292
292
|
return (_jsx("g", { children: _jsxs("defs", { children: [_jsx("marker", { id: "marker-start-".concat(id), refX: -refX, refY: refY, overflow: "visible", orient: "auto", markerUnits: "userSpaceOnUse", children: this.getStartArrow() }), _jsx("marker", { id: "marker-end-".concat(id), refX: refX, refY: refY, overflow: "visible", orient: theta, markerUnits: "userSpaceOnUse", children: this.getEndArrow() })] }) }));
|
|
293
293
|
};
|
|
294
|
+
/**
|
|
295
|
+
* Private helper method to generate arrow path based on type and parameters
|
|
296
|
+
*/
|
|
297
|
+
BaseEdge.prototype.getArrowPath = function (arrowType, props) {
|
|
298
|
+
var stroke = props.stroke, _a = props.fill, fill = _a === void 0 ? stroke : _a, strokeWidth = props.strokeWidth, _b = props.offset, offset = _b === void 0 ? 10 : _b, verticalLength = props.verticalLength, strokeLinecap = props.strokeLinecap, strokeLinejoin = props.strokeLinejoin, transform = props.transform;
|
|
299
|
+
var arrowPath = '';
|
|
300
|
+
switch (arrowType) {
|
|
301
|
+
case 'solid':
|
|
302
|
+
arrowPath = "M".concat(-offset / 4, ",0 L").concat((3 * offset) / 4, ",").concat(verticalLength, " L").concat((3 * offset) / 4, ",-").concat(verticalLength, " Z");
|
|
303
|
+
break;
|
|
304
|
+
case 'hollow':
|
|
305
|
+
arrowPath = "M".concat(-offset / 4, ",0 L").concat((3 * offset) / 4, ",").concat(verticalLength, " L").concat(-offset / 4, ",0 L").concat((3 * offset) / 4, ",-").concat(verticalLength, " L").concat(-offset / 4, ",0 Z");
|
|
306
|
+
break;
|
|
307
|
+
case 'diamond':
|
|
308
|
+
arrowPath = "M".concat(-offset / 2, ",0 L0,").concat(verticalLength, " L").concat(offset / 2, ",0 L0,-").concat(verticalLength, " L").concat(-offset / 2, ",0 Z");
|
|
309
|
+
break;
|
|
310
|
+
case 'circle':
|
|
311
|
+
arrowPath = "M".concat(-offset / 2, ",0 A").concat(offset / 4, ",").concat(offset / 4, " 0 1,0 ").concat(offset / 2, ",0 A").concat(offset / 4, ",").concat(offset / 4, " 0 1,0 ").concat(-offset / 2, ",0 Z");
|
|
312
|
+
break;
|
|
313
|
+
default:
|
|
314
|
+
arrowPath = '';
|
|
315
|
+
break;
|
|
316
|
+
}
|
|
317
|
+
return (_jsx("path", { d: arrowPath, stroke: stroke, fill: fill, strokeWidth: strokeWidth, strokeLinecap: strokeLinecap, strokeLinejoin: strokeLinejoin, transform: transform }));
|
|
318
|
+
};
|
|
294
319
|
/**
|
|
295
320
|
* @overridable 可重写,自定义边起点箭头形状。
|
|
296
321
|
* @example
|
|
@@ -305,7 +330,16 @@ var BaseEdge = /** @class */ (function (_super) {
|
|
|
305
330
|
* }
|
|
306
331
|
*/
|
|
307
332
|
BaseEdge.prototype.getStartArrow = function () {
|
|
308
|
-
|
|
333
|
+
var model = this.props.model;
|
|
334
|
+
var _a = model.getArrowStyle(), stroke = _a.stroke, strokeWidth = _a.strokeWidth, offset = _a.offset, verticalLength = _a.verticalLength, _b = _a.startArrowType, startArrowType = _b === void 0 ? 'none' : _b, strokeLinecap = _a.strokeLinecap, strokeLinejoin = _a.strokeLinejoin;
|
|
335
|
+
return this.getArrowPath(startArrowType, {
|
|
336
|
+
stroke: stroke,
|
|
337
|
+
strokeWidth: strokeWidth,
|
|
338
|
+
offset: offset,
|
|
339
|
+
verticalLength: verticalLength,
|
|
340
|
+
strokeLinecap: strokeLinecap,
|
|
341
|
+
strokeLinejoin: strokeLinejoin,
|
|
342
|
+
});
|
|
309
343
|
};
|
|
310
344
|
/**
|
|
311
345
|
* @overridable 可重写,自定义边终点箭头形状。
|
|
@@ -322,8 +356,16 @@ var BaseEdge = /** @class */ (function (_super) {
|
|
|
322
356
|
*/
|
|
323
357
|
BaseEdge.prototype.getEndArrow = function () {
|
|
324
358
|
var model = this.props.model;
|
|
325
|
-
var _a = model.getArrowStyle(), stroke = _a.stroke, strokeWidth = _a.strokeWidth, offset = _a.offset, verticalLength = _a.verticalLength;
|
|
326
|
-
return (
|
|
359
|
+
var _a = model.getArrowStyle(), stroke = _a.stroke, strokeWidth = _a.strokeWidth, offset = _a.offset, verticalLength = _a.verticalLength, _b = _a.endArrowType, endArrowType = _b === void 0 ? 'solid' : _b, strokeLinecap = _a.strokeLinecap, strokeLinejoin = _a.strokeLinejoin;
|
|
360
|
+
return this.getArrowPath(endArrowType, {
|
|
361
|
+
stroke: stroke,
|
|
362
|
+
strokeWidth: strokeWidth,
|
|
363
|
+
offset: offset,
|
|
364
|
+
verticalLength: verticalLength,
|
|
365
|
+
strokeLinecap: strokeLinecap,
|
|
366
|
+
strokeLinejoin: strokeLinejoin,
|
|
367
|
+
transform: 'rotate(180)',
|
|
368
|
+
});
|
|
327
369
|
};
|
|
328
370
|
/**
|
|
329
371
|
* @overridable 可重写,自定义调整边连接节点形状。在开启了adjustEdgeStartAndEnd的时候,会显示调整点。
|
package/es/view/overlay/Grid.js
CHANGED
|
@@ -54,8 +54,9 @@ var Grid = /** @class */ (function (_super) {
|
|
|
54
54
|
return (_jsx("path", { d: d, stroke: color, strokeWidth: strokeWidth / 2, opacity: opacity, fill: "transparent" }));
|
|
55
55
|
};
|
|
56
56
|
Grid.prototype.render = function () {
|
|
57
|
-
var
|
|
58
|
-
|
|
57
|
+
var _a = this.props.graphModel, transformModel = _a.transformModel, grid = _a.grid;
|
|
58
|
+
this.gridOptions = grid;
|
|
59
|
+
var _b = this.gridOptions, type = _b.type, _c = _b.size, size = _c === void 0 ? 1 : _c;
|
|
59
60
|
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;
|
|
60
61
|
var matrixString = [
|
|
61
62
|
SCALE_X,
|