@tmagic/editor 1.5.7 → 1.5.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 +17 -0
- package/dist/tmagic-editor.js +463 -470
- package/dist/tmagic-editor.umd.cjs +471 -469
- package/package.json +7 -7
- package/src/components/CodeBlockEditor.vue +4 -4
- package/src/components/FloatingBox.vue +4 -4
- package/src/components/ToolButton.vue +6 -4
- package/src/components/TreeNode.vue +2 -2
- package/src/fields/CodeSelect.vue +6 -6
- package/src/fields/CodeSelectCol.vue +5 -4
- package/src/fields/CondOpSelect.vue +5 -4
- package/src/fields/DataSourceFieldSelect/FieldSelect.vue +6 -5
- package/src/fields/DataSourceFieldSelect/Index.vue +4 -3
- package/src/fields/DataSourceFields.vue +3 -3
- package/src/fields/DataSourceInput.vue +4 -4
- package/src/fields/DataSourceMethodSelect.vue +8 -9
- package/src/fields/DataSourceMocks.vue +3 -3
- package/src/fields/DataSourceSelect.vue +6 -5
- package/src/fields/DisplayConds.vue +4 -4
- package/src/fields/EventSelect.vue +17 -23
- package/src/fields/PageFragmentSelect.vue +6 -5
- package/src/fields/UISelect.vue +16 -19
- package/src/hooks/index.ts +1 -0
- package/src/hooks/use-code-block-edit.ts +5 -10
- package/src/hooks/use-data-source-edit.ts +6 -6
- package/src/hooks/use-editor-content-height.ts +5 -5
- package/src/hooks/use-float-box.ts +5 -5
- package/src/hooks/use-next-float-box-position.ts +9 -9
- package/src/hooks/use-services.ts +13 -0
- package/src/hooks/use-stage.ts +2 -6
- package/src/layouts/AddPageBox.vue +3 -7
- package/src/layouts/Framework.vue +27 -27
- package/src/layouts/NavMenu.vue +16 -16
- package/src/layouts/page-bar/AddButton.vue +4 -7
- package/src/layouts/page-bar/PageBar.vue +10 -10
- package/src/layouts/page-bar/PageBarScrollContainer.vue +7 -8
- package/src/layouts/page-bar/PageList.vue +6 -8
- package/src/layouts/props-panel/FormPanel.vue +6 -4
- package/src/layouts/props-panel/PropsPanel.vue +39 -49
- package/src/layouts/props-panel/use-style-panel.ts +35 -19
- package/src/layouts/sidebar/ComponentListPanel.vue +5 -5
- package/src/layouts/sidebar/Sidebar.vue +15 -9
- package/src/layouts/sidebar/code-block/CodeBlockList.vue +13 -18
- package/src/layouts/sidebar/code-block/CodeBlockListPanel.vue +4 -3
- package/src/layouts/sidebar/code-block/useContentMenu.ts +3 -3
- package/src/layouts/sidebar/data-source/DataSourceConfigPanel.vue +5 -5
- package/src/layouts/sidebar/data-source/DataSourceList.vue +13 -17
- package/src/layouts/sidebar/data-source/DataSourceListPanel.vue +6 -12
- package/src/layouts/sidebar/data-source/useContentMenu.ts +3 -3
- package/src/layouts/sidebar/layer/LayerMenu.vue +11 -8
- package/src/layouts/sidebar/layer/LayerNodeTool.vue +2 -6
- package/src/layouts/sidebar/layer/LayerPanel.vue +6 -12
- package/src/layouts/sidebar/layer/use-click.ts +16 -15
- package/src/layouts/sidebar/layer/use-drag.ts +6 -6
- package/src/layouts/sidebar/layer/use-keybinding.ts +6 -8
- package/src/layouts/sidebar/layer/use-node-status.ts +16 -7
- package/src/layouts/workspace/Breadcrumb.vue +8 -9
- package/src/layouts/workspace/Workspace.vue +4 -10
- package/src/layouts/workspace/viewer/NodeListMenu.vue +9 -8
- package/src/layouts/workspace/viewer/Stage.vue +24 -24
- package/src/layouts/workspace/viewer/StageOverlay.vue +15 -16
- package/src/layouts/workspace/viewer/ViewerMenu.vue +15 -14
- package/src/services/dep.ts +23 -8
- package/src/services/ui.ts +6 -2
- package/src/theme/common/var.scss +1 -0
- package/src/theme/sidebar.scss +20 -1
- package/src/type.ts +3 -9
- package/src/utils/const.ts +11 -0
- package/src/utils/content-menu.ts +28 -30
- package/src/utils/idle-task.ts +11 -0
- package/src/utils/index.ts +1 -0
- package/types/index.d.ts +28 -10
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.5.
|
|
2
|
+
"version": "1.5.8",
|
|
3
3
|
"name": "@tmagic/editor",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": [
|
|
@@ -58,11 +58,11 @@
|
|
|
58
58
|
"moveable": "^0.53.0",
|
|
59
59
|
"serialize-javascript": "^6.0.0",
|
|
60
60
|
"sortablejs": "^1.15.2",
|
|
61
|
-
"@tmagic/design": "1.5.
|
|
62
|
-
"@tmagic/form": "1.5.
|
|
63
|
-
"@tmagic/
|
|
64
|
-
"@tmagic/utils": "1.5.
|
|
65
|
-
"@tmagic/
|
|
61
|
+
"@tmagic/design": "1.5.8",
|
|
62
|
+
"@tmagic/form": "1.5.8",
|
|
63
|
+
"@tmagic/table": "1.5.8",
|
|
64
|
+
"@tmagic/utils": "1.5.8",
|
|
65
|
+
"@tmagic/stage": "1.5.8"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"@types/events": "^3.0.0",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"monaco-editor": "^0.48.0",
|
|
77
77
|
"typescript": "*",
|
|
78
78
|
"vue": ">=3.5.0",
|
|
79
|
-
"@tmagic/core": "1.5.
|
|
79
|
+
"@tmagic/core": "1.5.8"
|
|
80
80
|
},
|
|
81
81
|
"peerDependenciesMeta": {
|
|
82
82
|
"typescript": {
|
|
@@ -74,9 +74,9 @@ import {
|
|
|
74
74
|
import FloatingBox from '@editor/components/FloatingBox.vue';
|
|
75
75
|
import { useEditorContentHeight } from '@editor/hooks/use-editor-content-height';
|
|
76
76
|
import { useNextFloatBoxPosition } from '@editor/hooks/use-next-float-box-position';
|
|
77
|
+
import { useServices } from '@editor/hooks/use-services';
|
|
77
78
|
import { useWindowRect } from '@editor/hooks/use-window-rect';
|
|
78
79
|
import CodeEditor from '@editor/layouts/CodeEditor.vue';
|
|
79
|
-
import type { Services } from '@editor/type';
|
|
80
80
|
import { getEditorConfig } from '@editor/utils/config';
|
|
81
81
|
|
|
82
82
|
defineOptions({
|
|
@@ -97,7 +97,7 @@ const emit = defineEmits<{
|
|
|
97
97
|
submit: [values: CodeBlockContent, eventData: ContainerChangeEventData];
|
|
98
98
|
}>();
|
|
99
99
|
|
|
100
|
-
const
|
|
100
|
+
const { codeBlockService, uiService } = useServices();
|
|
101
101
|
|
|
102
102
|
const { height: codeBlockEditorHeight } = useEditorContentHeight();
|
|
103
103
|
|
|
@@ -192,7 +192,7 @@ const functionConfig = computed<FormConfig>(() => [
|
|
|
192
192
|
label: '描述',
|
|
193
193
|
name: 'extra',
|
|
194
194
|
},
|
|
195
|
-
|
|
195
|
+
codeBlockService.getParamsColConfig() || defaultParamColConfig,
|
|
196
196
|
],
|
|
197
197
|
},
|
|
198
198
|
{
|
|
@@ -259,7 +259,7 @@ const closedHandler = () => {
|
|
|
259
259
|
};
|
|
260
260
|
|
|
261
261
|
const parentFloating = inject<Ref<HTMLDivElement | null>>('parentFloating', ref(null));
|
|
262
|
-
const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(
|
|
262
|
+
const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(uiService, parentFloating);
|
|
263
263
|
|
|
264
264
|
defineExpose({
|
|
265
265
|
async show() {
|
|
@@ -17,14 +17,14 @@
|
|
|
17
17
|
</template>
|
|
18
18
|
|
|
19
19
|
<script setup lang="ts">
|
|
20
|
-
import { computed,
|
|
20
|
+
import { computed, nextTick, onBeforeUnmount, provide, ref, useTemplateRef, watch } from 'vue';
|
|
21
21
|
import { Close } from '@element-plus/icons-vue';
|
|
22
22
|
import VanillaMoveable from 'moveable';
|
|
23
23
|
|
|
24
24
|
import { TMagicButton, useZIndex } from '@tmagic/design';
|
|
25
25
|
|
|
26
26
|
import MIcon from '@editor/components/Icon.vue';
|
|
27
|
-
import
|
|
27
|
+
import { useServices } from '@editor/hooks/use-services';
|
|
28
28
|
|
|
29
29
|
interface Position {
|
|
30
30
|
left: number;
|
|
@@ -66,8 +66,8 @@ const bodyHeight = computed(() => {
|
|
|
66
66
|
return 'auto';
|
|
67
67
|
});
|
|
68
68
|
|
|
69
|
-
const
|
|
70
|
-
const frameworkWidth = computed(() =>
|
|
69
|
+
const { uiService } = useServices();
|
|
70
|
+
const frameworkWidth = computed(() => uiService.get('frameworkRect').width || 0);
|
|
71
71
|
const style = computed(() => {
|
|
72
72
|
let { left } = props.position;
|
|
73
73
|
if (width.value) {
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
</template>
|
|
50
50
|
|
|
51
51
|
<script lang="ts" setup>
|
|
52
|
-
import { computed
|
|
52
|
+
import { computed } from 'vue';
|
|
53
53
|
import { ArrowDown } from '@element-plus/icons-vue';
|
|
54
54
|
|
|
55
55
|
import {
|
|
@@ -62,8 +62,10 @@ import {
|
|
|
62
62
|
TMagicTooltip,
|
|
63
63
|
} from '@tmagic/design';
|
|
64
64
|
|
|
65
|
+
import { useServices } from '@editor/hooks/use-services';
|
|
66
|
+
|
|
65
67
|
import MIcon from '../components/Icon.vue';
|
|
66
|
-
import type { MenuButton, MenuComponent
|
|
68
|
+
import type { MenuButton, MenuComponent } from '../type';
|
|
67
69
|
|
|
68
70
|
defineOptions({
|
|
69
71
|
name: 'MEditorToolButton',
|
|
@@ -82,7 +84,7 @@ const props = withDefaults(
|
|
|
82
84
|
eventType: 'click',
|
|
83
85
|
},
|
|
84
86
|
);
|
|
85
|
-
const services =
|
|
87
|
+
const services = useServices();
|
|
86
88
|
|
|
87
89
|
const disabled = computed(() => {
|
|
88
90
|
if (typeof props.data === 'string') return false;
|
|
@@ -104,7 +106,7 @@ const display = computed(() => {
|
|
|
104
106
|
|
|
105
107
|
const buttonHandler = (item: MenuButton | MenuComponent, event: MouseEvent) => {
|
|
106
108
|
if (disabled.value) return;
|
|
107
|
-
if (typeof (item as MenuButton).handler === 'function'
|
|
109
|
+
if (typeof (item as MenuButton).handler === 'function') {
|
|
108
110
|
(item as MenuButton).handler?.(services, event);
|
|
109
111
|
}
|
|
110
112
|
};
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
class="tree-node"
|
|
16
16
|
:class="{ selected, expanded }"
|
|
17
17
|
:style="`padding-left: ${indent}px`"
|
|
18
|
-
@contextmenu="
|
|
18
|
+
@contextmenu="nodeContextmenuHandler"
|
|
19
19
|
@mouseenter="mouseenterHandler"
|
|
20
20
|
>
|
|
21
21
|
<MIcon
|
|
@@ -139,7 +139,7 @@ const handleDragEnd = (event: DragEvent) => {
|
|
|
139
139
|
treeEmit?.('node-dragend', event, props.data);
|
|
140
140
|
};
|
|
141
141
|
|
|
142
|
-
const
|
|
142
|
+
const nodeContextmenuHandler = (event: MouseEvent) => {
|
|
143
143
|
treeEmit?.('node-contextmenu', event, props.data);
|
|
144
144
|
};
|
|
145
145
|
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
</template>
|
|
17
17
|
|
|
18
18
|
<script lang="ts" setup>
|
|
19
|
-
import { computed,
|
|
19
|
+
import { computed, watch } from 'vue';
|
|
20
20
|
import { isEmpty } from 'lodash-es';
|
|
21
21
|
|
|
22
22
|
import { HookCodeType, HookType } from '@tmagic/core';
|
|
@@ -24,7 +24,7 @@ import { TMagicCard } from '@tmagic/design';
|
|
|
24
24
|
import type { ContainerChangeEventData, FieldProps, FormItem, GroupListConfig } from '@tmagic/form';
|
|
25
25
|
import { MContainer } from '@tmagic/form';
|
|
26
26
|
|
|
27
|
-
import
|
|
27
|
+
import { useServices } from '@editor/hooks/use-services';
|
|
28
28
|
|
|
29
29
|
defineOptions({
|
|
30
30
|
name: 'MFieldsCodeSelect',
|
|
@@ -34,7 +34,7 @@ const emit = defineEmits<{
|
|
|
34
34
|
change: [v: any, eventData: ContainerChangeEventData];
|
|
35
35
|
}>();
|
|
36
36
|
|
|
37
|
-
const
|
|
37
|
+
const { dataSourceService, codeBlockService } = useServices();
|
|
38
38
|
|
|
39
39
|
const props = withDefaults(
|
|
40
40
|
defineProps<
|
|
@@ -59,7 +59,7 @@ const codeConfig = computed<GroupListConfig>(() => ({
|
|
|
59
59
|
return index;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
const ds =
|
|
62
|
+
const ds = dataSourceService.getDataSourceById(model.codeId[0]);
|
|
63
63
|
return `${ds?.title} / ${model.codeId[1]}`;
|
|
64
64
|
}
|
|
65
65
|
|
|
@@ -98,7 +98,7 @@ const codeConfig = computed<GroupListConfig>(() => ({
|
|
|
98
98
|
span: 18,
|
|
99
99
|
labelWidth: 0,
|
|
100
100
|
display: (mForm, { model }) => model.codeType !== HookCodeType.DATA_SOURCE_METHOD,
|
|
101
|
-
notEditable: () => !
|
|
101
|
+
notEditable: () => !codeBlockService.getEditStatus(),
|
|
102
102
|
},
|
|
103
103
|
{
|
|
104
104
|
type: 'data-source-method-select',
|
|
@@ -106,7 +106,7 @@ const codeConfig = computed<GroupListConfig>(() => ({
|
|
|
106
106
|
span: 18,
|
|
107
107
|
labelWidth: 0,
|
|
108
108
|
display: (mForm, { model }) => model.codeType === HookCodeType.DATA_SOURCE_METHOD,
|
|
109
|
-
notEditable: () => !
|
|
109
|
+
notEditable: () => !dataSourceService.get('editable'),
|
|
110
110
|
},
|
|
111
111
|
],
|
|
112
112
|
},
|
|
@@ -52,7 +52,8 @@ import {
|
|
|
52
52
|
|
|
53
53
|
import CodeParams from '@editor/components/CodeParams.vue';
|
|
54
54
|
import MIcon from '@editor/components/Icon.vue';
|
|
55
|
-
import
|
|
55
|
+
import { useServices } from '@editor/hooks/use-services';
|
|
56
|
+
import type { CodeParamStatement, CodeSelectColConfig, EventBus } from '@editor/type';
|
|
56
57
|
import { SideItemKey } from '@editor/type';
|
|
57
58
|
|
|
58
59
|
defineOptions({
|
|
@@ -60,7 +61,7 @@ defineOptions({
|
|
|
60
61
|
});
|
|
61
62
|
|
|
62
63
|
const mForm = inject<FormState | undefined>('mForm');
|
|
63
|
-
const
|
|
64
|
+
const { codeBlockService, uiService } = useServices();
|
|
64
65
|
const eventBus = inject<EventBus>('eventBus');
|
|
65
66
|
const emit = defineEmits<{
|
|
66
67
|
change: [v: any, eventData: ContainerChangeEventData];
|
|
@@ -73,7 +74,7 @@ const props = withDefaults(defineProps<FieldProps<CodeSelectColConfig>>(), {
|
|
|
73
74
|
const notEditable = computed(() => filterFunction(mForm, props.config.notEditable, props));
|
|
74
75
|
|
|
75
76
|
const hasCodeBlockSidePanel = computed(() =>
|
|
76
|
-
(
|
|
77
|
+
(uiService.get('sideBarItems') || []).find((item) => item.$key === SideItemKey.CODE_BLOCK),
|
|
77
78
|
);
|
|
78
79
|
|
|
79
80
|
/**
|
|
@@ -94,7 +95,7 @@ const getParamItemsConfig = (codeId?: Id): CodeParamStatement[] => {
|
|
|
94
95
|
}));
|
|
95
96
|
};
|
|
96
97
|
|
|
97
|
-
const codeDsl = computed(() =>
|
|
98
|
+
const codeDsl = computed(() => codeBlockService.getCodeDsl());
|
|
98
99
|
const paramsConfig = ref<CodeParamStatement[]>(getParamItemsConfig(props.model[props.name]));
|
|
99
100
|
|
|
100
101
|
watch(
|
|
@@ -27,12 +27,13 @@
|
|
|
27
27
|
</template>
|
|
28
28
|
|
|
29
29
|
<script setup lang="ts">
|
|
30
|
-
import { computed
|
|
30
|
+
import { computed } from 'vue';
|
|
31
31
|
|
|
32
32
|
import { getDesignConfig, TMagicSelect } from '@tmagic/design';
|
|
33
33
|
import type { FieldProps } from '@tmagic/form';
|
|
34
34
|
|
|
35
|
-
import
|
|
35
|
+
import { useServices } from '@editor/hooks/use-services';
|
|
36
|
+
import type { CondOpSelectConfig } from '@editor/type';
|
|
36
37
|
import { arrayOptions, eqOptions, numberOptions } from '@editor/utils';
|
|
37
38
|
|
|
38
39
|
defineOptions({
|
|
@@ -43,7 +44,7 @@ const emit = defineEmits<{
|
|
|
43
44
|
change: [value: string];
|
|
44
45
|
}>();
|
|
45
46
|
|
|
46
|
-
const { dataSourceService } =
|
|
47
|
+
const { dataSourceService } = useServices();
|
|
47
48
|
|
|
48
49
|
const props = defineProps<FieldProps<CondOpSelectConfig>>();
|
|
49
50
|
|
|
@@ -52,7 +53,7 @@ const optionComponent = getDesignConfig('components')?.option;
|
|
|
52
53
|
const options = computed(() => {
|
|
53
54
|
const [id, ...fieldNames] = [...(props.config.parentFields || []), ...props.model.field];
|
|
54
55
|
|
|
55
|
-
const ds = dataSourceService
|
|
56
|
+
const ds = dataSourceService.getDataSourceById(id);
|
|
56
57
|
|
|
57
58
|
let fields = ds?.fields || [];
|
|
58
59
|
let type = '';
|
|
@@ -69,13 +69,14 @@
|
|
|
69
69
|
import { computed, inject, ref, watch } from 'vue';
|
|
70
70
|
import { Edit, View } from '@element-plus/icons-vue';
|
|
71
71
|
|
|
72
|
-
import { DataSourceFieldType } from '@tmagic/core';
|
|
72
|
+
import type { DataSourceFieldType } from '@tmagic/core';
|
|
73
73
|
import { getDesignConfig, TMagicButton, TMagicCascader, TMagicSelect, TMagicTooltip } from '@tmagic/design';
|
|
74
74
|
import { type FilterFunction, filterFunction, type FormState, type SelectOption } from '@tmagic/form';
|
|
75
75
|
import { DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX } from '@tmagic/utils';
|
|
76
76
|
|
|
77
77
|
import MIcon from '@editor/components/Icon.vue';
|
|
78
|
-
import {
|
|
78
|
+
import { useServices } from '@editor/hooks/use-services';
|
|
79
|
+
import { type EventBus, SideItemKey } from '@editor/type';
|
|
79
80
|
import { getCascaderOptionsFromFields, removeDataSourceFieldPrefix } from '@editor/utils';
|
|
80
81
|
|
|
81
82
|
const props = defineProps<{
|
|
@@ -101,11 +102,11 @@ const modelValue = defineModel<string[] | any>('modelValue', { default: [] });
|
|
|
101
102
|
|
|
102
103
|
const optionComponent = getDesignConfig('components')?.option;
|
|
103
104
|
|
|
104
|
-
const
|
|
105
|
+
const { dataSourceService, uiService } = useServices();
|
|
105
106
|
const mForm = inject<FormState | undefined>('mForm');
|
|
106
107
|
const eventBus = inject<EventBus>('eventBus');
|
|
107
108
|
|
|
108
|
-
const dataSources = computed(() =>
|
|
109
|
+
const dataSources = computed(() => dataSourceService.get('dataSources') || []);
|
|
109
110
|
|
|
110
111
|
const valueIsKey = computed(() => props.value === 'key');
|
|
111
112
|
const notEditable = computed(() => filterFunction(mForm, props.notEditable, props));
|
|
@@ -172,7 +173,7 @@ const onChangeHandler = (v: string[] = []) => {
|
|
|
172
173
|
};
|
|
173
174
|
|
|
174
175
|
const hasDataSourceSidePanel = computed(() =>
|
|
175
|
-
|
|
176
|
+
uiService.get('sideBarItems').find((item) => item.$key === SideItemKey.DATA_SOURCE),
|
|
176
177
|
);
|
|
177
178
|
|
|
178
179
|
const editHandler = (id: string) => {
|
|
@@ -48,7 +48,8 @@ import type { ContainerChangeEventData, FieldProps, FormState } from '@tmagic/fo
|
|
|
48
48
|
import { DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX } from '@tmagic/utils';
|
|
49
49
|
|
|
50
50
|
import MIcon from '@editor/components/Icon.vue';
|
|
51
|
-
import
|
|
51
|
+
import { useServices } from '@editor/hooks/use-services';
|
|
52
|
+
import type { DataSourceFieldSelectConfig } from '@editor/type';
|
|
52
53
|
import { removeDataSourceFieldPrefix } from '@editor/utils';
|
|
53
54
|
|
|
54
55
|
import FieldSelect from './FieldSelect.vue';
|
|
@@ -83,10 +84,10 @@ watch(
|
|
|
83
84
|
},
|
|
84
85
|
);
|
|
85
86
|
|
|
86
|
-
const
|
|
87
|
+
const { dataSourceService } = useServices();
|
|
87
88
|
const mForm = inject<FormState | undefined>('mForm');
|
|
88
89
|
|
|
89
|
-
const dataSources = computed(() =>
|
|
90
|
+
const dataSources = computed(() => dataSourceService.get('dataSources') || []);
|
|
90
91
|
|
|
91
92
|
const type = computed((): string => {
|
|
92
93
|
let type = props.config.fieldConfig?.type;
|
|
@@ -64,7 +64,7 @@ import { getDefaultValueFromFields } from '@tmagic/utils';
|
|
|
64
64
|
import FloatingBox from '@editor/components/FloatingBox.vue';
|
|
65
65
|
import { useEditorContentHeight } from '@editor/hooks';
|
|
66
66
|
import { useNextFloatBoxPosition } from '@editor/hooks/use-next-float-box-position';
|
|
67
|
-
import
|
|
67
|
+
import { useServices } from '@editor/hooks/use-services';
|
|
68
68
|
|
|
69
69
|
defineOptions({
|
|
70
70
|
name: 'MFieldsDataSourceFields',
|
|
@@ -85,7 +85,7 @@ const emit = defineEmits<{
|
|
|
85
85
|
change: [v: any, eventData?: ContainerChangeEventData];
|
|
86
86
|
}>();
|
|
87
87
|
|
|
88
|
-
const
|
|
88
|
+
const { uiService } = useServices();
|
|
89
89
|
|
|
90
90
|
const fieldValues = ref<Record<string, any>>({});
|
|
91
91
|
const fieldTitle = ref('');
|
|
@@ -344,5 +344,5 @@ const addFromJsonDialogVisible = defineModel<boolean>('visible1', { default: fal
|
|
|
344
344
|
const { height: editorHeight } = useEditorContentHeight();
|
|
345
345
|
|
|
346
346
|
const parentFloating = inject<Ref<HTMLDivElement | null>>('parentFloating', ref(null));
|
|
347
|
-
const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(
|
|
347
|
+
const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(uiService, parentFloating);
|
|
348
348
|
</script>
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
</template>
|
|
49
49
|
|
|
50
50
|
<script setup lang="ts">
|
|
51
|
-
import { computed,
|
|
51
|
+
import { computed, nextTick, ref, useTemplateRef, watch } from 'vue';
|
|
52
52
|
import { Coin } from '@element-plus/icons-vue';
|
|
53
53
|
|
|
54
54
|
import type { DataSchema, DataSourceSchema } from '@tmagic/core';
|
|
@@ -57,7 +57,7 @@ import type { FieldProps, FormItem } from '@tmagic/form';
|
|
|
57
57
|
import { getKeysArray, isNumber } from '@tmagic/utils';
|
|
58
58
|
|
|
59
59
|
import Icon from '@editor/components/Icon.vue';
|
|
60
|
-
import
|
|
60
|
+
import { useServices } from '@editor/hooks/use-services';
|
|
61
61
|
import { getDisplayField } from '@editor/utils/data-source';
|
|
62
62
|
|
|
63
63
|
defineOptions({
|
|
@@ -81,7 +81,7 @@ const emit = defineEmits<{
|
|
|
81
81
|
change: [value: string];
|
|
82
82
|
}>();
|
|
83
83
|
|
|
84
|
-
const { dataSourceService } =
|
|
84
|
+
const { dataSourceService } = useServices();
|
|
85
85
|
|
|
86
86
|
const autocompleteRef = useTemplateRef<InstanceType<typeof TMagicAutocomplete>>('autocomplete');
|
|
87
87
|
const isFocused = ref(false);
|
|
@@ -89,7 +89,7 @@ const state = ref('');
|
|
|
89
89
|
const displayState = ref<{ value: string; type: 'var' | 'text' }[]>([]);
|
|
90
90
|
|
|
91
91
|
const input = computed<HTMLInputElement>(() => autocompleteRef.value?.inputRef?.input);
|
|
92
|
-
const dataSources = computed(() => dataSourceService
|
|
92
|
+
const dataSources = computed(() => dataSourceService.get('dataSources'));
|
|
93
93
|
|
|
94
94
|
const setDisplayState = () => {
|
|
95
95
|
displayState.value = getDisplayField(dataSources.value, state.value);
|
|
@@ -41,37 +41,36 @@ import { createValues, type FieldProps, filterFunction, type FormState, MContain
|
|
|
41
41
|
|
|
42
42
|
import CodeParams from '@editor/components/CodeParams.vue';
|
|
43
43
|
import MIcon from '@editor/components/Icon.vue';
|
|
44
|
-
import
|
|
44
|
+
import { useServices } from '@editor/hooks/use-services';
|
|
45
|
+
import type { CodeParamStatement, DataSourceMethodSelectConfig, EventBus } from '@editor/type';
|
|
45
46
|
import { SideItemKey } from '@editor/type';
|
|
46
47
|
|
|
47
48
|
defineOptions({
|
|
48
49
|
name: 'MFieldsDataSourceMethodSelect',
|
|
49
50
|
});
|
|
50
51
|
|
|
52
|
+
const { dataSourceService, uiService } = useServices();
|
|
51
53
|
const mForm = inject<FormState | undefined>('mForm');
|
|
52
|
-
const services = inject<Services>('services');
|
|
53
54
|
const eventBus = inject<EventBus>('eventBus');
|
|
54
55
|
|
|
55
56
|
const emit = defineEmits(['change']);
|
|
56
57
|
|
|
57
|
-
const dataSourceService = services?.dataSourceService;
|
|
58
|
-
|
|
59
58
|
const props = withDefaults(defineProps<FieldProps<DataSourceMethodSelectConfig>>(), {
|
|
60
59
|
disabled: false,
|
|
61
60
|
});
|
|
62
61
|
|
|
63
62
|
const hasDataSourceSidePanel = computed(() =>
|
|
64
|
-
(
|
|
63
|
+
(uiService.get('sideBarItems') || []).find((item) => item.$key === SideItemKey.DATA_SOURCE),
|
|
65
64
|
);
|
|
66
65
|
|
|
67
66
|
const notEditable = computed(() => filterFunction(mForm, props.config.notEditable, props));
|
|
68
67
|
|
|
69
|
-
const dataSources = computed(() => dataSourceService
|
|
68
|
+
const dataSources = computed(() => dataSourceService.get('dataSources'));
|
|
70
69
|
|
|
71
70
|
const isCustomMethod = computed(() => {
|
|
72
71
|
const [id, name] = props.model[props.name];
|
|
73
72
|
|
|
74
|
-
const dataSource = dataSourceService
|
|
73
|
+
const dataSource = dataSourceService.getDataSourceById(id);
|
|
75
74
|
|
|
76
75
|
return Boolean(dataSource?.methods.find((method) => method.name === name));
|
|
77
76
|
});
|
|
@@ -107,7 +106,7 @@ const setParamsConfig = (dataSourceMethod: [Id, string], formState: any = {}) =>
|
|
|
107
106
|
const methodsOptions = computed(
|
|
108
107
|
() =>
|
|
109
108
|
dataSources.value
|
|
110
|
-
?.filter((ds) => ds.methods?.length || dataSourceService
|
|
109
|
+
?.filter((ds) => ds.methods?.length || dataSourceService.getFormMethod(ds.type).length)
|
|
111
110
|
?.map((ds) => ({
|
|
112
111
|
label: ds.title || ds.id,
|
|
113
112
|
value: ds.id,
|
|
@@ -144,7 +143,7 @@ const onChangeHandler = (value: any) => {
|
|
|
144
143
|
const editCodeHandler = () => {
|
|
145
144
|
const [id] = props.model[props.name];
|
|
146
145
|
|
|
147
|
-
const dataSource = dataSourceService
|
|
146
|
+
const dataSource = dataSourceService.getDataSourceById(id);
|
|
148
147
|
|
|
149
148
|
if (!dataSource) return;
|
|
150
149
|
|
|
@@ -38,8 +38,8 @@ import { getDefaultValueFromFields } from '@tmagic/utils';
|
|
|
38
38
|
|
|
39
39
|
import FloatingBox from '@editor/components/FloatingBox.vue';
|
|
40
40
|
import { useNextFloatBoxPosition } from '@editor/hooks/use-next-float-box-position';
|
|
41
|
+
import { useServices } from '@editor/hooks/use-services';
|
|
41
42
|
import CodeEditor from '@editor/layouts/CodeEditor.vue';
|
|
42
|
-
import { Services } from '@editor/type';
|
|
43
43
|
|
|
44
44
|
import { useEditorContentHeight } from '..';
|
|
45
45
|
|
|
@@ -60,7 +60,7 @@ const props = withDefaults(
|
|
|
60
60
|
|
|
61
61
|
const emit = defineEmits(['change']);
|
|
62
62
|
|
|
63
|
-
const
|
|
63
|
+
const { uiService } = useServices();
|
|
64
64
|
const width = defineModel<number>('width', { default: 670 });
|
|
65
65
|
|
|
66
66
|
const drawerTitle = ref('');
|
|
@@ -250,5 +250,5 @@ const toggleValue = (row: MockSchema, key: 'enable' | 'useInEditor', value: bool
|
|
|
250
250
|
const addDialogVisible = defineModel<boolean>('visible', { default: false });
|
|
251
251
|
const { height: editorHeight } = useEditorContentHeight();
|
|
252
252
|
const parentFloating = inject<Ref<HTMLDivElement | null>>('parentFloating', ref(null));
|
|
253
|
-
const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(
|
|
253
|
+
const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(uiService, parentFloating);
|
|
254
254
|
</script>
|
|
@@ -27,7 +27,8 @@ import { TMagicButton, TMagicTooltip } from '@tmagic/design';
|
|
|
27
27
|
import { type FieldProps, filterFunction, type FormState, MSelect, type SelectConfig } from '@tmagic/form';
|
|
28
28
|
|
|
29
29
|
import MIcon from '@editor/components/Icon.vue';
|
|
30
|
-
import
|
|
30
|
+
import { useServices } from '@editor/hooks/use-services';
|
|
31
|
+
import type { DataSourceSelect, EventBus } from '@editor/type';
|
|
31
32
|
import { SideItemKey } from '@editor/type';
|
|
32
33
|
|
|
33
34
|
defineOptions({
|
|
@@ -41,15 +42,15 @@ const props = withDefaults(defineProps<FieldProps<DataSourceSelect>>(), {
|
|
|
41
42
|
});
|
|
42
43
|
|
|
43
44
|
const mForm = inject<FormState | undefined>('mForm');
|
|
44
|
-
const { dataSourceService, uiService } =
|
|
45
|
+
const { dataSourceService, uiService } = useServices();
|
|
45
46
|
const eventBus = inject<EventBus>('eventBus');
|
|
46
47
|
|
|
47
|
-
const dataSources = computed(() => dataSourceService
|
|
48
|
+
const dataSources = computed(() => dataSourceService.get('dataSources'));
|
|
48
49
|
|
|
49
50
|
const notEditable = computed(() => filterFunction(mForm, props.config.notEditable, props));
|
|
50
51
|
|
|
51
52
|
const hasDataSourceSidePanel = computed(() =>
|
|
52
|
-
|
|
53
|
+
uiService.get('sideBarItems').find((item) => item.$key === SideItemKey.DATA_SOURCE),
|
|
53
54
|
);
|
|
54
55
|
|
|
55
56
|
const selectConfig = computed<SelectConfig>(() => {
|
|
@@ -87,7 +88,7 @@ const editHandler = () => {
|
|
|
87
88
|
|
|
88
89
|
const id = typeof value === 'string' ? value : value.dataSourceId;
|
|
89
90
|
|
|
90
|
-
const dataSource = dataSourceService
|
|
91
|
+
const dataSource = dataSourceService.getDataSourceById(id);
|
|
91
92
|
|
|
92
93
|
if (!dataSource) return;
|
|
93
94
|
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
MGroupList,
|
|
27
27
|
} from '@tmagic/form';
|
|
28
28
|
|
|
29
|
-
import
|
|
29
|
+
import { useServices } from '@editor/hooks/use-services';
|
|
30
30
|
import { getCascaderOptionsFromFields } from '@editor/utils';
|
|
31
31
|
|
|
32
32
|
defineOptions({
|
|
@@ -49,7 +49,7 @@ const props = withDefaults(
|
|
|
49
49
|
},
|
|
50
50
|
);
|
|
51
51
|
|
|
52
|
-
const { dataSourceService } =
|
|
52
|
+
const { dataSourceService } = useServices();
|
|
53
53
|
const mForm = inject<FormState | undefined>('mForm');
|
|
54
54
|
|
|
55
55
|
const parentFields = computed(() => filterFunction<string[]>(mForm, props.config.parentFields, props) || []);
|
|
@@ -71,7 +71,7 @@ const config = computed<GroupListConfig>(() => ({
|
|
|
71
71
|
type: 'cascader',
|
|
72
72
|
options: () => {
|
|
73
73
|
const [dsId, ...keys] = parentFields.value;
|
|
74
|
-
const ds = dataSourceService
|
|
74
|
+
const ds = dataSourceService.getDataSourceById(dsId);
|
|
75
75
|
if (!ds) {
|
|
76
76
|
return [];
|
|
77
77
|
}
|
|
@@ -113,7 +113,7 @@ const config = computed<GroupListConfig>(() => ({
|
|
|
113
113
|
type: (mForm, { model }) => {
|
|
114
114
|
const [id, ...fieldNames] = [...parentFields.value, ...model.field];
|
|
115
115
|
|
|
116
|
-
const ds = dataSourceService
|
|
116
|
+
const ds = dataSourceService.getDataSourceById(id);
|
|
117
117
|
|
|
118
118
|
let fields = ds?.fields || [];
|
|
119
119
|
let type = '';
|