@tmagic/editor 1.8.0-beta.7 → 1.8.0-manmanyu.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/es/Editor.vue_vue_type_script_setup_true_lang.js +13 -3
- package/dist/es/components/CompareForm.vue_vue_type_script_setup_true_lang.js +6 -5
- package/dist/es/components/ContentMenu.vue_vue_type_script_setup_true_lang.js +11 -4
- package/dist/es/components/FloatingBox.vue_vue_type_script_setup_true_lang.js +9 -4
- package/dist/es/fields/Code.vue_vue_type_script_setup_true_lang.js +4 -1
- package/dist/es/fields/CodeLink.vue_vue_type_script_setup_true_lang.js +4 -1
- package/dist/es/fields/CodeSelect.vue_vue_type_script_setup_true_lang.js +68 -43
- package/dist/es/fields/CodeSelectCol.vue_vue_type_script_setup_true_lang.js +5 -1
- package/dist/es/fields/CondOpSelect.vue_vue_type_script_setup_true_lang.js +4 -1
- package/dist/es/fields/DataSourceFieldSelect/Index.vue_vue_type_script_setup_true_lang.js +10 -7
- package/dist/es/fields/DataSourceFields.vue_vue_type_script_setup_true_lang.js +4 -1
- package/dist/es/fields/DataSourceInput.vue_vue_type_script_setup_true_lang.js +4 -1
- package/dist/es/fields/DataSourceMethodSelect.vue_vue_type_script_setup_true_name_true_lang.js +4 -1
- package/dist/es/fields/DataSourceMethods.vue_vue_type_script_setup_true_lang.js +4 -1
- package/dist/es/fields/DataSourceMocks.vue_vue_type_script_setup_true_lang.js +4 -1
- package/dist/es/fields/DataSourceSelect.vue_vue_type_script_setup_true_lang.js +4 -1
- package/dist/es/fields/DisplayConds.vue_vue_type_script_setup_true_lang.js +8 -2
- package/dist/es/fields/EventSelect.vue_vue_type_script_setup_true_lang.js +101 -64
- package/dist/es/fields/KeyValue.vue_vue_type_script_setup_true_lang.js +4 -1
- package/dist/es/fields/PageFragmentSelect.vue_vue_type_script_setup_true_lang.js +4 -1
- package/dist/es/fields/StyleSetter/Index.vue_vue_type_script_setup_true_lang.js +5 -4
- package/dist/es/fields/StyleSetter/components/BackgroundPosition.vue_vue_type_script_setup_true_lang.js +4 -1
- package/dist/es/fields/StyleSetter/components/Border.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/fields/StyleSetter/icons/align-items/Center.js +31 -0
- package/dist/es/fields/StyleSetter/icons/align-items/FlexEnd.js +31 -0
- package/dist/es/fields/StyleSetter/icons/align-items/FlexStart.js +31 -0
- package/dist/es/fields/StyleSetter/icons/align-items/SpaceAround.js +50 -0
- package/dist/es/fields/StyleSetter/icons/align-items/SpaceBetween.js +50 -0
- package/dist/es/fields/StyleSetter/icons/background-repeat/NoRepeat.js +6 -6
- package/dist/es/fields/StyleSetter/icons/background-repeat/Repeat.js +5 -2
- package/dist/es/fields/StyleSetter/icons/background-repeat/RepeatX.js +28 -5
- package/dist/es/fields/StyleSetter/icons/background-repeat/RepeatY.js +31 -5
- package/dist/es/fields/StyleSetter/icons/flex-direction/Column.js +10 -2
- package/dist/es/fields/StyleSetter/icons/flex-direction/ColumnReverse.js +10 -2
- package/dist/es/fields/StyleSetter/icons/flex-direction/Row.js +10 -2
- package/dist/es/fields/StyleSetter/icons/flex-direction/RowReverse.js +10 -2
- package/dist/es/fields/StyleSetter/icons/justify-content/Center.js +16 -2
- package/dist/es/fields/StyleSetter/icons/justify-content/FlexEnd.js +18 -2
- package/dist/es/fields/StyleSetter/icons/justify-content/FlexStart.js +18 -2
- package/dist/es/fields/StyleSetter/icons/justify-content/SpaceAround.js +36 -2
- package/dist/es/fields/StyleSetter/icons/justify-content/SpaceBetween.js +32 -2
- package/dist/es/fields/StyleSetter/pro/Background.vue_vue_type_script_setup_true_lang.js +11 -6
- package/dist/es/fields/StyleSetter/pro/Font.vue_vue_type_script_setup_true_lang.js +6 -3
- package/dist/es/fields/StyleSetter/pro/Layout.vue_vue_type_script_setup_true_lang.js +82 -46
- package/dist/es/fields/UISelect.vue_vue_type_script_setup_true_lang.js +4 -1
- package/dist/es/icons/DatasourceIcon.js +17 -0
- package/dist/es/index.js +5 -3
- package/dist/es/layouts/Framework.vue_vue_type_script_setup_true_lang.js +14 -10
- package/dist/es/layouts/history-list/GroupRow.vue_vue_type_script_setup_true_lang.js +38 -26
- package/dist/es/layouts/history-list/HistoryDiffDialog.vue_vue_type_script_setup_true_lang.js +5 -1
- package/dist/es/layouts/history-list/HistoryListPanel.vue_vue_type_script_setup_true_lang.js +135 -288
- package/dist/es/layouts/history-list/composables.js +23 -55
- package/dist/es/layouts/history-list/useHistoryList.js +56 -0
- package/dist/es/layouts/history-list/useHistoryRevert.js +304 -0
- package/dist/es/services/history.js +18 -1
- package/dist/es/style.css +306 -37
- package/dist/es/utils/const.js +1 -1
- package/dist/es/utils/props.js +137 -31
- package/dist/style.css +306 -37
- package/dist/themes/magic-admin.css +2316 -0
- package/dist/tmagic-editor.umd.cjs +4427 -2871
- package/package.json +7 -7
- package/src/Editor.vue +13 -1
- package/src/components/CompareForm.vue +14 -6
- package/src/components/ContentMenu.vue +10 -2
- package/src/components/FloatingBox.vue +13 -2
- package/src/editorProps.ts +9 -0
- package/src/fields/CodeSelect.vue +51 -40
- package/src/fields/CodeSelectCol.vue +1 -0
- package/src/fields/DataSourceFieldSelect/Index.vue +14 -5
- package/src/fields/DisplayConds.vue +4 -1
- package/src/fields/EventSelect.vue +58 -32
- package/src/fields/StyleSetter/Index.vue +1 -4
- package/src/fields/StyleSetter/components/Border.vue +1 -1
- package/src/fields/StyleSetter/icons/align-items/Center.vue +19 -0
- package/src/fields/StyleSetter/icons/align-items/FlexEnd.vue +19 -0
- package/src/fields/StyleSetter/icons/align-items/FlexStart.vue +19 -0
- package/src/fields/StyleSetter/icons/align-items/SpaceAround.vue +34 -0
- package/src/fields/StyleSetter/icons/align-items/SpaceBetween.vue +34 -0
- package/src/fields/StyleSetter/icons/align-items/index copy.ts +5 -0
- package/src/fields/StyleSetter/icons/align-items/index.ts +5 -0
- package/src/fields/StyleSetter/icons/background-repeat/NoRepeat.vue +20 -4
- package/src/fields/StyleSetter/icons/background-repeat/Repeat.vue +10 -28
- package/src/fields/StyleSetter/icons/background-repeat/RepeatX.vue +4 -5
- package/src/fields/StyleSetter/icons/background-repeat/RepeatY.vue +4 -5
- package/src/fields/StyleSetter/icons/flex-direction/Column.vue +4 -3
- package/src/fields/StyleSetter/icons/flex-direction/ColumnReverse.vue +4 -3
- package/src/fields/StyleSetter/icons/flex-direction/Row.vue +4 -3
- package/src/fields/StyleSetter/icons/flex-direction/RowReverse.vue +4 -3
- package/src/fields/StyleSetter/icons/justify-content/Center.vue +5 -2
- package/src/fields/StyleSetter/icons/justify-content/FlexEnd.vue +15 -2
- package/src/fields/StyleSetter/icons/justify-content/FlexStart.vue +15 -2
- package/src/fields/StyleSetter/icons/justify-content/SpaceAround.vue +28 -3
- package/src/fields/StyleSetter/icons/justify-content/SpaceBetween.vue +28 -2
- package/src/fields/StyleSetter/pro/Background.vue +11 -5
- package/src/fields/StyleSetter/pro/Font.vue +3 -3
- package/src/fields/StyleSetter/pro/Layout.vue +105 -28
- package/src/fields/UISelect.vue +1 -1
- package/src/icons/DatasourceIcon.vue +7 -0
- package/src/index.ts +2 -0
- package/src/layouts/Framework.vue +7 -1
- package/src/layouts/NavMenu.vue +2 -2
- package/src/layouts/history-list/GroupRow.vue +10 -0
- package/src/layouts/history-list/HistoryDiffDialog.vue +6 -1
- package/src/layouts/history-list/HistoryListPanel.vue +53 -250
- package/src/layouts/history-list/PageTab.vue +4 -4
- package/src/layouts/history-list/composables.ts +52 -90
- package/src/layouts/history-list/useHistoryList.ts +60 -0
- package/src/layouts/history-list/useHistoryRevert.ts +400 -0
- package/src/services/codeBlock.ts +30 -29
- package/src/services/dataSource.ts +37 -37
- package/src/services/editor.ts +32 -29
- package/src/services/history.ts +340 -430
- package/src/theme/code-block.scss +37 -0
- package/src/theme/common/var.scss +1 -1
- package/src/theme/component-list-panel.scss +2 -2
- package/src/theme/data-source-field.scss +4 -0
- package/src/theme/display-conds.scss +11 -0
- package/src/theme/event.scss +55 -1
- package/src/theme/history-list-panel.scss +23 -9
- package/src/theme/props-panel.scss +2 -1
- package/src/theme/style-setter/border.scss +14 -5
- package/src/theme/theme.scss +1 -0
- package/src/theme/themes/magic-admin/index.scss +125 -0
- package/src/type.ts +174 -92
- package/src/utils/const.ts +2 -1
- package/src/utils/history.ts +52 -67
- package/src/utils/props.ts +138 -9
- package/types/index.d.ts +156 -13
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.8.0-
|
|
2
|
+
"version": "1.8.0-manmanyu.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": "^7.0.0",
|
|
60
60
|
"sortablejs": "^1.15.6",
|
|
61
|
-
"@tmagic/
|
|
62
|
-
"@tmagic/
|
|
63
|
-
"@tmagic/
|
|
64
|
-
"@tmagic/
|
|
65
|
-
"@tmagic/stage": "1.8.0-
|
|
61
|
+
"@tmagic/design": "1.8.0-manmanyu.8",
|
|
62
|
+
"@tmagic/form": "1.8.0-manmanyu.8",
|
|
63
|
+
"@tmagic/utils": "1.8.0-manmanyu.8",
|
|
64
|
+
"@tmagic/table": "1.8.0-manmanyu.8",
|
|
65
|
+
"@tmagic/stage": "1.8.0-manmanyu.8"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"@types/events": "^3.0.3",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"type-fest": "^5.2.0",
|
|
77
77
|
"typescript": "^6.0.3",
|
|
78
78
|
"vue": "^3.5.34",
|
|
79
|
-
"@tmagic/core": "1.8.0-
|
|
79
|
+
"@tmagic/core": "1.8.0-manmanyu.8"
|
|
80
80
|
},
|
|
81
81
|
"peerDependenciesMeta": {
|
|
82
82
|
"typescript": {
|
package/src/Editor.vue
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
:page-bar-sort-options="pageBarSortOptions"
|
|
5
5
|
:page-filter-function="pageFilterFunction"
|
|
6
6
|
:hide-sidebar="hideSidebar"
|
|
7
|
+
:theme="theme"
|
|
7
8
|
>
|
|
8
9
|
<template #header>
|
|
9
10
|
<slot name="header"></slot>
|
|
@@ -135,9 +136,10 @@
|
|
|
135
136
|
<script lang="ts" setup>
|
|
136
137
|
import { EventEmitter } from 'events';
|
|
137
138
|
|
|
138
|
-
import { provide } from 'vue';
|
|
139
|
+
import { computed, provide } from 'vue';
|
|
139
140
|
|
|
140
141
|
import type { MApp } from '@tmagic/core';
|
|
142
|
+
import { M_THEME_KEY } from '@tmagic/design';
|
|
141
143
|
|
|
142
144
|
import Framework from './layouts/Framework.vue';
|
|
143
145
|
import TMagicNavMenu from './layouts/NavMenu.vue';
|
|
@@ -247,6 +249,16 @@ provide('historyListExtraTabs', props.historyListExtraTabs);
|
|
|
247
249
|
|
|
248
250
|
provide<EventBus>('eventBus', new EventEmitter());
|
|
249
251
|
|
|
252
|
+
/**
|
|
253
|
+
* 把当前主题以响应式 ref 形式 provide 给后代,供包含 `Teleport` 的组件
|
|
254
|
+
* (如 `TMagicPopover` / `FloatingBox` / `ContentMenu`)在传送目标上挂 `m-theme--<theme>`
|
|
255
|
+
* 类,让主题级 CSS 变量在 portal 节点上也能命中。详见 `@tmagic/design/theme.ts`。
|
|
256
|
+
*/
|
|
257
|
+
provide(
|
|
258
|
+
M_THEME_KEY,
|
|
259
|
+
computed(() => props.theme ?? ''),
|
|
260
|
+
);
|
|
261
|
+
|
|
250
262
|
const propsPanelMountedHandler = (e: InstanceType<typeof FormPanel>) => {
|
|
251
263
|
emit('props-panel-mounted', e);
|
|
252
264
|
};
|
|
@@ -17,14 +17,14 @@
|
|
|
17
17
|
</template>
|
|
18
18
|
|
|
19
19
|
<script lang="ts" setup>
|
|
20
|
-
import { computed, inject, type Ref, ref, type ShallowRef, useTemplateRef, watch, watchEffect } from 'vue';
|
|
20
|
+
import { computed, inject, provide, type Ref, ref, type ShallowRef, useTemplateRef, watch, watchEffect } from 'vue';
|
|
21
21
|
import { isEqual } from 'lodash-es';
|
|
22
22
|
|
|
23
23
|
import { type CodeBlockContent, type DataSourceSchema, HookType, type MNode } from '@tmagic/core';
|
|
24
24
|
import { type FormConfig, type FormState, type FormValue, MForm } from '@tmagic/form';
|
|
25
25
|
|
|
26
26
|
import { useServices } from '@editor/hooks/use-services';
|
|
27
|
-
import type { CompareCategory, CompareFormLoadConfig } from '@editor/type';
|
|
27
|
+
import type { CompareCategory, CompareFormLoadConfig, Services } from '@editor/type';
|
|
28
28
|
import { getCodeBlockFormConfig } from '@editor/utils/code-block';
|
|
29
29
|
|
|
30
30
|
defineOptions({
|
|
@@ -67,15 +67,19 @@ const props = withDefaults(
|
|
|
67
67
|
* `ctx.defaultLoadConfig()` 复用默认结果再做二次加工。返回的 config 直接用于对比展示。
|
|
68
68
|
*/
|
|
69
69
|
loadConfig?: CompareFormLoadConfig;
|
|
70
|
+
/** 编辑器服务集合,由调用方传入(不再通过 inject('services') 获取)。 */
|
|
71
|
+
services: Services;
|
|
70
72
|
}>(),
|
|
71
73
|
{
|
|
72
74
|
category: 'node',
|
|
73
75
|
labelWidth: '120px',
|
|
76
|
+
services: () => useServices(),
|
|
74
77
|
},
|
|
75
78
|
);
|
|
76
79
|
|
|
77
|
-
const { propsService, dataSourceService, codeBlockService, editorService } =
|
|
78
|
-
|
|
80
|
+
const { propsService, dataSourceService, codeBlockService, editorService } = props.services;
|
|
81
|
+
|
|
82
|
+
provide('services', props.services);
|
|
79
83
|
|
|
80
84
|
const config = ref<FormConfig>([]);
|
|
81
85
|
|
|
@@ -185,7 +189,11 @@ const defaultLoadConfig = async (): Promise<FormConfig> => {
|
|
|
185
189
|
);
|
|
186
190
|
}
|
|
187
191
|
case 'data-source': {
|
|
188
|
-
|
|
192
|
+
const config = dataSourceService.getFormConfig(props.type || 'base');
|
|
193
|
+
// 数据源表单外层 tab 的「数据定义」项 status 为 'fields',tab-pane name 随之为 'fields'。
|
|
194
|
+
// 未显式设置 active 时,Tabs 默认取 '0',与 'fields' 不匹配会导致打开弹窗时无默认激活项,
|
|
195
|
+
// 这里与 DataSourceConfigPanel 保持一致,默认激活「数据定义」tab。
|
|
196
|
+
return config.map((item) => ('type' in item && item.type === 'tab' ? { ...item, active: 'fields' } : item));
|
|
189
197
|
}
|
|
190
198
|
case 'code-block': {
|
|
191
199
|
return getCodeBlockFormConfig({
|
|
@@ -242,7 +250,7 @@ const stage = computed(() => editorService.get('stage'));
|
|
|
242
250
|
watchEffect(() => {
|
|
243
251
|
if (formRef.value) {
|
|
244
252
|
formRef.value.formState.stage = stage.value;
|
|
245
|
-
formRef.value.formState.services = services;
|
|
253
|
+
formRef.value.formState.services = props.services;
|
|
246
254
|
}
|
|
247
255
|
});
|
|
248
256
|
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
<transition name="fade">
|
|
3
3
|
<div
|
|
4
4
|
v-show="visible"
|
|
5
|
-
class="magic-editor-content-menu"
|
|
6
5
|
ref="menu"
|
|
6
|
+
:class="['magic-editor-content-menu', themeClass]"
|
|
7
7
|
:style="menuStyle"
|
|
8
8
|
@mouseenter="mouseenterHandler()"
|
|
9
9
|
@contextmenu.prevent
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
<script lang="ts" setup>
|
|
40
40
|
import { computed, nextTick, onBeforeUnmount, onMounted, type Ref, ref, useTemplateRef } from 'vue';
|
|
41
41
|
|
|
42
|
-
import { useZIndex } from '@tmagic/design';
|
|
42
|
+
import { useThemeClass, useZIndex } from '@tmagic/design';
|
|
43
43
|
|
|
44
44
|
import { MenuButton, MenuComponent } from '@editor/type';
|
|
45
45
|
|
|
@@ -73,6 +73,14 @@ const menuEl = useTemplateRef<HTMLDivElement>('menu');
|
|
|
73
73
|
const buttonRefs = useTemplateRef<InstanceType<typeof ToolButton>[]>('buttons');
|
|
74
74
|
const subMenuRef = useTemplateRef<any>('subMenu');
|
|
75
75
|
const visible = ref(false);
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* 主题修饰类(来自最近的 `<MEditor>` / `<MForm>` 祖先 provide)。
|
|
79
|
+
* - 顶层 `ContentMenu` 渲染在编辑器子树中,加上去是冗余但无害;
|
|
80
|
+
* - 子菜单(递归 `<content-menu :is-sub-menu="true">` 被 `<teleport to="body">` 送到 body)
|
|
81
|
+
* 不在编辑器子树中,必须显式挂上主题类,主题级 CSS 变量才能命中。
|
|
82
|
+
*/
|
|
83
|
+
const themeClass = useThemeClass();
|
|
76
84
|
const subMenuData: Ref<(MenuButton | MenuComponent)[]> = ref<(MenuButton | MenuComponent)[]>([]);
|
|
77
85
|
const zIndex = useZIndex();
|
|
78
86
|
const curZIndex = ref<number>(0);
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<Teleport to="body" v-if="visible">
|
|
3
|
-
<div
|
|
3
|
+
<div
|
|
4
|
+
ref="target"
|
|
5
|
+
:class="['m-editor-float-box', themeClass]"
|
|
6
|
+
:style="{ ...style, zIndex: curZIndex }"
|
|
7
|
+
@mousedown="nextZIndex"
|
|
8
|
+
>
|
|
4
9
|
<div ref="title" class="m-editor-float-box-title">
|
|
5
10
|
<slot name="title">
|
|
6
11
|
<span>{{ title }}</span>
|
|
@@ -21,7 +26,7 @@ import { computed, nextTick, onBeforeUnmount, provide, ref, useTemplateRef, watc
|
|
|
21
26
|
import { Close } from '@element-plus/icons-vue';
|
|
22
27
|
import VanillaMoveable from 'moveable';
|
|
23
28
|
|
|
24
|
-
import { TMagicButton, useZIndex } from '@tmagic/design';
|
|
29
|
+
import { TMagicButton, useThemeClass, useZIndex } from '@tmagic/design';
|
|
25
30
|
|
|
26
31
|
import MIcon from '@editor/components/Icon.vue';
|
|
27
32
|
import { useServices } from '@editor/hooks/use-services';
|
|
@@ -50,6 +55,12 @@ const props = withDefaults(
|
|
|
50
55
|
const targetEl = useTemplateRef<HTMLDivElement>('target');
|
|
51
56
|
const titleEl = useTemplateRef<HTMLDivElement>('title');
|
|
52
57
|
|
|
58
|
+
/**
|
|
59
|
+
* 主题修饰类(来自最近的 `<MEditor>` / `<MForm>` 祖先 provide)。
|
|
60
|
+
* 挂在 `Teleport` 出去的浮动面板根节点上,让主题级 CSS 变量在 portal 节点上也能命中。
|
|
61
|
+
*/
|
|
62
|
+
const themeClass = useThemeClass();
|
|
63
|
+
|
|
53
64
|
const zIndex = useZIndex();
|
|
54
65
|
const curZIndex = ref<number>(0);
|
|
55
66
|
|
package/src/editorProps.ts
CHANGED
|
@@ -27,6 +27,15 @@ import type {
|
|
|
27
27
|
} from './type';
|
|
28
28
|
|
|
29
29
|
export interface EditorProps {
|
|
30
|
+
/**
|
|
31
|
+
* 主题名称:对应 `packages/editor/src/theme/themes/<theme>/index.scss` 的目录名。
|
|
32
|
+
*
|
|
33
|
+
* 设置后会在编辑器根元素上追加 `m-editor--<theme>` 修饰类,配合按需引入
|
|
34
|
+
* `@tmagic/editor/dist/themes/<theme>.css` 即可启用主题样式。
|
|
35
|
+
*
|
|
36
|
+
* 例如:`<MEditor theme="magic-admin" />` + `import '@tmagic/editor/dist/themes/magic-admin.css'`。
|
|
37
|
+
*/
|
|
38
|
+
theme?: string;
|
|
30
39
|
/** 页面初始值 */
|
|
31
40
|
modelValue?: MApp;
|
|
32
41
|
/** 左侧面板中的组件类型列表 */
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="m-fields-code-select" :class="config.className">
|
|
3
|
-
<TMagicCard>
|
|
3
|
+
<TMagicCard :flat="config.flat">
|
|
4
4
|
<MContainer
|
|
5
5
|
:config="codeConfig"
|
|
6
6
|
:size="size"
|
|
7
|
+
class="code-select-content"
|
|
7
8
|
:prop="prop"
|
|
8
9
|
:disabled="disabled"
|
|
9
10
|
:is-compare="isCompareMode"
|
|
@@ -12,16 +13,20 @@
|
|
|
12
13
|
@change="changeHandler"
|
|
13
14
|
>
|
|
14
15
|
</MContainer>
|
|
16
|
+
<TMagicButton class="create-button fullWidth" :icon="Plus" :size="size" :disabled="disabled" @click="newHandler()"
|
|
17
|
+
>添加{{ config.text }}</TMagicButton
|
|
18
|
+
>
|
|
15
19
|
</TMagicCard>
|
|
16
20
|
</div>
|
|
17
21
|
</template>
|
|
18
22
|
|
|
19
23
|
<script lang="ts" setup>
|
|
20
24
|
import { computed, watch } from 'vue';
|
|
25
|
+
import { Plus } from '@element-plus/icons-vue';
|
|
21
26
|
import { isEmpty } from 'lodash-es';
|
|
22
27
|
|
|
23
28
|
import { HookCodeType, HookType } from '@tmagic/core';
|
|
24
|
-
import { TMagicCard } from '@tmagic/design';
|
|
29
|
+
import { TMagicButton, TMagicCard } from '@tmagic/design';
|
|
25
30
|
import type { CodeSelectConfig, ContainerChangeEventData, FieldProps, GroupListConfig } from '@tmagic/form';
|
|
26
31
|
import { MContainer } from '@tmagic/form';
|
|
27
32
|
|
|
@@ -53,12 +58,24 @@ const props = withDefaults(defineProps<FieldProps<CodeSelectConfig>>(), {});
|
|
|
53
58
|
* 仅当存在历史值时才启用对比,避免 lastValues 缺失时退化为「全部新增」的空对比。
|
|
54
59
|
*/
|
|
55
60
|
const isCompareMode = computed(() => Boolean(props.isCompare && props.lastValues));
|
|
56
|
-
|
|
61
|
+
const newHandler = () => {
|
|
62
|
+
const defaultCode = {
|
|
63
|
+
codeType: HookCodeType.CODE,
|
|
64
|
+
codeId: '',
|
|
65
|
+
};
|
|
66
|
+
const name = props.config.name || '';
|
|
67
|
+
const hookData = props.model[name]?.hookData || [];
|
|
68
|
+
emit('change', defaultCode, {
|
|
69
|
+
modifyKey: `hookData.${hookData.length}`,
|
|
70
|
+
});
|
|
71
|
+
};
|
|
57
72
|
const codeConfig = computed<GroupListConfig>(() => ({
|
|
58
73
|
type: 'group-list',
|
|
59
74
|
name: 'hookData',
|
|
60
75
|
enableToggleMode: false,
|
|
61
76
|
expandAll: true,
|
|
77
|
+
flat: true,
|
|
78
|
+
addable: () => false,
|
|
62
79
|
title: (mForm, { model, index }: any) => {
|
|
63
80
|
if (model.codeType === HookCodeType.DATA_SOURCE_METHOD) {
|
|
64
81
|
if (Array.isArray(model.codeId)) {
|
|
@@ -81,46 +98,40 @@ const codeConfig = computed<GroupListConfig>(() => ({
|
|
|
81
98
|
|
|
82
99
|
return model.codeId || index;
|
|
83
100
|
},
|
|
101
|
+
titlePrefix: props.config.name === undefined ? undefined : String(props.config.name),
|
|
84
102
|
items: [
|
|
85
103
|
{
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
{ value: HookCodeType.CODE, text: '代码块' },
|
|
94
|
-
{ value: HookCodeType.DATA_SOURCE_METHOD, text: '数据源方法' },
|
|
95
|
-
],
|
|
96
|
-
defaultValue: 'code',
|
|
97
|
-
onChange: (_mForm, v: HookCodeType, { setModel }) => {
|
|
98
|
-
if (v === HookCodeType.DATA_SOURCE_METHOD) {
|
|
99
|
-
setModel('codeId', []);
|
|
100
|
-
} else {
|
|
101
|
-
setModel('codeId', '');
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
return v;
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
type: 'code-select-col',
|
|
109
|
-
name: 'codeId',
|
|
110
|
-
span: 18,
|
|
111
|
-
labelWidth: 0,
|
|
112
|
-
display: (_mForm, { model }) => model.codeType !== HookCodeType.DATA_SOURCE_METHOD,
|
|
113
|
-
notEditable: () => !codeBlockService.getEditStatus(),
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
type: 'data-source-method-select',
|
|
117
|
-
name: 'codeId',
|
|
118
|
-
span: 18,
|
|
119
|
-
labelWidth: 0,
|
|
120
|
-
display: (_mForm, { model }) => model.codeType === HookCodeType.DATA_SOURCE_METHOD,
|
|
121
|
-
notEditable: () => !dataSourceService.get('editable'),
|
|
122
|
-
},
|
|
104
|
+
text: '代码类型',
|
|
105
|
+
type: 'select',
|
|
106
|
+
name: 'codeType',
|
|
107
|
+
labelPosition: 'right',
|
|
108
|
+
options: [
|
|
109
|
+
{ value: HookCodeType.CODE, text: '代码块' },
|
|
110
|
+
{ value: HookCodeType.DATA_SOURCE_METHOD, text: '数据源方法' },
|
|
123
111
|
],
|
|
112
|
+
defaultValue: 'code',
|
|
113
|
+
onChange: (_mForm, v: HookCodeType, { setModel }) => {
|
|
114
|
+
if (v === HookCodeType.DATA_SOURCE_METHOD) {
|
|
115
|
+
setModel('codeId', []);
|
|
116
|
+
} else {
|
|
117
|
+
setModel('codeId', '');
|
|
118
|
+
}
|
|
119
|
+
return v;
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
type: 'code-select-col',
|
|
124
|
+
name: 'codeId',
|
|
125
|
+
text: '代码块',
|
|
126
|
+
display: (_mForm, { model }) => model.codeType !== HookCodeType.DATA_SOURCE_METHOD,
|
|
127
|
+
notEditable: () => !codeBlockService.getEditStatus(),
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
type: 'data-source-method-select',
|
|
131
|
+
name: 'codeId',
|
|
132
|
+
text: '数据源字段',
|
|
133
|
+
display: (_mForm, { model }) => model.codeType === HookCodeType.DATA_SOURCE_METHOD,
|
|
134
|
+
notEditable: () => !dataSourceService.get('editable'),
|
|
124
135
|
},
|
|
125
136
|
],
|
|
126
137
|
}));
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div
|
|
2
|
+
<div
|
|
3
|
+
class="m-fields-data-source-field-select"
|
|
4
|
+
:class="{
|
|
5
|
+
[`data-source-field-${type}`]: !isSelectValid,
|
|
6
|
+
}"
|
|
7
|
+
>
|
|
3
8
|
<FieldSelect
|
|
4
|
-
v-if="
|
|
9
|
+
v-if="isSelectValid"
|
|
5
10
|
:model-value="model[name]"
|
|
6
11
|
:disabled="disabled"
|
|
7
12
|
:size="size"
|
|
@@ -37,15 +42,14 @@
|
|
|
37
42
|
:size="size"
|
|
38
43
|
:disabled="disabled"
|
|
39
44
|
@click="onToggleDataSourceFieldSelectHandler"
|
|
40
|
-
><MIcon :icon="
|
|
41
|
-
|
|
45
|
+
><MIcon :icon="dataSourceIcon"></MIcon>
|
|
46
|
+
</TMagicButton>
|
|
42
47
|
</TMagicTooltip>
|
|
43
48
|
</div>
|
|
44
49
|
</template>
|
|
45
50
|
|
|
46
51
|
<script setup lang="ts">
|
|
47
52
|
import { computed, inject, ref, resolveComponent, watch } from 'vue';
|
|
48
|
-
import { Coin } from '@element-plus/icons-vue';
|
|
49
53
|
|
|
50
54
|
import { DataSchema } from '@tmagic/core';
|
|
51
55
|
import { TMagicButton, tMagicMessage, TMagicTooltip } from '@tmagic/design';
|
|
@@ -61,6 +65,8 @@ import { DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX, removeDataSourceFieldPrefix } f
|
|
|
61
65
|
import MIcon from '@editor/components/Icon.vue';
|
|
62
66
|
import { useServices } from '@editor/hooks/use-services';
|
|
63
67
|
|
|
68
|
+
import dataSourceIcon from '../../icons/DatasourceIcon.vue';
|
|
69
|
+
|
|
64
70
|
import FieldSelect from './FieldSelect.vue';
|
|
65
71
|
|
|
66
72
|
defineOptions({
|
|
@@ -75,6 +81,9 @@ const props = withDefaults(defineProps<FieldProps<DataSourceFieldSelectConfig>>(
|
|
|
75
81
|
|
|
76
82
|
const showDataSourceFieldSelect = ref(false);
|
|
77
83
|
|
|
84
|
+
const isSelectValid = computed(
|
|
85
|
+
() => !disabledDataSource.value && (showDataSourceFieldSelect.value || !props.config.fieldConfig),
|
|
86
|
+
);
|
|
78
87
|
watch(
|
|
79
88
|
() => props.model[props.name],
|
|
80
89
|
(value) => {
|
|
@@ -68,12 +68,15 @@ const config = computed<GroupListConfig>(() => ({
|
|
|
68
68
|
titlePrefix: props.config.titlePrefix,
|
|
69
69
|
expandAll: true,
|
|
70
70
|
enableToggleMode: false,
|
|
71
|
+
flat: props.config.flat,
|
|
71
72
|
items: [
|
|
72
73
|
{
|
|
73
74
|
type: 'table',
|
|
74
75
|
name: 'cond',
|
|
75
|
-
operateColWidth:
|
|
76
|
+
operateColWidth: props.config.operateColWidth,
|
|
76
77
|
enableToggleMode: false,
|
|
78
|
+
fixed: props.config.fixed,
|
|
79
|
+
flat: props.config.flat,
|
|
77
80
|
items: [
|
|
78
81
|
parentFields.value.length
|
|
79
82
|
? {
|
|
@@ -12,16 +12,21 @@
|
|
|
12
12
|
@change="onChangeHandler"
|
|
13
13
|
></MTable>
|
|
14
14
|
|
|
15
|
-
<div v-else class="fullWidth">
|
|
16
|
-
<
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
15
|
+
<div v-else class="fullWidth event-select-container">
|
|
16
|
+
<div class="event-select-header">
|
|
17
|
+
<div class="event-select-title">事件配置</div>
|
|
18
|
+
<TMagicButton
|
|
19
|
+
v-if="!isCompareMode && displayList.length > 0"
|
|
20
|
+
class="create-button"
|
|
21
|
+
text
|
|
22
|
+
type="primary"
|
|
23
|
+
:icon="Plus"
|
|
24
|
+
:size="size"
|
|
25
|
+
:disabled="disabled"
|
|
26
|
+
@click="addEvent()"
|
|
27
|
+
>添加事件</TMagicButton
|
|
28
|
+
>
|
|
29
|
+
</div>
|
|
25
30
|
<MPanel
|
|
26
31
|
v-for="entry in displayList"
|
|
27
32
|
:key="entry.index"
|
|
@@ -32,32 +37,45 @@
|
|
|
32
37
|
:model="entry.cardItem"
|
|
33
38
|
:last-values="entry.lastCardItem"
|
|
34
39
|
:is-compare="isCompareMode"
|
|
40
|
+
:hide-expand="true"
|
|
35
41
|
:label-width="config.labelWidth || '100px'"
|
|
36
42
|
@change="onChangeHandler"
|
|
37
43
|
>
|
|
38
44
|
<template #header>
|
|
39
|
-
<
|
|
40
|
-
class="
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
45
|
+
<div class="event-item-header">
|
|
46
|
+
<div class="event-item-title">事件{{ Number(entry.index) + 1 }}</div>
|
|
47
|
+
<MFormContainer
|
|
48
|
+
class="fullWidth"
|
|
49
|
+
:config="eventNameConfig"
|
|
50
|
+
:model="entry.cardItem"
|
|
51
|
+
:last-values="entry.lastCardItem"
|
|
52
|
+
:is-compare="isCompareMode"
|
|
53
|
+
:disabled="disabled"
|
|
54
|
+
:size="size"
|
|
55
|
+
:prop="`${prop}.${entry.index}`"
|
|
56
|
+
@change="eventNameChangeHandler"
|
|
57
|
+
></MFormContainer>
|
|
58
|
+
<TMagicButton
|
|
59
|
+
class="event-item-delete-button"
|
|
60
|
+
v-if="!isCompareMode"
|
|
61
|
+
link
|
|
62
|
+
:icon="Delete"
|
|
63
|
+
:disabled="disabled"
|
|
64
|
+
:size="size"
|
|
65
|
+
@click="removeEvent(Number(entry.index))"
|
|
66
|
+
></TMagicButton>
|
|
67
|
+
</div>
|
|
59
68
|
</template>
|
|
60
69
|
</MPanel>
|
|
70
|
+
|
|
71
|
+
<TMagicButton
|
|
72
|
+
v-if="!isCompareMode"
|
|
73
|
+
class="create-button fullWidth"
|
|
74
|
+
:icon="Plus"
|
|
75
|
+
:disabled="disabled"
|
|
76
|
+
@click="addEvent()"
|
|
77
|
+
>添加事件</TMagicButton
|
|
78
|
+
>
|
|
61
79
|
</div>
|
|
62
80
|
</div>
|
|
63
81
|
</template>
|
|
@@ -65,6 +83,7 @@
|
|
|
65
83
|
<script lang="ts" setup>
|
|
66
84
|
import { computed } from 'vue';
|
|
67
85
|
import { Delete } from '@element-plus/icons-vue';
|
|
86
|
+
import { Plus } from '@element-plus/icons-vue';
|
|
68
87
|
import { has } from 'lodash-es';
|
|
69
88
|
|
|
70
89
|
import type { EventOption, MComponent, MContainer } from '@tmagic/core';
|
|
@@ -105,7 +124,7 @@ const { editorService, dataSourceService, eventsService, codeBlockService, props
|
|
|
105
124
|
const eventNameConfig = computed(() => {
|
|
106
125
|
const defaultEventNameConfig = {
|
|
107
126
|
name: 'name',
|
|
108
|
-
text: '
|
|
127
|
+
text: '事件类型',
|
|
109
128
|
type: (mForm: FormState | undefined, { formValue }: any) => {
|
|
110
129
|
if (
|
|
111
130
|
props.config.src !== 'component' ||
|
|
@@ -115,7 +134,7 @@ const eventNameConfig = computed(() => {
|
|
|
115
134
|
}
|
|
116
135
|
return 'select';
|
|
117
136
|
},
|
|
118
|
-
labelWidth: '
|
|
137
|
+
labelWidth: '70px',
|
|
119
138
|
checkStrictly: () => props.config.src !== 'component',
|
|
120
139
|
valueSeparator: '.',
|
|
121
140
|
options: (mForm: FormState, { formValue }: any) => {
|
|
@@ -186,6 +205,7 @@ const actionTypeConfig = computed(() => {
|
|
|
186
205
|
name: 'actionType',
|
|
187
206
|
text: '联动类型',
|
|
188
207
|
type: 'select',
|
|
208
|
+
labelPosition: 'left',
|
|
189
209
|
defaultValue: ActionType.COMP,
|
|
190
210
|
options: () => {
|
|
191
211
|
const o: {
|
|
@@ -230,6 +250,7 @@ const targetCompConfig = computed(() => {
|
|
|
230
250
|
name: 'to',
|
|
231
251
|
text: '联动组件',
|
|
232
252
|
type: 'ui-select',
|
|
253
|
+
labelPosition: 'left',
|
|
233
254
|
display: (_mForm, { model }) => model.actionType === ActionType.COMP,
|
|
234
255
|
onChange: (_MForm, _v, { setModel }) => {
|
|
235
256
|
setModel('method', '');
|
|
@@ -243,6 +264,7 @@ const compActionConfig = computed(() => {
|
|
|
243
264
|
const defaultCompActionConfig: DynamicTypeConfig = {
|
|
244
265
|
name: 'method',
|
|
245
266
|
text: '动作',
|
|
267
|
+
labelPosition: 'left',
|
|
246
268
|
type: (mForm: FormState | undefined, { model }: any) => {
|
|
247
269
|
const to = editorService.getNodeById(model.to);
|
|
248
270
|
|
|
@@ -362,6 +384,8 @@ const actionsConfig = computed(
|
|
|
362
384
|
() =>
|
|
363
385
|
defineFormItem({
|
|
364
386
|
type: 'panel',
|
|
387
|
+
labelPosition: 'left',
|
|
388
|
+
flat: true,
|
|
365
389
|
items: [
|
|
366
390
|
{
|
|
367
391
|
type: 'group-list',
|
|
@@ -369,6 +393,8 @@ const actionsConfig = computed(
|
|
|
369
393
|
expandAll: true,
|
|
370
394
|
enableToggleMode: false,
|
|
371
395
|
titlePrefix: '动作',
|
|
396
|
+
labelPosition: 'left',
|
|
397
|
+
flat: true,
|
|
372
398
|
items: [
|
|
373
399
|
actionTypeConfig.value,
|
|
374
400
|
targetCompConfig.value,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<TMagicCollapse class="m-fields-style-setter" v-model="collapseValue">
|
|
3
3
|
<template v-for="(item, index) in list" :key="index">
|
|
4
4
|
<TMagicCollapseItem :name="`${index}`">
|
|
5
|
-
<template #title
|
|
5
|
+
<template #title>{{ item.title }}</template>
|
|
6
6
|
<component
|
|
7
7
|
v-if="item.component"
|
|
8
8
|
:is="item.component"
|
|
@@ -21,14 +21,11 @@
|
|
|
21
21
|
|
|
22
22
|
<script setup lang="ts">
|
|
23
23
|
import { shallowRef } from 'vue';
|
|
24
|
-
import { Grid } from '@element-plus/icons-vue';
|
|
25
24
|
|
|
26
25
|
import { TMagicCollapse, TMagicCollapseItem } from '@tmagic/design';
|
|
27
26
|
import type { ContainerChangeEventData, FieldProps } from '@tmagic/form';
|
|
28
27
|
import type { StyleSchema } from '@tmagic/schema';
|
|
29
28
|
|
|
30
|
-
import MIcon from '@editor/components/Icon.vue';
|
|
31
|
-
|
|
32
29
|
import { Background, Border, Font, Layout, Position, Transform } from './pro/';
|
|
33
30
|
|
|
34
31
|
defineOptions({
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
|
|
3
|
+
<path
|
|
4
|
+
d="M12 4C12.5523 4 13 4.44772 13 5V11C13 11.5523 12.5523 12 12 12H4C3.44772 12 3 11.5523 3 11V5C3 4.44772 3.44772 4 4 4H12ZM4.5 5C4.22386 5 4 5.22386 4 5.5V10.5C4 10.7761 4.22386 11 4.5 11H11.5C11.7761 11 12 10.7761 12 10.5V5.5C12 5.22386 11.7761 5 11.5 5H4.5Z"
|
|
5
|
+
/>
|
|
6
|
+
<rect
|
|
7
|
+
x="13.75"
|
|
8
|
+
y="7.75"
|
|
9
|
+
width="0.5"
|
|
10
|
+
height="11.5"
|
|
11
|
+
rx="0.25"
|
|
12
|
+
transform="rotate(90 13.75 7.75)"
|
|
13
|
+
stroke="black"
|
|
14
|
+
stroke-opacity="0.3"
|
|
15
|
+
style="stroke: black; stroke-opacity: 0.3"
|
|
16
|
+
stroke-width="0.5"
|
|
17
|
+
/>
|
|
18
|
+
</svg>
|
|
19
|
+
</template>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
|
|
3
|
+
<path
|
|
4
|
+
d="M12 3C12.5523 3 13 3.44772 13 4V10C13 10.5523 12.5523 11 12 11H4C3.44772 11 3 10.5523 3 10V4C3 3.44772 3.44772 3 4 3H12ZM4.5 4C4.22386 4 4 4.22386 4 4.5V9.5C4 9.77614 4.22386 10 4.5 10H11.5C11.7761 10 12 9.77614 12 9.5V4.5C12 4.22386 11.7761 4 11.5 4H4.5Z"
|
|
5
|
+
/>
|
|
6
|
+
<rect
|
|
7
|
+
x="13.75"
|
|
8
|
+
y="12.25"
|
|
9
|
+
width="0.5"
|
|
10
|
+
height="11.5"
|
|
11
|
+
rx="0.25"
|
|
12
|
+
transform="rotate(90 13.75 12.25)"
|
|
13
|
+
stroke="black"
|
|
14
|
+
stroke-opacity="0.3"
|
|
15
|
+
style="stroke: black; stroke-opacity: 0.3"
|
|
16
|
+
stroke-width="0.5"
|
|
17
|
+
/>
|
|
18
|
+
</svg>
|
|
19
|
+
</template>
|