@knotx/plugins-group 0.0.0
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/LICENSE +21 -0
- package/dist/index.cjs +501 -0
- package/dist/index.d.cts +117 -0
- package/dist/index.d.mts +117 -0
- package/dist/index.d.ts +117 -0
- package/dist/index.mjs +499 -0
- package/package.json +50 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { NodePosition, BasePlugin, NodeData } from '@knotx/core';
|
|
2
|
+
|
|
3
|
+
interface GroupStyle {
|
|
4
|
+
backgroundColor?: string;
|
|
5
|
+
borderColor?: string;
|
|
6
|
+
borderWidth?: number;
|
|
7
|
+
borderStyle?: string;
|
|
8
|
+
borderRadius?: number;
|
|
9
|
+
}
|
|
10
|
+
interface GroupConfig {
|
|
11
|
+
autoBounds?: boolean;
|
|
12
|
+
padding?: number;
|
|
13
|
+
style?: GroupStyle;
|
|
14
|
+
}
|
|
15
|
+
interface GroupAPI {
|
|
16
|
+
/**
|
|
17
|
+
* 创建组
|
|
18
|
+
* @param params 创建组参数
|
|
19
|
+
* @returns 组 ID
|
|
20
|
+
*/
|
|
21
|
+
createGroup: (params: {
|
|
22
|
+
id: string;
|
|
23
|
+
nodeIds: string[];
|
|
24
|
+
config?: GroupConfig;
|
|
25
|
+
data?: Record<string, any>;
|
|
26
|
+
}) => string;
|
|
27
|
+
/**
|
|
28
|
+
* 解散组
|
|
29
|
+
* @param groupId 组 ID
|
|
30
|
+
* @param recursive 是否递归解散组
|
|
31
|
+
* @returns 是否成功解散组
|
|
32
|
+
*/
|
|
33
|
+
dissolveGroup: (groupId: string, recursive?: boolean) => boolean;
|
|
34
|
+
/**
|
|
35
|
+
* 删除组
|
|
36
|
+
* @param groupId 组 ID
|
|
37
|
+
* @returns 是否成功删除组
|
|
38
|
+
*/
|
|
39
|
+
deleteGroup: (groupId: string) => boolean;
|
|
40
|
+
/**
|
|
41
|
+
* 添加节点到组
|
|
42
|
+
* @param groupId 组 ID
|
|
43
|
+
* @param nodeIds 节点 ID 列表
|
|
44
|
+
* @returns 是否成功添加节点到组
|
|
45
|
+
*/
|
|
46
|
+
addNodesToGroup: (groupId: string, nodeIds: string[]) => boolean;
|
|
47
|
+
/**
|
|
48
|
+
* 从组中移除节点
|
|
49
|
+
* @param groupId 组 ID
|
|
50
|
+
* @param nodeIds 节点 ID 列表
|
|
51
|
+
* @returns 是否成功从组中移除节点
|
|
52
|
+
*/
|
|
53
|
+
removeNodesFromGroup: (groupId: string, nodeIds: string[]) => boolean;
|
|
54
|
+
/**
|
|
55
|
+
* 移动组
|
|
56
|
+
* @param groupId 组 ID
|
|
57
|
+
* @param position 组位置
|
|
58
|
+
* @param isDelta 是否是增量移动
|
|
59
|
+
* @returns 是否成功移动组
|
|
60
|
+
*/
|
|
61
|
+
moveGroup: (groupId: string, position: NodePosition, isDelta?: boolean) => boolean;
|
|
62
|
+
}
|
|
63
|
+
declare module '@knotx/core' {
|
|
64
|
+
interface PluginData {
|
|
65
|
+
group: GroupAPI;
|
|
66
|
+
}
|
|
67
|
+
interface NodeData {
|
|
68
|
+
/**
|
|
69
|
+
* 所处的组
|
|
70
|
+
*/
|
|
71
|
+
group?: string;
|
|
72
|
+
/**
|
|
73
|
+
* type='group' 时,当前组配置
|
|
74
|
+
*/
|
|
75
|
+
groupConfig?: GroupConfig;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
interface GroupBounds {
|
|
79
|
+
x: number;
|
|
80
|
+
y: number;
|
|
81
|
+
width: number;
|
|
82
|
+
height: number;
|
|
83
|
+
}
|
|
84
|
+
declare class Group extends BasePlugin<'group'> {
|
|
85
|
+
name: "group";
|
|
86
|
+
private getNode;
|
|
87
|
+
private getNodeDraft;
|
|
88
|
+
private dispatchNodeOperation;
|
|
89
|
+
private addNodePipe;
|
|
90
|
+
private registerNodeLevelGetter;
|
|
91
|
+
private dualRelation;
|
|
92
|
+
private subscriptions;
|
|
93
|
+
init(): void;
|
|
94
|
+
destroy(): void;
|
|
95
|
+
renderGroup({ node: groupNode }: {
|
|
96
|
+
node: NodeData;
|
|
97
|
+
}): JSX.Element | null;
|
|
98
|
+
private calculateBounds;
|
|
99
|
+
createGroup: GroupAPI['createGroup'];
|
|
100
|
+
dissolveGroup: GroupAPI['dissolveGroup'];
|
|
101
|
+
deleteGroup: GroupAPI['deleteGroup'];
|
|
102
|
+
addNodesToGroup: GroupAPI['addNodesToGroup'];
|
|
103
|
+
removeNodesFromGroup: GroupAPI['removeNodesFromGroup'];
|
|
104
|
+
moveGroup: GroupAPI['moveGroup'];
|
|
105
|
+
private buildMoveGroupOperation;
|
|
106
|
+
static GROUP_WRAPPER_CLASSNAME: string;
|
|
107
|
+
static DEFAULT_GROUP_PADDING: number;
|
|
108
|
+
static DEFAULT_GROUP_STYLE: {
|
|
109
|
+
backgroundColor: string;
|
|
110
|
+
borderColor: string;
|
|
111
|
+
borderWidth: number;
|
|
112
|
+
borderStyle: string;
|
|
113
|
+
borderRadius: number;
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export { Group, type GroupAPI, type GroupBounds, type GroupConfig, type GroupStyle };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { NodePosition, BasePlugin, NodeData } from '@knotx/core';
|
|
2
|
+
|
|
3
|
+
interface GroupStyle {
|
|
4
|
+
backgroundColor?: string;
|
|
5
|
+
borderColor?: string;
|
|
6
|
+
borderWidth?: number;
|
|
7
|
+
borderStyle?: string;
|
|
8
|
+
borderRadius?: number;
|
|
9
|
+
}
|
|
10
|
+
interface GroupConfig {
|
|
11
|
+
autoBounds?: boolean;
|
|
12
|
+
padding?: number;
|
|
13
|
+
style?: GroupStyle;
|
|
14
|
+
}
|
|
15
|
+
interface GroupAPI {
|
|
16
|
+
/**
|
|
17
|
+
* 创建组
|
|
18
|
+
* @param params 创建组参数
|
|
19
|
+
* @returns 组 ID
|
|
20
|
+
*/
|
|
21
|
+
createGroup: (params: {
|
|
22
|
+
id: string;
|
|
23
|
+
nodeIds: string[];
|
|
24
|
+
config?: GroupConfig;
|
|
25
|
+
data?: Record<string, any>;
|
|
26
|
+
}) => string;
|
|
27
|
+
/**
|
|
28
|
+
* 解散组
|
|
29
|
+
* @param groupId 组 ID
|
|
30
|
+
* @param recursive 是否递归解散组
|
|
31
|
+
* @returns 是否成功解散组
|
|
32
|
+
*/
|
|
33
|
+
dissolveGroup: (groupId: string, recursive?: boolean) => boolean;
|
|
34
|
+
/**
|
|
35
|
+
* 删除组
|
|
36
|
+
* @param groupId 组 ID
|
|
37
|
+
* @returns 是否成功删除组
|
|
38
|
+
*/
|
|
39
|
+
deleteGroup: (groupId: string) => boolean;
|
|
40
|
+
/**
|
|
41
|
+
* 添加节点到组
|
|
42
|
+
* @param groupId 组 ID
|
|
43
|
+
* @param nodeIds 节点 ID 列表
|
|
44
|
+
* @returns 是否成功添加节点到组
|
|
45
|
+
*/
|
|
46
|
+
addNodesToGroup: (groupId: string, nodeIds: string[]) => boolean;
|
|
47
|
+
/**
|
|
48
|
+
* 从组中移除节点
|
|
49
|
+
* @param groupId 组 ID
|
|
50
|
+
* @param nodeIds 节点 ID 列表
|
|
51
|
+
* @returns 是否成功从组中移除节点
|
|
52
|
+
*/
|
|
53
|
+
removeNodesFromGroup: (groupId: string, nodeIds: string[]) => boolean;
|
|
54
|
+
/**
|
|
55
|
+
* 移动组
|
|
56
|
+
* @param groupId 组 ID
|
|
57
|
+
* @param position 组位置
|
|
58
|
+
* @param isDelta 是否是增量移动
|
|
59
|
+
* @returns 是否成功移动组
|
|
60
|
+
*/
|
|
61
|
+
moveGroup: (groupId: string, position: NodePosition, isDelta?: boolean) => boolean;
|
|
62
|
+
}
|
|
63
|
+
declare module '@knotx/core' {
|
|
64
|
+
interface PluginData {
|
|
65
|
+
group: GroupAPI;
|
|
66
|
+
}
|
|
67
|
+
interface NodeData {
|
|
68
|
+
/**
|
|
69
|
+
* 所处的组
|
|
70
|
+
*/
|
|
71
|
+
group?: string;
|
|
72
|
+
/**
|
|
73
|
+
* type='group' 时,当前组配置
|
|
74
|
+
*/
|
|
75
|
+
groupConfig?: GroupConfig;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
interface GroupBounds {
|
|
79
|
+
x: number;
|
|
80
|
+
y: number;
|
|
81
|
+
width: number;
|
|
82
|
+
height: number;
|
|
83
|
+
}
|
|
84
|
+
declare class Group extends BasePlugin<'group'> {
|
|
85
|
+
name: "group";
|
|
86
|
+
private getNode;
|
|
87
|
+
private getNodeDraft;
|
|
88
|
+
private dispatchNodeOperation;
|
|
89
|
+
private addNodePipe;
|
|
90
|
+
private registerNodeLevelGetter;
|
|
91
|
+
private dualRelation;
|
|
92
|
+
private subscriptions;
|
|
93
|
+
init(): void;
|
|
94
|
+
destroy(): void;
|
|
95
|
+
renderGroup({ node: groupNode }: {
|
|
96
|
+
node: NodeData;
|
|
97
|
+
}): JSX.Element | null;
|
|
98
|
+
private calculateBounds;
|
|
99
|
+
createGroup: GroupAPI['createGroup'];
|
|
100
|
+
dissolveGroup: GroupAPI['dissolveGroup'];
|
|
101
|
+
deleteGroup: GroupAPI['deleteGroup'];
|
|
102
|
+
addNodesToGroup: GroupAPI['addNodesToGroup'];
|
|
103
|
+
removeNodesFromGroup: GroupAPI['removeNodesFromGroup'];
|
|
104
|
+
moveGroup: GroupAPI['moveGroup'];
|
|
105
|
+
private buildMoveGroupOperation;
|
|
106
|
+
static GROUP_WRAPPER_CLASSNAME: string;
|
|
107
|
+
static DEFAULT_GROUP_PADDING: number;
|
|
108
|
+
static DEFAULT_GROUP_STYLE: {
|
|
109
|
+
backgroundColor: string;
|
|
110
|
+
borderColor: string;
|
|
111
|
+
borderWidth: number;
|
|
112
|
+
borderStyle: string;
|
|
113
|
+
borderRadius: number;
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export { Group, type GroupAPI, type GroupBounds, type GroupConfig, type GroupStyle };
|