@tmagic/editor 1.3.0-beta.6 → 1.3.0-beta.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/dist/style.css +57 -56
- package/dist/tmagic-editor.js +549 -436
- package/dist/tmagic-editor.js.map +1 -1
- package/dist/tmagic-editor.umd.cjs +567 -454
- package/dist/tmagic-editor.umd.cjs.map +1 -1
- package/package.json +10 -10
- package/src/Editor.vue +8 -0
- package/src/components/ContentMenu.vue +2 -6
- package/src/components/SplitView.vue +22 -6
- package/src/components/Tree.vue +66 -0
- package/src/components/TreeNode.vue +142 -0
- package/src/layouts/Framework.vue +11 -21
- package/src/layouts/sidebar/Sidebar.vue +13 -0
- package/src/layouts/sidebar/data-source/DataSourceList.vue +28 -17
- package/src/layouts/sidebar/data-source/DataSourceListPanel.vue +8 -2
- package/src/layouts/sidebar/layer/LayerPanel.vue +40 -31
- package/src/layouts/sidebar/layer/use-click.ts +105 -0
- package/src/layouts/sidebar/layer/use-drag.ts +1 -1
- package/src/layouts/sidebar/layer/use-filter.ts +1 -12
- package/src/layouts/sidebar/layer/use-keybinding.ts +6 -2
- package/src/layouts/sidebar/layer/use-node-status.ts +4 -2
- package/src/layouts/workspace/viewer/NodeListMenu.vue +11 -2
- package/src/services/dep.ts +1 -1
- package/src/theme/layer-panel.scss +2 -74
- package/src/theme/theme.scss +1 -0
- package/src/theme/tree.scss +72 -0
- package/src/type.ts +16 -1
- package/src/utils/dep.ts +7 -2
- package/src/utils/tree.ts +15 -0
- package/types/components/ContentMenu.vue.d.ts +4 -1
- package/types/components/SplitView.vue.d.ts +3 -1
- package/types/{layouts/sidebar/layer/LayerNode.vue.d.ts → components/Tree.vue.d.ts} +19 -17
- package/types/components/TreeNode.vue.d.ts +47 -0
- package/types/layouts/sidebar/data-source/DataSourceList.vue.d.ts +2 -6
- package/types/layouts/sidebar/data-source/DataSourceListPanel.vue.d.ts +7 -1
- package/types/layouts/sidebar/layer/LayerPanel.vue.d.ts +1 -1
- package/types/layouts/sidebar/layer/use-click.d.ts +106 -0
- package/types/layouts/sidebar/layer/use-filter.d.ts +0 -1
- package/types/layouts/sidebar/layer/use-keybinding.d.ts +2 -1
- package/types/type.d.ts +20 -1
- package/types/utils/tree.d.ts +3 -0
- package/src/layouts/sidebar/layer/LayerNode.vue +0 -208
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { type ComputedRef, nextTick, type Ref, ref } from 'vue';
|
|
2
|
+
import { throttle } from 'lodash-es';
|
|
3
|
+
|
|
4
|
+
import { Id, MNode } from '@tmagic/schema';
|
|
5
|
+
|
|
6
|
+
import { LayerNodeStatus, Services, TreeNodeData, UI_SELECT_MODE_EVENT_NAME } from '@editor/type';
|
|
7
|
+
import { updateStatus } from '@editor/utils/tree';
|
|
8
|
+
|
|
9
|
+
import LayerMenu from './LayerMenu.vue';
|
|
10
|
+
|
|
11
|
+
export const useClick = (
|
|
12
|
+
services: Services | undefined,
|
|
13
|
+
isCtrlKeyDown: Ref<boolean>,
|
|
14
|
+
nodeStatusMap: ComputedRef<Map<Id, LayerNodeStatus> | undefined>,
|
|
15
|
+
) => {
|
|
16
|
+
// 触发画布选中
|
|
17
|
+
const select = async (data: MNode) => {
|
|
18
|
+
if (!data.id) {
|
|
19
|
+
throw new Error('没有id');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (isCtrlKeyDown.value) {
|
|
23
|
+
multiSelect(data);
|
|
24
|
+
} else {
|
|
25
|
+
await services?.editorService.select(data);
|
|
26
|
+
services?.editorService.get('stage')?.select(data.id);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const multiSelect = async (data: MNode) => {
|
|
31
|
+
const nodes = services?.editorService.get('nodes') || [];
|
|
32
|
+
|
|
33
|
+
const newNodes: Id[] = [];
|
|
34
|
+
let isCancel = false;
|
|
35
|
+
nodes.forEach((node) => {
|
|
36
|
+
if (node.id === data.id) {
|
|
37
|
+
isCancel = true;
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
newNodes.push(node.id);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// 只剩一个不能取消选中
|
|
45
|
+
if (!isCancel || newNodes.length === 0) {
|
|
46
|
+
newNodes.push(data.id);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
await services?.editorService.multiSelect(newNodes);
|
|
50
|
+
services?.editorService.get('stage')?.multiSelect(newNodes);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const throttleTime = 300;
|
|
54
|
+
// 鼠标在组件树移动触发高亮
|
|
55
|
+
const highlightHandler = throttle((event: MouseEvent, data: TreeNodeData) => {
|
|
56
|
+
highlight(data);
|
|
57
|
+
}, throttleTime);
|
|
58
|
+
|
|
59
|
+
// 触发画布高亮
|
|
60
|
+
const highlight = (data: TreeNodeData) => {
|
|
61
|
+
services?.editorService?.highlight(data);
|
|
62
|
+
services?.editorService?.get('stage')?.highlight(data.id);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const nodeClickHandler = (event: MouseEvent, data: TreeNodeData) => {
|
|
66
|
+
if (!nodeStatusMap?.value) return;
|
|
67
|
+
|
|
68
|
+
if (services?.uiService.get('uiSelectMode')) {
|
|
69
|
+
document.dispatchEvent(new CustomEvent(UI_SELECT_MODE_EVENT_NAME, { detail: data }));
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (data.items && data.items.length > 0 && !isCtrlKeyDown.value) {
|
|
74
|
+
updateStatus(nodeStatusMap.value, data.id, {
|
|
75
|
+
expand: true,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
nextTick(() => {
|
|
80
|
+
select(data);
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
// 右键菜单
|
|
85
|
+
const menu = ref<InstanceType<typeof LayerMenu>>();
|
|
86
|
+
|
|
87
|
+
return {
|
|
88
|
+
menu,
|
|
89
|
+
|
|
90
|
+
nodeClickHandler,
|
|
91
|
+
|
|
92
|
+
nodeContentmenuHandler(event: MouseEvent, data: TreeNodeData) {
|
|
93
|
+
event.preventDefault();
|
|
94
|
+
|
|
95
|
+
const nodes = services?.editorService.get('nodes') || [];
|
|
96
|
+
if (nodes.length < 2 || !nodes.includes(data)) {
|
|
97
|
+
nodeClickHandler(event, data);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
menu.value?.show(event);
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
highlightHandler,
|
|
104
|
+
};
|
|
105
|
+
};
|
|
@@ -65,7 +65,7 @@ export const useDrag = (services: Services | undefined) => {
|
|
|
65
65
|
if (!event.target) return;
|
|
66
66
|
|
|
67
67
|
const targetEl = getNodeEl(event.target as HTMLElement);
|
|
68
|
-
if (!targetEl) return;
|
|
68
|
+
if (!targetEl?.draggable) return;
|
|
69
69
|
|
|
70
70
|
const labelEl = targetEl.children[0];
|
|
71
71
|
if (!labelEl) return;
|
|
@@ -1,21 +1,10 @@
|
|
|
1
1
|
import { type ComputedRef, ref } from 'vue';
|
|
2
2
|
|
|
3
3
|
import { Id, MNode, MPage } from '@tmagic/schema';
|
|
4
|
-
import { getKeys } from '@tmagic/utils';
|
|
5
4
|
|
|
6
5
|
import { LayerNodeStatus } from '@editor/type';
|
|
7
6
|
import { traverseNode } from '@editor/utils';
|
|
8
|
-
|
|
9
|
-
export const updateStatus = (nodeStatusMap: Map<Id, LayerNodeStatus>, id: Id, status: Partial<LayerNodeStatus>) => {
|
|
10
|
-
const nodeStatus = nodeStatusMap.get(id);
|
|
11
|
-
|
|
12
|
-
if (!nodeStatus) return;
|
|
13
|
-
getKeys(status).forEach((key) => {
|
|
14
|
-
if (nodeStatus[key] !== undefined && status[key] !== undefined) {
|
|
15
|
-
nodeStatus[key] = Boolean(status[key]);
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
};
|
|
7
|
+
import { updateStatus } from '@editor/utils/tree';
|
|
19
8
|
|
|
20
9
|
export const useFilter = (
|
|
21
10
|
nodeStatusMap: ComputedRef<Map<Id, LayerNodeStatus> | undefined>,
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { type Ref, ref, watchEffect } from 'vue';
|
|
2
2
|
|
|
3
|
+
import Tree from '@editor/components/Tree.vue';
|
|
3
4
|
import type { Services } from '@editor/type';
|
|
4
5
|
import { KeyBindingContainerKey } from '@editor/utils/keybinding-config';
|
|
5
6
|
|
|
6
|
-
export const useKeybinding = (
|
|
7
|
+
export const useKeybinding = (
|
|
8
|
+
services: Services | undefined,
|
|
9
|
+
contianer: Ref<InstanceType<typeof Tree> | undefined>,
|
|
10
|
+
) => {
|
|
7
11
|
const keybindingService = services?.keybindingService;
|
|
8
12
|
|
|
9
13
|
// 是否多选
|
|
@@ -37,7 +41,7 @@ export const useKeybinding = (services: Services | undefined, contianer: Ref<HTM
|
|
|
37
41
|
watchEffect(() => {
|
|
38
42
|
if (contianer.value) {
|
|
39
43
|
globalThis.addEventListener('blur', windowBlurHandler);
|
|
40
|
-
keybindingService?.registeEl(KeyBindingContainerKey.LAYER_PANEL, contianer.value);
|
|
44
|
+
keybindingService?.registeEl(KeyBindingContainerKey.LAYER_PANEL, contianer.value.$el);
|
|
41
45
|
} else {
|
|
42
46
|
globalThis.removeEventListener('blur', windowBlurHandler);
|
|
43
47
|
keybindingService?.unregisteEl(KeyBindingContainerKey.LAYER_PANEL);
|
|
@@ -5,8 +5,7 @@ import { getNodePath } from '@tmagic/utils';
|
|
|
5
5
|
|
|
6
6
|
import { LayerNodeStatus, Services } from '@editor/type';
|
|
7
7
|
import { traverseNode } from '@editor/utils';
|
|
8
|
-
|
|
9
|
-
import { updateStatus } from './use-filter';
|
|
8
|
+
import { updateStatus } from '@editor/utils/tree';
|
|
10
9
|
|
|
11
10
|
const createPageNodeStatus = (services: Services | undefined, pageId: Id) => {
|
|
12
11
|
const map = new Map<Id, LayerNodeStatus>();
|
|
@@ -15,6 +14,7 @@ const createPageNodeStatus = (services: Services | undefined, pageId: Id) => {
|
|
|
15
14
|
visible: true,
|
|
16
15
|
expand: true,
|
|
17
16
|
selected: true,
|
|
17
|
+
draggable: false,
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
services?.editorService.getNodeById(pageId)?.items.forEach((node: MNode) =>
|
|
@@ -23,6 +23,7 @@ const createPageNodeStatus = (services: Services | undefined, pageId: Id) => {
|
|
|
23
23
|
visible: true,
|
|
24
24
|
expand: false,
|
|
25
25
|
selected: false,
|
|
26
|
+
draggable: true,
|
|
26
27
|
});
|
|
27
28
|
}),
|
|
28
29
|
);
|
|
@@ -87,6 +88,7 @@ export const useNodeStatus = (services: Services | undefined, page: ComputedRef<
|
|
|
87
88
|
visible: true,
|
|
88
89
|
expand: Array.isArray(node.items),
|
|
89
90
|
selected: true,
|
|
91
|
+
draggable: true,
|
|
90
92
|
});
|
|
91
93
|
});
|
|
92
94
|
});
|
|
@@ -26,11 +26,15 @@ import ContentMenu from '@editor/components/ContentMenu.vue';
|
|
|
26
26
|
import type { ComponentItem, MenuButton, Services } from '@editor/type';
|
|
27
27
|
|
|
28
28
|
import NodeListMenuTitle from './NodeListMenuTitle.vue';
|
|
29
|
+
|
|
30
|
+
const PINNED_STATUE_CACHE_KEY = 'tmagic-pinned-node-list-pinned-status';
|
|
31
|
+
|
|
29
32
|
const props = defineProps<{ isMultiSelect?: boolean }>();
|
|
30
33
|
|
|
31
34
|
const menu = ref<InstanceType<typeof ContentMenu>>();
|
|
32
35
|
const nodeList = ref<MNode[]>([]);
|
|
33
|
-
const pinned = ref(
|
|
36
|
+
const pinned = ref(Boolean(globalThis.localStorage.getItem(PINNED_STATUE_CACHE_KEY)));
|
|
37
|
+
const firstShow = ref(true);
|
|
34
38
|
|
|
35
39
|
const services = inject<Services>('services');
|
|
36
40
|
const editorService = services?.editorService;
|
|
@@ -94,7 +98,8 @@ const unWatch = watch(
|
|
|
94
98
|
nodeList.value = nodes;
|
|
95
99
|
|
|
96
100
|
if (nodeList.value.length > 1) {
|
|
97
|
-
menu.value?.show(pinned.value ? undefined : event);
|
|
101
|
+
menu.value?.show(pinned.value && !firstShow.value ? undefined : event);
|
|
102
|
+
firstShow.value = false;
|
|
98
103
|
}
|
|
99
104
|
}, 1500);
|
|
100
105
|
});
|
|
@@ -163,4 +168,8 @@ const dragMenuHandler = ({ deltaY, deltaX }: OnDrag) => {
|
|
|
163
168
|
const closeHandler = () => {
|
|
164
169
|
menu.value?.hide();
|
|
165
170
|
};
|
|
171
|
+
|
|
172
|
+
watch(pinned, () => {
|
|
173
|
+
globalThis.localStorage.setItem(PINNED_STATUE_CACHE_KEY, pinned.value.toString());
|
|
174
|
+
});
|
|
166
175
|
</script>
|
package/src/services/dep.ts
CHANGED
|
@@ -299,7 +299,7 @@ export class Watcher extends EventEmitter {
|
|
|
299
299
|
const keyIsItems = key === 'items';
|
|
300
300
|
const fullKey = prop ? `${prop}.${key}` : key;
|
|
301
301
|
|
|
302
|
-
if (target.isTarget(
|
|
302
|
+
if (target.isTarget(fullKey, value)) {
|
|
303
303
|
target.updateDep(node, fullKey);
|
|
304
304
|
this.emit('update-dep', node, fullKey);
|
|
305
305
|
} else if (!keyIsItems && Array.isArray(value)) {
|
|
@@ -1,79 +1,7 @@
|
|
|
1
|
-
.
|
|
2
|
-
$--node-height: 22px;
|
|
3
|
-
|
|
1
|
+
.m-editor-layer-panel {
|
|
4
2
|
background: $--sidebar-content-background-color;
|
|
5
3
|
|
|
6
|
-
.
|
|
4
|
+
.m-editor-tree {
|
|
7
5
|
padding-top: 48px;
|
|
8
|
-
background-color: $--sidebar-content-background-color;
|
|
9
|
-
color: $--font-color;
|
|
10
|
-
font-size: 13px;
|
|
11
|
-
|
|
12
|
-
.magic-editor-layer-node {
|
|
13
|
-
cursor: pointer;
|
|
14
|
-
white-space: nowrap;
|
|
15
|
-
|
|
16
|
-
.layer-node {
|
|
17
|
-
display: flex;
|
|
18
|
-
align-items: center;
|
|
19
|
-
|
|
20
|
-
&:hover {
|
|
21
|
-
background-color: $--hover-color;
|
|
22
|
-
color: $--font-color;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
&.selected {
|
|
26
|
-
background-color: $--theme-color;
|
|
27
|
-
color: $--hover-color;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
&.drag-inner {
|
|
31
|
-
.layer-node-content {
|
|
32
|
-
background-color: rgba($color: $--theme-color, $alpha: 0.5);
|
|
33
|
-
color: $--hover-color;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
&.drag-before {
|
|
38
|
-
.layer-node-content {
|
|
39
|
-
border-top-color: rgba($color: $--theme-color, $alpha: 0.5);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
&.drag-after {
|
|
44
|
-
.layer-node-content {
|
|
45
|
-
border-bottom-color: rgba($color: $--theme-color, $alpha: 0.5);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
.expand-icon {
|
|
50
|
-
padding: 4px;
|
|
51
|
-
box-sizing: content-box;
|
|
52
|
-
font-size: 14px;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
.layer-node-content {
|
|
56
|
-
display: flex;
|
|
57
|
-
flex: 1;
|
|
58
|
-
justify-content: space-between;
|
|
59
|
-
height: $--node-height;
|
|
60
|
-
border-top: 2px solid transparent;
|
|
61
|
-
border-bottom: 2px solid transparent;
|
|
62
|
-
.layer-node-label {
|
|
63
|
-
line-height: $--node-height;
|
|
64
|
-
flex: 1;
|
|
65
|
-
width: 100px;
|
|
66
|
-
overflow: hidden;
|
|
67
|
-
text-overflow: ellipsis;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
.layer-node-tool {
|
|
72
|
-
margin-right: 15px;
|
|
73
|
-
display: flex;
|
|
74
|
-
align-items: center;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
6
|
}
|
|
79
7
|
}
|
package/src/theme/theme.scss
CHANGED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
.m-editor-tree {
|
|
2
|
+
$--node-height: 22px;
|
|
3
|
+
color: $--font-color;
|
|
4
|
+
font-size: 13px;
|
|
5
|
+
|
|
6
|
+
.m-editor-tree-node {
|
|
7
|
+
cursor: pointer;
|
|
8
|
+
white-space: nowrap;
|
|
9
|
+
|
|
10
|
+
.tree-node {
|
|
11
|
+
display: flex;
|
|
12
|
+
align-items: center;
|
|
13
|
+
|
|
14
|
+
&:hover {
|
|
15
|
+
background-color: $--hover-color;
|
|
16
|
+
color: $--font-color;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&.selected {
|
|
20
|
+
background-color: $--theme-color;
|
|
21
|
+
color: $--hover-color;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
&.drag-inner {
|
|
25
|
+
.tree-node-content {
|
|
26
|
+
background-color: rgba($color: $--theme-color, $alpha: 0.5);
|
|
27
|
+
color: $--hover-color;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
&.drag-before {
|
|
32
|
+
.tree-node-content {
|
|
33
|
+
border-top-color: rgba($color: $--theme-color, $alpha: 0.5);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
&.drag-after {
|
|
38
|
+
.tree-node-content {
|
|
39
|
+
border-bottom-color: rgba($color: $--theme-color, $alpha: 0.5);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.expand-icon {
|
|
44
|
+
padding: 4px;
|
|
45
|
+
box-sizing: content-box;
|
|
46
|
+
font-size: 14px;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.tree-node-content {
|
|
50
|
+
display: flex;
|
|
51
|
+
flex: 1;
|
|
52
|
+
justify-content: space-between;
|
|
53
|
+
height: $--node-height;
|
|
54
|
+
border-top: 2px solid transparent;
|
|
55
|
+
border-bottom: 2px solid transparent;
|
|
56
|
+
.tree-node-label {
|
|
57
|
+
line-height: $--node-height;
|
|
58
|
+
flex: 1;
|
|
59
|
+
width: 100px;
|
|
60
|
+
overflow: hidden;
|
|
61
|
+
text-overflow: ellipsis;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.tree-node-tool {
|
|
66
|
+
margin-right: 15px;
|
|
67
|
+
display: flex;
|
|
68
|
+
align-items: center;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
package/src/type.ts
CHANGED
|
@@ -75,19 +75,25 @@ export interface CodeBlockListSlots {
|
|
|
75
75
|
'code-block-panel-tool'(props: { id: Id; data: CodeBlockContent }): any;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
export interface DataSourceListSlots {
|
|
79
|
+
'data-source-panel-tool'(props: { data: any }): any;
|
|
80
|
+
}
|
|
81
|
+
|
|
78
82
|
export interface LayerNodeSlots {
|
|
79
83
|
'layer-node-content'(props: { data: MNode }): any;
|
|
80
84
|
}
|
|
81
85
|
|
|
82
86
|
export interface LayerPanelSlots extends LayerNodeSlots {
|
|
83
87
|
'layer-panel-header'(props: {}): any;
|
|
88
|
+
'layer-node-tool'(props: { data: MNode }): any;
|
|
89
|
+
'layer-node-content'(props: { data: MNode }): any;
|
|
84
90
|
}
|
|
85
91
|
|
|
86
92
|
export interface PropsPanelSlots {
|
|
87
93
|
'props-panel-header'(props: {}): any;
|
|
88
94
|
}
|
|
89
95
|
|
|
90
|
-
export type SidebarSlots = LayerPanelSlots & CodeBlockListPanelSlots & ComponentListPanelSlots;
|
|
96
|
+
export type SidebarSlots = LayerPanelSlots & CodeBlockListPanelSlots & ComponentListPanelSlots & DataSourceListSlots;
|
|
91
97
|
|
|
92
98
|
export type BeforeAdd = (config: MNode, parent: MContainer) => Promise<MNode> | MNode;
|
|
93
99
|
export type GetConfig = (config: FormConfig) => Promise<FormConfig> | FormConfig;
|
|
@@ -595,6 +601,8 @@ export interface LayerNodeStatus {
|
|
|
595
601
|
expand: boolean;
|
|
596
602
|
/** 选中 */
|
|
597
603
|
selected: boolean;
|
|
604
|
+
/** 是否可拖拽 */
|
|
605
|
+
draggable: boolean;
|
|
598
606
|
}
|
|
599
607
|
|
|
600
608
|
/** 拖拽类型 */
|
|
@@ -607,3 +615,10 @@ export enum DragType {
|
|
|
607
615
|
|
|
608
616
|
/** 当uiService.get('uiSelectMode')为true,点击组件(包括任何形式,组件树/画布)时触发的事件名 */
|
|
609
617
|
export const UI_SELECT_MODE_EVENT_NAME = 'ui-select';
|
|
618
|
+
|
|
619
|
+
export interface TreeNodeData {
|
|
620
|
+
id: Id;
|
|
621
|
+
name?: string;
|
|
622
|
+
items?: TreeNodeData[];
|
|
623
|
+
[key: string]: any;
|
|
624
|
+
}
|
package/src/utils/dep.ts
CHANGED
|
@@ -58,8 +58,13 @@ export const createDataSourceCondTarget = (id: string) =>
|
|
|
58
58
|
new Target({
|
|
59
59
|
type: DepTargetType.DATA_SOURCE_COND,
|
|
60
60
|
id,
|
|
61
|
-
isTarget: (key: string | number, value: any) =>
|
|
62
|
-
Array.isArray(value)
|
|
61
|
+
isTarget: (key: string | number, value: any) => {
|
|
62
|
+
if (!Array.isArray(value) || value[0] !== id || !`${key}`.startsWith('displayConds')) return false;
|
|
63
|
+
|
|
64
|
+
const ds = dataSourceService.getDataSourceById(id);
|
|
65
|
+
|
|
66
|
+
return Boolean(ds?.fields?.find((field) => field.name === value[1]));
|
|
67
|
+
},
|
|
63
68
|
});
|
|
64
69
|
|
|
65
70
|
export const createDataSourceMethodTarget = (id: string) =>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Id } from '@tmagic/schema';
|
|
2
|
+
import { getKeys } from '@tmagic/utils';
|
|
3
|
+
|
|
4
|
+
import type { LayerNodeStatus } from '@editor/type';
|
|
5
|
+
|
|
6
|
+
export const updateStatus = (nodeStatusMap: Map<Id, LayerNodeStatus>, id: Id, status: Partial<LayerNodeStatus>) => {
|
|
7
|
+
const nodeStatus = nodeStatusMap.get(id);
|
|
8
|
+
|
|
9
|
+
if (!nodeStatus) return;
|
|
10
|
+
getKeys(status).forEach((key) => {
|
|
11
|
+
if (nodeStatus[key] !== undefined && status[key] !== undefined) {
|
|
12
|
+
nodeStatus[key] = Boolean(status[key]);
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
};
|
|
@@ -15,7 +15,10 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
|
|
|
15
15
|
top: number;
|
|
16
16
|
}>;
|
|
17
17
|
hide: () => void;
|
|
18
|
-
show: (e?:
|
|
18
|
+
show: (e?: {
|
|
19
|
+
clientY: number;
|
|
20
|
+
clientX: number;
|
|
21
|
+
} | undefined) => void;
|
|
19
22
|
contains: (el: HTMLElement) => any;
|
|
20
23
|
setPosition: (e: {
|
|
21
24
|
clientY: number;
|
|
@@ -11,7 +11,9 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
|
|
|
11
11
|
minLeft: number;
|
|
12
12
|
minRight: number;
|
|
13
13
|
minCenter: number;
|
|
14
|
-
}>, {
|
|
14
|
+
}>, {
|
|
15
|
+
updateWidth(): void;
|
|
16
|
+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("change" | "update:left" | "update:right")[], "change" | "update:left" | "update:right", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
15
17
|
left?: number | undefined;
|
|
16
18
|
right?: number | undefined;
|
|
17
19
|
minLeft?: number | undefined;
|
|
@@ -1,30 +1,32 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import {
|
|
1
|
+
import type { Id } from '@tmagic/schema';
|
|
2
|
+
import type { LayerNodeStatus, TreeNodeData } from '../type';
|
|
3
3
|
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
4
|
-
data:
|
|
5
|
-
|
|
4
|
+
data: TreeNodeData[];
|
|
5
|
+
nodeStatusMap: Map<Id, LayerNodeStatus>;
|
|
6
6
|
indent?: number | undefined;
|
|
7
|
-
|
|
8
|
-
isCtrlKeyDown?: boolean | undefined;
|
|
7
|
+
emptyText?: string | undefined;
|
|
9
8
|
}>, {
|
|
10
9
|
indent: number;
|
|
11
|
-
|
|
12
|
-
isCtrlKeyDown: boolean;
|
|
10
|
+
emptyText: string;
|
|
13
11
|
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
14
|
-
data:
|
|
15
|
-
|
|
12
|
+
data: TreeNodeData[];
|
|
13
|
+
nodeStatusMap: Map<Id, LayerNodeStatus>;
|
|
16
14
|
indent?: number | undefined;
|
|
17
|
-
|
|
18
|
-
isCtrlKeyDown?: boolean | undefined;
|
|
15
|
+
emptyText?: string | undefined;
|
|
19
16
|
}>, {
|
|
20
17
|
indent: number;
|
|
21
|
-
|
|
22
|
-
isCtrlKeyDown: boolean;
|
|
18
|
+
emptyText: string;
|
|
23
19
|
}>>>, {
|
|
24
|
-
|
|
20
|
+
emptyText: string;
|
|
25
21
|
indent: number;
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
}, {}>, {
|
|
23
|
+
'tree-node-content'(props: {
|
|
24
|
+
data: TreeNodeData;
|
|
25
|
+
}): any;
|
|
26
|
+
'tree-node-tool'(props: {
|
|
27
|
+
data: TreeNodeData;
|
|
28
|
+
}): any;
|
|
29
|
+
}>;
|
|
28
30
|
export default _default;
|
|
29
31
|
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
30
32
|
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Id } from '@tmagic/schema';
|
|
2
|
+
import type { LayerNodeStatus, TreeNodeData } from '../type';
|
|
3
|
+
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
4
|
+
data: TreeNodeData;
|
|
5
|
+
nodeStatusMap: Map<Id, LayerNodeStatus>;
|
|
6
|
+
indent?: number | undefined;
|
|
7
|
+
}>, {
|
|
8
|
+
indent: number;
|
|
9
|
+
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
10
|
+
data: TreeNodeData;
|
|
11
|
+
nodeStatusMap: Map<Id, LayerNodeStatus>;
|
|
12
|
+
indent?: number | undefined;
|
|
13
|
+
}>, {
|
|
14
|
+
indent: number;
|
|
15
|
+
}>>>, {
|
|
16
|
+
indent: number;
|
|
17
|
+
}, {}>, {
|
|
18
|
+
'tree-node-tool'(props: {
|
|
19
|
+
data: TreeNodeData;
|
|
20
|
+
}): any;
|
|
21
|
+
'tree-node-content'(props: {
|
|
22
|
+
data: TreeNodeData;
|
|
23
|
+
}): any;
|
|
24
|
+
}>;
|
|
25
|
+
export default _default;
|
|
26
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
27
|
+
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
28
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
29
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
30
|
+
} : {
|
|
31
|
+
type: import('vue').PropType<T[K]>;
|
|
32
|
+
required: true;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
type __VLS_WithDefaults<P, D> = {
|
|
36
|
+
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
|
|
37
|
+
default: D[K];
|
|
38
|
+
}> : P[K];
|
|
39
|
+
};
|
|
40
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
41
|
+
new (): {
|
|
42
|
+
$slots: S;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
type __VLS_Prettify<T> = {
|
|
46
|
+
[K in keyof T]: T[K];
|
|
47
|
+
} & {};
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
+
import { type DataSourceListSlots } from '../../../type';
|
|
1
2
|
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{}, {
|
|
2
3
|
filter(val: string): void;
|
|
3
|
-
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>,
|
|
4
|
-
"data-source-panel-tool"?(_: {
|
|
5
|
-
id: any;
|
|
6
|
-
data: any;
|
|
7
|
-
}): any;
|
|
8
|
-
}>;
|
|
4
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>, DataSourceListSlots>;
|
|
9
5
|
export default _default;
|
|
10
6
|
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
11
7
|
new (): {
|
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import type { DataSourceListSlots } from '../../../type';
|
|
2
|
+
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>, DataSourceListSlots>;
|
|
2
3
|
export default _default;
|
|
4
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
5
|
+
new (): {
|
|
6
|
+
$slots: S;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { LayerPanelSlots, MenuButton, MenuComponent } from '../../../type';
|
|
2
2
|
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__VLS_TypePropsToRuntimeProps<{
|
|
3
3
|
layerContentMenu: (MenuButton | MenuComponent)[];
|
|
4
4
|
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
|