@logicflow/core 1.2.0-alpha.5 → 1.2.0-alpha.8

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/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@logicflow/core",
3
- "version": "1.2.0-alpha.5",
3
+ "version": "1.2.0-alpha.8",
4
4
  "description": "LogicFlow core, to quickly build flowchart editor",
5
- "main": "dist/logic-flow.js",
6
- "unpkg": "dist/logic-flow.js",
7
- "jsdelivr": "dist/logic-flow.js",
5
+ "main": "dist/entry.js",
6
+ "unpkg": "dist/logic-flow.min.js",
7
+ "jsdelivr": "dist/logic-flow.min.js",
8
8
  "license": "Apache-2.0",
9
9
  "homepage": "http://logic-flow.org/",
10
10
  "types": "types/index.d.ts",
@@ -17,7 +17,7 @@
17
17
  "dev": "cross-env NODE_ENV=development webpack-dev-server --client-log-level warning --config scripts/webpack.config.dev.js",
18
18
  "clean": "rimraf dist lib esm cjs",
19
19
  "build": "npm run build:umd",
20
- "build:umd": "cross-env NODE_ENV=production webpack --config scripts/webpack.config.build.js && cp -r src/style/ dist/style",
20
+ "build:umd": "cross-env NODE_ENV=production webpack --config scripts/webpack.config.build.js && cp -r src/style/ dist/style && cp scripts/entry.js dist",
21
21
  "build-analyse": "cross-env analyse=true npm run build",
22
22
  "types": "tsc -d --declarationDir ./tempTypes --outDir temp && rimraf types && mv ./tempTypes/src ./types && rimraf temp && rimraf tempTypes",
23
23
  "lint": "eslint . --ext .ts,.tsx",
@@ -106,6 +106,11 @@ export default class LogicFlow {
106
106
  */
107
107
  register(type: string | RegisterConfig, fn?: RegisterElementFn, isObserverView?: boolean): void;
108
108
  private registerElement;
109
+ /**
110
+ * 批量注册
111
+ * @param elements 注册的元素
112
+ */
113
+ batchRegister(elements?: any[]): void;
109
114
  private defaultRegister;
110
115
  /**
111
116
  * 将图形选中
@@ -445,9 +450,20 @@ export default class LogicFlow {
445
450
  translateCenter(): void;
446
451
  /**
447
452
  * 图形适应屏幕大小
448
- * @param offset number 距离盒子四周的距离, 默认为20
453
+ * @param verticalOffset number 距离盒子上下的距离, 默认为20
454
+ * @param horizontalOffset number 距离盒子左右的距离, 默认为20
455
+ */
456
+ fitView(verticalOffset?: number, horizontalOffset?: number): void;
457
+ /**
458
+ * 开启边的动画
459
+ * @param edgeId any
460
+ */
461
+ openEdgeAnimation(edgeId: any): void;
462
+ /**
463
+ * 关闭边的动画
464
+ * @param edgeId any
449
465
  */
450
- fitView(offset: number): void;
466
+ closeEdgeAnimation(edgeId: any): void;
451
467
  /**
452
468
  * 监听事件
453
469
  * 事件详情见 @see todo
@@ -139,6 +139,10 @@ export declare type EdgeTextTheme = {
139
139
  * 文本背景样式
140
140
  */
141
141
  background?: {
142
+ /**
143
+ * 背景区域padding
144
+ * wrapPadding: '5px,10px'
145
+ */
142
146
  wrapPadding?: string;
143
147
  } & RectTheme;
144
148
  /**
@@ -179,6 +183,19 @@ export declare type OutlineTheme = {
179
183
  */
180
184
  hover?: CommonTheme;
181
185
  } & CommonTheme;
186
+ /**
187
+ * 边动画主题
188
+ */
189
+ export declare type EdgeAnimation = {
190
+ stroke?: string;
191
+ strokeDasharray?: string;
192
+ strokeDashoffset?: string;
193
+ animationName?: string;
194
+ animationDuration?: string;
195
+ animationIterationCount?: string;
196
+ animationTimingFunction?: string;
197
+ animationDirection?: string;
198
+ };
182
199
  export declare type Theme = {
183
200
  /**
184
201
  * 所有节点的通用主题设置
@@ -258,5 +275,9 @@ export declare type Theme = {
258
275
  * 节点选择状态下外侧的选框样式
259
276
  */
260
277
  outline?: OutlineTheme;
278
+ /**
279
+ * 边动画样式
280
+ */
281
+ edgeAnimation?: EdgeAnimation;
261
282
  };
262
283
  export declare const defaultTheme: Theme;
@@ -68,6 +68,12 @@ export interface EditConfigInterface {
68
68
  * 不支持ctrl,ctrl会触发contextmenu
69
69
  */
70
70
  multipleSelectKey?: string;
71
+ /**
72
+ * 拖动节点靠近画布边缘时,
73
+ * 是否自动扩张画布.
74
+ * 默认false。
75
+ */
76
+ autoExpand?: string;
71
77
  }
72
78
  /**
73
79
  * 页面编辑配置
@@ -89,6 +95,7 @@ export default class EditConfigModel {
89
95
  edgeTextEdit: boolean;
90
96
  nodeTextDraggable: boolean;
91
97
  edgeTextDraggable: boolean;
98
+ autoExpand: boolean;
92
99
  multipleSelectKey: string;
93
100
  defaultConfig: {};
94
101
  constructor(config: EditConfigInterface);
@@ -433,9 +433,20 @@ declare class GraphModel {
433
433
  translateCenter(): void;
434
434
  /**
435
435
  * 画布图形适应屏幕大小
436
- * @param offset number 距离盒子四周的距离, 默认为20
436
+ * @param verticalOffset number 距离盒子上下的距离, 默认为20
437
+ * @param horizontalOffset number 距离盒子左右的距离, 默认为20
437
438
  */
438
- fitView(offset?: number): void;
439
+ fitView(verticalOffset?: number, horizontalOffset?: number): void;
440
+ /**
441
+ * 开启边的动画
442
+ * @param edgeId any
443
+ */
444
+ openEdgeAnimation(edgeId: any): void;
445
+ /**
446
+ * 关闭边的动画
447
+ * @param edgeId any
448
+ */
449
+ closeEdgeAnimation(edgeId: any): void;
439
450
  }
440
451
  export { GraphModel };
441
452
  export default GraphModel;
@@ -1,6 +1,6 @@
1
1
  import { IBaseModel } from '../BaseModel';
2
2
  import GraphModel from '../GraphModel';
3
- import { Point, AdditionData, EdgeData, MenuConfig, EdgeConfig } from '../../type/index';
3
+ import { Point, AdditionData, EdgeData, MenuConfig, EdgeConfig, ShapeStyleAttribute } from '../../type/index';
4
4
  import { ModelType, ElementType } from '../../constant/constant';
5
5
  import { OutlineTheme } from '../../constant/DefaultTheme';
6
6
  declare class BaseEdgeModel implements IBaseModel {
@@ -25,6 +25,8 @@ declare class BaseEdgeModel implements IBaseModel {
25
25
  isHitable: boolean;
26
26
  draggable: boolean;
27
27
  visible: boolean;
28
+ virtual: boolean;
29
+ isAnimation: boolean;
28
30
  graphModel: GraphModel;
29
31
  zIndex: number;
30
32
  readonly BaseType = ElementType.EDGE;
@@ -36,6 +38,11 @@ declare class BaseEdgeModel implements IBaseModel {
36
38
  menu?: MenuConfig[];
37
39
  customTextPosition: boolean;
38
40
  animationData: import("../../constant/DefaultAnimation").Animation;
41
+ style: ShapeStyleAttribute;
42
+ arrowConfig: {
43
+ markerEnd: string;
44
+ markerStart: string;
45
+ };
39
46
  [propName: string]: any;
40
47
  constructor(data: EdgeConfig, graphModel: GraphModel);
41
48
  init(): void;
@@ -62,7 +69,12 @@ declare class BaseEdgeModel implements IBaseModel {
62
69
  * 获取当前节点样式
63
70
  * @returns 自定义边样式
64
71
  */
65
- getEdgeStyle(): import("../../constant/DefaultTheme").CommonTheme;
72
+ getEdgeStyle(): {
73
+ [x: string]: any;
74
+ fill?: string;
75
+ stroke?: string;
76
+ strokeWidth?: number;
77
+ };
66
78
  /**
67
79
  * @override 支持重写
68
80
  * 获取当前节点文本样式
@@ -75,7 +87,13 @@ declare class BaseEdgeModel implements IBaseModel {
75
87
  */
76
88
  getAnimation(): import("../../constant/DefaultAnimation").Animation;
77
89
  /**
78
- * @override 支持重写
90
+ * @overridable 支持重写
91
+ * 获取当前边的动画样式
92
+ * @returns 自定义边动画样式
93
+ */
94
+ getEdgeAnimationStyle(): import("../../constant/DefaultTheme").EdgeAnimation;
95
+ /**
96
+ * @overridable 支持重写
79
97
  * 获取outline样式,重写可以定义此类型边outline样式, 默认使用主题样式
80
98
  * @returns 自定义outline样式
81
99
  */
@@ -112,6 +130,9 @@ declare class BaseEdgeModel implements IBaseModel {
112
130
  getHistoryData(): EdgeData;
113
131
  setProperty(key: any, val: any): void;
114
132
  setProperties(properties: any): void;
133
+ setStyle(key: any, val: any): void;
134
+ setStyles(styles: any): void;
135
+ updateStyles(styles: any): void;
115
136
  /**
116
137
  * 内部方法,处理初始化文本格式
117
138
  */
@@ -139,6 +160,8 @@ declare class BaseEdgeModel implements IBaseModel {
139
160
  setSelected(flag?: boolean): void;
140
161
  setHovered(flag?: boolean): void;
141
162
  setHitable(flag?: boolean): void;
163
+ openEdgeAnimation(): void;
164
+ closeEdgeAnimation(): void;
142
165
  setElementState(state: number, additionStateData?: AdditionData): void;
143
166
  updateStartPoint(anchor: any): void;
144
167
  moveStartPoint(deltaX: any, deltaY: any): void;
@@ -37,15 +37,27 @@ export default class PolylineEdgeModel extends BaseEdgeModel {
37
37
  moveEndPoint(deltaX: any, deltaY: any): void;
38
38
  dragAppendStart(): void;
39
39
  dragAppendSimple(appendInfo: any, dragInfo: any): {
40
- start: any;
41
- end: any;
40
+ start: {
41
+ x: any;
42
+ y: any;
43
+ };
44
+ end: {
45
+ x: any;
46
+ y: any;
47
+ };
42
48
  startIndex: any;
43
49
  endIndex: any;
44
50
  direction: any;
45
51
  };
46
52
  dragAppend(appendInfo: any, dragInfo: any): {
47
- start: any;
48
- end: any;
53
+ start: {
54
+ x: any;
55
+ y: any;
56
+ };
57
+ end: {
58
+ x: any;
59
+ y: any;
60
+ };
49
61
  startIndex: any;
50
62
  endIndex: any;
51
63
  direction: any;
@@ -45,10 +45,12 @@ export default class BaseNodeModel implements IBaseNodeModel {
45
45
  isHitable: boolean;
46
46
  draggable: boolean;
47
47
  visible: boolean;
48
+ virtual: boolean;
48
49
  graphModel: GraphModel;
49
50
  zIndex: number;
50
51
  state: number;
51
52
  autoToFront: boolean;
53
+ style: ShapeStyleAttribute;
52
54
  readonly BaseType = ElementType.NODE;
53
55
  modelType: ModelType;
54
56
  additionStateData: AdditionData;
@@ -194,7 +196,10 @@ export default class BaseNodeModel implements IBaseNodeModel {
194
196
  setElementState(state: number, additionStateData?: AdditionData): void;
195
197
  setProperty(key: any, val: any): void;
196
198
  setProperties(properties: any): void;
197
- setZIndex(zIndex?: number): void;
199
+ setStyle(key: any, val: any): void;
200
+ setStyles(styles: any): void;
201
+ updateStyles(styles: any): void;
202
+ setZIndex(zindex?: number): void;
198
203
  /**
199
204
  * 设置节点属性;
200
205
  * 支持属性请参考节点属性文档
@@ -382,4 +382,25 @@ export declare type VirtualRectSize = {
382
382
  virtualRectCenterPositionX: number;
383
383
  virtualRectCenterPositionY: number;
384
384
  };
385
+ export declare type ArrowPath = {
386
+ d: string;
387
+ stroke?: string;
388
+ fill?: string;
389
+ transform?: string;
390
+ [key: string]: any;
391
+ };
392
+ export declare type ArrowMarker = {
393
+ id: string;
394
+ refX?: string | number;
395
+ refY?: string | number;
396
+ overflow?: string;
397
+ orient?: string;
398
+ markerUnits?: string;
399
+ viewBox?: string;
400
+ markerWidth?: number;
401
+ markerHeight?: number;
402
+ path: ArrowPath;
403
+ [key: string]: any;
404
+ };
405
+ export declare type ArrowMarkerList = ArrowMarker[];
385
406
  export {};
@@ -38,7 +38,7 @@ declare class Anchor extends Component<IProps, IState> {
38
38
  event: any;
39
39
  }) => void;
40
40
  onDragEnd: (event: any) => void;
41
- checkEnd: () => void;
41
+ checkEnd: (event: any) => void;
42
42
  moveAnchorEnd(endX: number, endY: number): void;
43
43
  isShowLine(): boolean;
44
44
  render(): h.JSX.Element;
@@ -17,6 +17,8 @@ export default class BaseEdge extends Component<IProps> {
17
17
  getArrowInfo(): ArrowInfo;
18
18
  getArrowStyle(): ArrowStyle;
19
19
  getArrow(): h.JSX.Element;
20
+ getStartArrow(): h.JSX.Element;
21
+ getEndArrow(): h.JSX.Element;
20
22
  getAdjustPoints(): h.JSX.Element;
21
23
  getAnimation(): void;
22
24
  getAppendWidth(): h.JSX.Element;