@tmagic/editor 1.7.0-beta.2 → 1.7.0-beta.4
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 +20 -7
- package/dist/tmagic-editor.js +170 -135
- package/dist/tmagic-editor.umd.cjs +169 -134
- package/package.json +13 -14
- package/src/fields/CodeSelectCol.vue +29 -36
- package/src/fields/CondOpSelect.vue +1 -1
- package/src/fields/DataSourceInput.vue +23 -4
- package/src/fields/DataSourceMethodSelect.vue +38 -30
- package/src/fields/EventSelect.vue +0 -1
- package/src/fields/PageFragmentSelect.vue +11 -8
- package/src/fields/UISelect.vue +0 -2
- package/src/layouts/workspace/viewer/Stage.vue +1 -1
- package/types/index.d.ts +2 -2
|
@@ -2,13 +2,15 @@
|
|
|
2
2
|
<div class="m-fields-code-select-col">
|
|
3
3
|
<div class="code-select-container">
|
|
4
4
|
<!-- 代码块下拉框 -->
|
|
5
|
-
<
|
|
5
|
+
<MSelect
|
|
6
6
|
class="select"
|
|
7
7
|
:config="selectConfig"
|
|
8
|
+
:name="name"
|
|
8
9
|
:model="model"
|
|
9
10
|
:size="size"
|
|
11
|
+
:prop="prop"
|
|
10
12
|
@change="onCodeIdChangeHandler"
|
|
11
|
-
></
|
|
13
|
+
></MSelect>
|
|
12
14
|
|
|
13
15
|
<!-- 查看/编辑按钮 -->
|
|
14
16
|
<TMagicButton
|
|
@@ -28,6 +30,7 @@
|
|
|
28
30
|
:key="model[name]"
|
|
29
31
|
:model="model"
|
|
30
32
|
:size="size"
|
|
33
|
+
:disabled="disabled"
|
|
31
34
|
:params-config="paramsConfig"
|
|
32
35
|
@change="onParamsChangeHandler"
|
|
33
36
|
></CodeParams>
|
|
@@ -48,7 +51,8 @@ import {
|
|
|
48
51
|
type FieldProps,
|
|
49
52
|
filterFunction,
|
|
50
53
|
type FormState,
|
|
51
|
-
|
|
54
|
+
MSelect,
|
|
55
|
+
type SelectConfig,
|
|
52
56
|
} from '@tmagic/form';
|
|
53
57
|
|
|
54
58
|
import CodeParams from '@editor/components/CodeParams.vue';
|
|
@@ -108,7 +112,7 @@ watch(
|
|
|
108
112
|
},
|
|
109
113
|
);
|
|
110
114
|
|
|
111
|
-
const selectConfig = {
|
|
115
|
+
const selectConfig: SelectConfig = {
|
|
112
116
|
type: 'select',
|
|
113
117
|
name: props.name,
|
|
114
118
|
disable: props.disabled,
|
|
@@ -122,33 +126,26 @@ const selectConfig = {
|
|
|
122
126
|
}
|
|
123
127
|
return [];
|
|
124
128
|
},
|
|
125
|
-
onChange: (formState: any, codeId: Id, { setModel, model }: any) => {
|
|
126
|
-
// 通过下拉框选择的codeId变化后修正model的值,避免写入其他codeId的params
|
|
127
|
-
paramsConfig.value = getParamItemsConfig(codeId);
|
|
128
|
-
|
|
129
|
-
if (paramsConfig.value.length) {
|
|
130
|
-
setModel('params', createValues(formState, paramsConfig.value, {}, model.params));
|
|
131
|
-
} else {
|
|
132
|
-
setModel('params', {});
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
return codeId;
|
|
136
|
-
},
|
|
137
129
|
};
|
|
138
130
|
|
|
139
|
-
const onCodeIdChangeHandler = (value: any
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
131
|
+
const onCodeIdChangeHandler = (value: any) => {
|
|
132
|
+
// 通过下拉框选择的codeId变化后修正model的值,避免写入其他codeId的params
|
|
133
|
+
paramsConfig.value = getParamItemsConfig(value);
|
|
134
|
+
|
|
135
|
+
const changeRecords = [
|
|
136
|
+
{
|
|
137
|
+
propPath: props.prop,
|
|
138
|
+
value,
|
|
139
|
+
},
|
|
140
|
+
];
|
|
141
|
+
|
|
142
|
+
changeRecords.push({
|
|
143
|
+
propPath: props.prop.replace(`${props.name}`, 'params'),
|
|
144
|
+
value: paramsConfig.value.length ? createValues(mForm, paramsConfig.value, {}, props.model.params) : {},
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
emit('change', value, {
|
|
148
|
+
changeRecords,
|
|
152
149
|
});
|
|
153
150
|
};
|
|
154
151
|
|
|
@@ -156,14 +153,10 @@ const onCodeIdChangeHandler = (value: any, eventData: ContainerChangeEventData)
|
|
|
156
153
|
* 参数值修改更新
|
|
157
154
|
*/
|
|
158
155
|
const onParamsChangeHandler = (value: any, eventData: ContainerChangeEventData) => {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
...eventData,
|
|
162
|
-
changeRecords: (eventData.changeRecords || []).map((item) => ({
|
|
163
|
-
prop: `${props.prop.replace(props.name, '')}${item.propPath}`,
|
|
164
|
-
value: item.value,
|
|
165
|
-
})),
|
|
156
|
+
eventData.changeRecords?.forEach((record) => {
|
|
157
|
+
record.propPath = `${props.prop.replace(`${props.name}`, '')}${record.propPath}`;
|
|
166
158
|
});
|
|
159
|
+
emit('change', props.model[props.name], eventData);
|
|
167
160
|
};
|
|
168
161
|
|
|
169
162
|
const editCode = (id: string) => {
|
|
@@ -38,12 +38,29 @@
|
|
|
38
38
|
</template>
|
|
39
39
|
</component>
|
|
40
40
|
<div
|
|
41
|
-
:class="`tmagic-data-source-input-text el-input t-input t-size-${size?.[0]} el-input--${size}`"
|
|
42
|
-
@mouseup="mouseupHandler"
|
|
43
41
|
v-else
|
|
42
|
+
:class="{
|
|
43
|
+
'tmagic-data-source-input-text': true,
|
|
44
|
+
'el-input': adapterType === 'element-plus',
|
|
45
|
+
[`el-input--${size}`]: adapterType === 'element-plus',
|
|
46
|
+
't-input': adapterType === 'tdesign-vue-next',
|
|
47
|
+
[`t-size-${size?.[0]}`]: adapterType === 'tdesign-vue-next',
|
|
48
|
+
}"
|
|
49
|
+
@mouseup="mouseupHandler"
|
|
44
50
|
>
|
|
45
|
-
<div
|
|
46
|
-
|
|
51
|
+
<div
|
|
52
|
+
:class="{
|
|
53
|
+
'tmagic-data-source-input-text-wrapper': true,
|
|
54
|
+
'el-input__wrapper': adapterType === 'element-plus',
|
|
55
|
+
'is-focus': isFocused,
|
|
56
|
+
}"
|
|
57
|
+
>
|
|
58
|
+
<div
|
|
59
|
+
:class="{
|
|
60
|
+
'el-input__inner': adapterType === 'element-plus',
|
|
61
|
+
input__inner: adapterType === 'tdesign-vue-next',
|
|
62
|
+
}"
|
|
63
|
+
>
|
|
47
64
|
<template v-for="(item, index) in displayState">
|
|
48
65
|
<span :key="index" v-if="item.type === 'text'" style="margin-right: 2px">{{ item.value }}</span>
|
|
49
66
|
<TMagicTag :key="index" :size="size" v-if="item.type === 'var'">{{ item.value }}</TMagicTag>
|
|
@@ -80,6 +97,8 @@ const emit = defineEmits<{
|
|
|
80
97
|
change: [value: string];
|
|
81
98
|
}>();
|
|
82
99
|
|
|
100
|
+
const adapterType = getDesignConfig('adapterType');
|
|
101
|
+
|
|
83
102
|
const { dataSourceService, propsService } = useServices();
|
|
84
103
|
|
|
85
104
|
const autocompleteRef = useTemplateRef<InstanceType<typeof TMagicAutocomplete>>('autocomplete');
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="m-fields-data-source-method-select">
|
|
3
3
|
<div class="data-source-method-select-container">
|
|
4
|
-
<
|
|
4
|
+
<MCascader
|
|
5
5
|
class="select"
|
|
6
6
|
:config="cascaderConfig"
|
|
7
7
|
:model="model"
|
|
8
|
+
:name="name"
|
|
8
9
|
:size="size"
|
|
10
|
+
:disabled="disabled"
|
|
11
|
+
:prop="prop"
|
|
9
12
|
@change="onChangeHandler"
|
|
10
|
-
></
|
|
13
|
+
></MCascader>
|
|
11
14
|
|
|
12
15
|
<TMagicTooltip
|
|
13
16
|
v-if="model[name] && isCustomMethod && hasDataSourceSidePanel"
|
|
@@ -22,11 +25,12 @@
|
|
|
22
25
|
<CodeParams
|
|
23
26
|
v-if="paramsConfig.length"
|
|
24
27
|
name="params"
|
|
28
|
+
:key="model[name]"
|
|
25
29
|
:model="model"
|
|
26
30
|
:size="size"
|
|
27
31
|
:disabled="disabled"
|
|
28
32
|
:params-config="paramsConfig"
|
|
29
|
-
@change="
|
|
33
|
+
@change="onParamsChangeHandler"
|
|
30
34
|
></CodeParams>
|
|
31
35
|
</div>
|
|
32
36
|
</template>
|
|
@@ -38,13 +42,14 @@ import { Edit, View } from '@element-plus/icons-vue';
|
|
|
38
42
|
import type { Id } from '@tmagic/core';
|
|
39
43
|
import { TMagicButton, TMagicTooltip } from '@tmagic/design';
|
|
40
44
|
import {
|
|
45
|
+
type CascaderConfig,
|
|
46
|
+
type ContainerChangeEventData,
|
|
41
47
|
createValues,
|
|
42
48
|
type DataSourceMethodSelectConfig,
|
|
43
49
|
type FieldProps,
|
|
44
50
|
filterFunction,
|
|
45
51
|
type FormState,
|
|
46
|
-
|
|
47
|
-
type OnChangeHandlerData,
|
|
52
|
+
MCascader,
|
|
48
53
|
} from '@tmagic/form';
|
|
49
54
|
|
|
50
55
|
import CodeParams from '@editor/components/CodeParams.vue';
|
|
@@ -100,21 +105,6 @@ const getParamItemsConfig = ([dataSourceId, methodName]: [Id, string] = ['', '']
|
|
|
100
105
|
|
|
101
106
|
const paramsConfig = ref<CodeParamStatement[]>(getParamItemsConfig(props.model[props.name || 'dataSourceMethod']));
|
|
102
107
|
|
|
103
|
-
const setParamsConfig = (
|
|
104
|
-
dataSourceMethod: [Id, string],
|
|
105
|
-
formState: any = {},
|
|
106
|
-
setModel: OnChangeHandlerData['setModel'],
|
|
107
|
-
) => {
|
|
108
|
-
// 通过下拉框选择的codeId变化后修正model的值,避免写入其他codeId的params
|
|
109
|
-
paramsConfig.value = dataSourceMethod ? getParamItemsConfig(dataSourceMethod) : [];
|
|
110
|
-
|
|
111
|
-
if (paramsConfig.value.length) {
|
|
112
|
-
setModel('params', createValues(formState, paramsConfig.value, {}, props.model.params));
|
|
113
|
-
} else {
|
|
114
|
-
setModel('params', {});
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
|
|
118
108
|
const methodsOptions = computed(
|
|
119
109
|
() =>
|
|
120
110
|
dataSources.value
|
|
@@ -132,24 +122,42 @@ const methodsOptions = computed(
|
|
|
132
122
|
})) || [],
|
|
133
123
|
);
|
|
134
124
|
|
|
135
|
-
const cascaderConfig = computed(() => ({
|
|
125
|
+
const cascaderConfig = computed<CascaderConfig>(() => ({
|
|
136
126
|
type: 'cascader',
|
|
137
|
-
name: props.name,
|
|
138
127
|
options: methodsOptions.value,
|
|
139
|
-
disable: props.disabled,
|
|
140
|
-
onChange: (formState: any, dataSourceMethod: [Id, string], { setModel }: OnChangeHandlerData) => {
|
|
141
|
-
setParamsConfig(dataSourceMethod, formState, setModel);
|
|
142
|
-
|
|
143
|
-
return dataSourceMethod;
|
|
144
|
-
},
|
|
145
128
|
}));
|
|
146
129
|
|
|
147
130
|
/**
|
|
148
131
|
* 参数值修改更新
|
|
149
132
|
*/
|
|
150
133
|
const onChangeHandler = (value: any) => {
|
|
151
|
-
|
|
152
|
-
|
|
134
|
+
paramsConfig.value = getParamItemsConfig(value);
|
|
135
|
+
|
|
136
|
+
const changeRecords = [
|
|
137
|
+
{
|
|
138
|
+
propPath: props.prop,
|
|
139
|
+
value,
|
|
140
|
+
},
|
|
141
|
+
];
|
|
142
|
+
|
|
143
|
+
changeRecords.push({
|
|
144
|
+
propPath: props.prop.replace(`${props.name}`, 'params'),
|
|
145
|
+
value: paramsConfig.value.length ? createValues(mForm, paramsConfig.value, {}, props.model.params) : {},
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
emit('change', value, {
|
|
149
|
+
changeRecords,
|
|
150
|
+
});
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* 参数值修改更新
|
|
155
|
+
*/
|
|
156
|
+
const onParamsChangeHandler = (value: any, eventData: ContainerChangeEventData) => {
|
|
157
|
+
eventData.changeRecords?.forEach((record) => {
|
|
158
|
+
record.propPath = `${props.prop.replace(`${props.name}`, '')}${record.propPath}`;
|
|
159
|
+
});
|
|
160
|
+
emit('change', props.model[props.name], eventData);
|
|
153
161
|
};
|
|
154
162
|
|
|
155
163
|
const editCodeHandler = () => {
|
|
@@ -219,7 +219,6 @@ const targetCompConfig = computed(() => {
|
|
|
219
219
|
display: (mForm: FormState, { model }: { model: Record<any, any> }) => model.actionType === ActionType.COMP,
|
|
220
220
|
onChange: (MForm: FormState, v: string, { setModel }: OnChangeHandlerData) => {
|
|
221
221
|
setModel('method', '');
|
|
222
|
-
return v;
|
|
223
222
|
},
|
|
224
223
|
};
|
|
225
224
|
return { ...defaultTargetCompConfig, ...props.config.targetCompConfig };
|
|
@@ -2,13 +2,16 @@
|
|
|
2
2
|
<div class="m-fields-page-fragment-select">
|
|
3
3
|
<div class="page-fragment-select-container">
|
|
4
4
|
<!-- 页面片下拉框 -->
|
|
5
|
-
<
|
|
5
|
+
<MSelect
|
|
6
6
|
class="select"
|
|
7
7
|
:config="selectConfig"
|
|
8
8
|
:model="model"
|
|
9
|
+
:name="name"
|
|
9
10
|
:size="size"
|
|
11
|
+
:prop="prop"
|
|
12
|
+
:disabled="disabled"
|
|
10
13
|
@change="changeHandler"
|
|
11
|
-
></
|
|
14
|
+
></MSelect>
|
|
12
15
|
<!-- 编辑按钮 -->
|
|
13
16
|
<Icon v-if="model[name]" class="icon" :icon="Edit" @click="editPageFragment(model[name])"></Icon>
|
|
14
17
|
</div>
|
|
@@ -20,7 +23,7 @@ import { computed } from 'vue';
|
|
|
20
23
|
import { Edit } from '@element-plus/icons-vue';
|
|
21
24
|
|
|
22
25
|
import { Id, NodeType } from '@tmagic/core';
|
|
23
|
-
import { FieldProps, type PageFragmentSelectConfig } from '@tmagic/form';
|
|
26
|
+
import { FieldProps, MSelect, type PageFragmentSelectConfig, type SelectConfig } from '@tmagic/form';
|
|
24
27
|
|
|
25
28
|
import Icon from '@editor/components/Icon.vue';
|
|
26
29
|
import { useServices } from '@editor/hooks/use-services';
|
|
@@ -32,16 +35,16 @@ defineOptions({
|
|
|
32
35
|
const { editorService } = useServices();
|
|
33
36
|
const emit = defineEmits(['change']);
|
|
34
37
|
|
|
35
|
-
|
|
38
|
+
withDefaults(defineProps<FieldProps<PageFragmentSelectConfig>>(), {
|
|
36
39
|
disabled: false,
|
|
37
40
|
});
|
|
41
|
+
|
|
38
42
|
const pageList = computed(() =>
|
|
39
43
|
editorService.get('root')?.items.filter((item) => item.type === NodeType.PAGE_FRAGMENT),
|
|
40
44
|
);
|
|
41
45
|
|
|
42
|
-
const selectConfig = {
|
|
46
|
+
const selectConfig: SelectConfig = {
|
|
43
47
|
type: 'select',
|
|
44
|
-
name: props.name,
|
|
45
48
|
options: () => {
|
|
46
49
|
if (pageList.value) {
|
|
47
50
|
return pageList.value.map((item) => ({
|
|
@@ -53,8 +56,8 @@ const selectConfig = {
|
|
|
53
56
|
return [];
|
|
54
57
|
},
|
|
55
58
|
};
|
|
56
|
-
const changeHandler =
|
|
57
|
-
emit('change',
|
|
59
|
+
const changeHandler = (v: Id) => {
|
|
60
|
+
emit('change', v);
|
|
58
61
|
};
|
|
59
62
|
|
|
60
63
|
const editPageFragment = (id: Id) => {
|
package/src/fields/UISelect.vue
CHANGED
|
@@ -79,7 +79,6 @@ const clickHandler = ({ detail }: Event & { detail: HTMLElement | MNode }) => {
|
|
|
79
79
|
id = getIdFromEl()(detail as HTMLElement) || id;
|
|
80
80
|
}
|
|
81
81
|
if (id) {
|
|
82
|
-
props.model[props.name] = id;
|
|
83
82
|
emit('change', id);
|
|
84
83
|
mForm?.$emit('field-change', props.prop, id);
|
|
85
84
|
}
|
|
@@ -102,7 +101,6 @@ const startSelect = () => {
|
|
|
102
101
|
|
|
103
102
|
const deleteHandler = () => {
|
|
104
103
|
if (props.model) {
|
|
105
|
-
props.model[props.name] = '';
|
|
106
104
|
emit('change', '');
|
|
107
105
|
mForm?.$emit('field-change', props.prop, '');
|
|
108
106
|
}
|
|
@@ -167,7 +167,7 @@ watch(page, (page) => {
|
|
|
167
167
|
}
|
|
168
168
|
});
|
|
169
169
|
|
|
170
|
-
const resizeObserver = new ResizeObserver((entries) => {
|
|
170
|
+
const resizeObserver = new globalThis.ResizeObserver((entries) => {
|
|
171
171
|
for (const { contentRect } of entries) {
|
|
172
172
|
uiService.set('stageContainerRect', {
|
|
173
173
|
width: contentRect.width,
|
package/types/index.d.ts
CHANGED
|
@@ -2679,12 +2679,12 @@ declare const __VLS_base$9: _vue_runtime_core.DefineComponent<__VLS_Props$g, {
|
|
|
2679
2679
|
deleteCode: (id: string) => Promise<void>;
|
|
2680
2680
|
}, {}, {}, {}, _vue_runtime_core.ComponentOptionsMixin, _vue_runtime_core.ComponentOptionsMixin, {
|
|
2681
2681
|
remove: (id: string) => any;
|
|
2682
|
-
"node-contextmenu": (event: MouseEvent, data: TreeNodeData) => any;
|
|
2683
2682
|
edit: (id: string) => any;
|
|
2683
|
+
"node-contextmenu": (event: MouseEvent, data: TreeNodeData) => any;
|
|
2684
2684
|
}, string, _vue_runtime_core.PublicProps, Readonly<__VLS_Props$g> & Readonly<{
|
|
2685
2685
|
onRemove?: ((id: string) => any) | undefined;
|
|
2686
|
-
"onNode-contextmenu"?: ((event: MouseEvent, data: TreeNodeData) => any) | undefined;
|
|
2687
2686
|
onEdit?: ((id: string) => any) | undefined;
|
|
2687
|
+
"onNode-contextmenu"?: ((event: MouseEvent, data: TreeNodeData) => any) | undefined;
|
|
2688
2688
|
}>, {}, {}, {}, {}, string, _vue_runtime_core.ComponentProvideOptions, false, {}, any>;
|
|
2689
2689
|
declare const __VLS_export$h: __VLS_WithSlots$9<typeof __VLS_base$9, __VLS_Slots$9>;
|
|
2690
2690
|
declare const _default$i: typeof __VLS_export$h;
|