@tmagic/editor 1.7.8-beta.1 → 1.7.8-beta.3
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/components/CodeBlockEditor.vue_vue_type_script_setup_true_lang.js +6 -6
- package/dist/es/fields/CodeSelectCol.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/fields/DataSourceFieldSelect/Index.vue_vue_type_script_setup_true_lang.js +4 -3
- package/dist/es/fields/EventSelect.vue_vue_type_script_setup_true_lang.js +5 -5
- package/dist/es/fields/StyleSetter/components/Border.vue_vue_type_script_setup_true_lang.js +5 -4
- package/dist/es/fields/StyleSetter/pro/Background.vue_vue_type_script_setup_true_lang.js +8 -6
- package/dist/es/fields/StyleSetter/pro/Border.vue_vue_type_script_setup_true_lang.js +8 -6
- package/dist/es/fields/StyleSetter/pro/Font.vue_vue_type_script_setup_true_lang.js +8 -6
- package/dist/es/fields/StyleSetter/pro/Layout.vue_vue_type_script_setup_true_lang.js +9 -8
- package/dist/es/fields/StyleSetter/pro/Position.vue_vue_type_script_setup_true_lang.js +8 -6
- package/dist/es/services/props.js +2 -1
- package/dist/es/utils/data-source/index.js +65 -63
- package/dist/es/utils/dep/worker.js +1 -1
- package/dist/es/utils/props.js +4 -4
- package/dist/tmagic-editor.umd.cjs +120 -107
- package/package.json +7 -7
- package/src/components/CodeBlockEditor.vue +70 -66
- package/src/components/CodeParams.vue +3 -3
- package/src/fields/CodeSelectCol.vue +5 -2
- package/src/fields/DataSourceFieldSelect/Index.vue +10 -3
- package/src/fields/DataSourceFields.vue +4 -1
- package/src/fields/DataSourceMethodSelect.vue +4 -1
- package/src/fields/EventSelect.vue +69 -63
- package/src/fields/StyleSetter/components/BackgroundPosition.vue +2 -2
- package/src/fields/StyleSetter/components/Border.vue +35 -33
- package/src/fields/StyleSetter/pro/Background.vue +4 -4
- package/src/fields/StyleSetter/pro/Border.vue +3 -3
- package/src/fields/StyleSetter/pro/Font.vue +3 -3
- package/src/fields/StyleSetter/pro/Layout.vue +8 -8
- package/src/fields/StyleSetter/pro/Position.vue +3 -3
- package/src/services/props.ts +3 -1
- package/src/utils/data-source/formConfigs/base.ts +2 -2
- package/src/utils/data-source/index.ts +73 -75
- package/src/utils/props.ts +10 -8
- package/types/index.d.ts +179 -175
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
<script lang="ts" setup>
|
|
13
13
|
import { markRaw } from 'vue';
|
|
14
14
|
|
|
15
|
-
import type {
|
|
16
|
-
import { MContainer } from '@tmagic/form';
|
|
15
|
+
import type { ChildConfig, ContainerChangeEventData } from '@tmagic/form';
|
|
16
|
+
import { defineFormItem, MContainer } from '@tmagic/form';
|
|
17
17
|
import type { StyleSchema } from '@tmagic/schema';
|
|
18
18
|
|
|
19
19
|
import Box from '../components/Box.vue';
|
|
@@ -42,7 +42,7 @@ const emit = defineEmits<{
|
|
|
42
42
|
change: [v: string | StyleSchema, eventData: ContainerChangeEventData];
|
|
43
43
|
}>();
|
|
44
44
|
|
|
45
|
-
const config = {
|
|
45
|
+
const config = defineFormItem({
|
|
46
46
|
items: [
|
|
47
47
|
{
|
|
48
48
|
name: 'display',
|
|
@@ -74,7 +74,7 @@ const config = {
|
|
|
74
74
|
tooltip: '垂直方向 起点在下沿 column-reverse',
|
|
75
75
|
},
|
|
76
76
|
],
|
|
77
|
-
display: (
|
|
77
|
+
display: (_mForm, { model }: { model: Record<any, any> }) => model.display === 'flex',
|
|
78
78
|
},
|
|
79
79
|
{
|
|
80
80
|
name: 'justifyContent',
|
|
@@ -89,7 +89,7 @@ const config = {
|
|
|
89
89
|
{ value: 'space-between', icon: markRaw(JustifyContentSpaceBetween), tooltip: '两端对齐 space-between' },
|
|
90
90
|
{ value: 'space-around', icon: markRaw(JustifyContentSpaceAround), tooltip: '横向平分 space-around' },
|
|
91
91
|
],
|
|
92
|
-
display: (
|
|
92
|
+
display: (_mForm, { model }: { model: Record<any, any> }) => model.display === 'flex',
|
|
93
93
|
},
|
|
94
94
|
{
|
|
95
95
|
name: 'alignItems',
|
|
@@ -104,7 +104,7 @@ const config = {
|
|
|
104
104
|
{ value: 'space-between', icon: markRaw(JustifyContentSpaceBetween), tooltip: '两端对齐 space-between' },
|
|
105
105
|
{ value: 'space-around', icon: markRaw(JustifyContentSpaceAround), tooltip: '横向平分 space-around' },
|
|
106
106
|
],
|
|
107
|
-
display: (
|
|
107
|
+
display: (_mForm, { model }: { model: Record<any, any> }) => model.display === 'flex',
|
|
108
108
|
},
|
|
109
109
|
{
|
|
110
110
|
name: 'flexWrap',
|
|
@@ -117,7 +117,7 @@ const config = {
|
|
|
117
117
|
{ value: 'wrap', text: '正换行', tooltip: '第一行在上方 wrap' },
|
|
118
118
|
{ value: 'wrap-reverse', text: '逆换行', tooltip: '第一行在下方 wrap-reverse' },
|
|
119
119
|
],
|
|
120
|
-
display: (
|
|
120
|
+
display: (_mForm, { model }: { model: Record<any, any> }) => model.display === 'flex',
|
|
121
121
|
},
|
|
122
122
|
{
|
|
123
123
|
type: 'row',
|
|
@@ -180,7 +180,7 @@ const config = {
|
|
|
180
180
|
],
|
|
181
181
|
},
|
|
182
182
|
],
|
|
183
|
-
};
|
|
183
|
+
}) as ChildConfig;
|
|
184
184
|
|
|
185
185
|
const change = (value: string | StyleSchema, eventData: ContainerChangeEventData) => {
|
|
186
186
|
emit('change', value, eventData);
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
</template>
|
|
4
4
|
|
|
5
5
|
<script lang="ts" setup>
|
|
6
|
-
import { ContainerChangeEventData, MContainer } from '@tmagic/form';
|
|
6
|
+
import { type ContainerChangeEventData, defineFormItem, type MContainer } from '@tmagic/form';
|
|
7
7
|
import type { StyleSchema } from '@tmagic/schema';
|
|
8
8
|
|
|
9
9
|
const props = defineProps<{
|
|
@@ -24,7 +24,7 @@ const positionText: Record<string, string> = {
|
|
|
24
24
|
sticky: '粘性定位',
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
-
const config = {
|
|
27
|
+
const config = defineFormItem({
|
|
28
28
|
items: [
|
|
29
29
|
{
|
|
30
30
|
name: 'position',
|
|
@@ -95,7 +95,7 @@ const config = {
|
|
|
95
95
|
},
|
|
96
96
|
},
|
|
97
97
|
],
|
|
98
|
-
};
|
|
98
|
+
});
|
|
99
99
|
|
|
100
100
|
const change = (value: string | StyleSchema, eventData: ContainerChangeEventData) => {
|
|
101
101
|
emit('change', value, eventData);
|
package/src/services/props.ts
CHANGED
|
@@ -102,9 +102,11 @@ class Props extends BaseService {
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
public async setPropsConfig(type: string, config: FormConfig | PropsFormConfigFunction) {
|
|
105
|
-
let c
|
|
105
|
+
let c: FormConfig;
|
|
106
106
|
if (typeof config === 'function') {
|
|
107
107
|
c = config({ editorService });
|
|
108
|
+
} else {
|
|
109
|
+
c = config;
|
|
108
110
|
}
|
|
109
111
|
|
|
110
112
|
this.state.propsConfigMap[toLine(type)] = await this.fillConfig(Array.isArray(c) ? c : [c]);
|
|
@@ -1,83 +1,81 @@
|
|
|
1
|
-
import { DataSchema, DataSourceFieldType, DataSourceSchema } from '@tmagic/core';
|
|
2
|
-
import { CascaderOption,
|
|
1
|
+
import type { DataSchema, DataSourceFieldType, DataSourceSchema } from '@tmagic/core';
|
|
2
|
+
import { type CascaderOption, defineFormItem, type FormConfig } from '@tmagic/form';
|
|
3
3
|
import { dataSourceTemplateRegExp, getKeysArray, isNumber } from '@tmagic/utils';
|
|
4
4
|
|
|
5
5
|
import BaseFormConfig from './formConfigs/base';
|
|
6
6
|
import HttpFormConfig from './formConfigs/http';
|
|
7
7
|
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
},
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
},
|
|
80
|
-
];
|
|
8
|
+
const dataSourceFormConfig = defineFormItem({
|
|
9
|
+
type: 'tab',
|
|
10
|
+
items: [
|
|
11
|
+
{
|
|
12
|
+
title: '数据定义',
|
|
13
|
+
items: [
|
|
14
|
+
{
|
|
15
|
+
name: 'fields',
|
|
16
|
+
type: 'data-source-fields',
|
|
17
|
+
defaultValue: () => [],
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
title: '方法定义',
|
|
23
|
+
items: [
|
|
24
|
+
{
|
|
25
|
+
name: 'methods',
|
|
26
|
+
type: 'data-source-methods',
|
|
27
|
+
defaultValue: () => [],
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
title: '事件配置',
|
|
33
|
+
items: [
|
|
34
|
+
{
|
|
35
|
+
name: 'events',
|
|
36
|
+
src: 'datasource',
|
|
37
|
+
type: 'event-select',
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
title: 'mock数据',
|
|
43
|
+
items: [
|
|
44
|
+
{
|
|
45
|
+
name: 'mocks',
|
|
46
|
+
type: 'data-source-mocks',
|
|
47
|
+
defaultValue: () => [],
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
title: '请求参数裁剪',
|
|
53
|
+
display: (_formState, { model }) => model.type === 'http',
|
|
54
|
+
items: [
|
|
55
|
+
{
|
|
56
|
+
name: 'beforeRequest',
|
|
57
|
+
type: 'vs-code',
|
|
58
|
+
parse: true,
|
|
59
|
+
autosize: { minRows: 10, maxRows: 30 },
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
title: '响应数据裁剪',
|
|
65
|
+
display: (_formStat, { model }) => model.type === 'http',
|
|
66
|
+
items: [
|
|
67
|
+
{
|
|
68
|
+
name: 'afterResponse',
|
|
69
|
+
type: 'vs-code',
|
|
70
|
+
parse: true,
|
|
71
|
+
autosize: { minRows: 10, maxRows: 30 },
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
const fillConfig = (config: FormConfig): FormConfig => [...BaseFormConfig(), ...config, dataSourceFormConfig];
|
|
81
79
|
|
|
82
80
|
export const getFormConfig = (type: string, configs: Record<string, FormConfig>): FormConfig => {
|
|
83
81
|
switch (type) {
|
package/src/utils/props.ts
CHANGED
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
NODE_DISABLE_DATA_SOURCE_KEY,
|
|
25
25
|
} from '@tmagic/core';
|
|
26
26
|
import { tMagicMessage } from '@tmagic/design';
|
|
27
|
-
import type {
|
|
27
|
+
import type { ChildConfig, DisplayCondsConfig, FormConfig, TabConfig, TabPaneConfig } from '@tmagic/form';
|
|
28
28
|
|
|
29
29
|
export const arrayOptions = [
|
|
30
30
|
{ text: '包含', value: 'include' },
|
|
@@ -107,7 +107,7 @@ export const styleTabConfig: TabPaneConfig = {
|
|
|
107
107
|
'borderStyle',
|
|
108
108
|
'borderColor',
|
|
109
109
|
],
|
|
110
|
-
},
|
|
110
|
+
} as unknown as ChildConfig,
|
|
111
111
|
],
|
|
112
112
|
},
|
|
113
113
|
],
|
|
@@ -168,9 +168,9 @@ export const advancedTabConfig: TabPaneConfig = {
|
|
|
168
168
|
],
|
|
169
169
|
};
|
|
170
170
|
|
|
171
|
-
export const displayTabConfig: TabPaneConfig = {
|
|
171
|
+
export const displayTabConfig: TabPaneConfig<DisplayCondsConfig> = {
|
|
172
172
|
title: '显示条件',
|
|
173
|
-
display: (_state
|
|
173
|
+
display: (_state, { model }) => model.type !== 'page',
|
|
174
174
|
items: [
|
|
175
175
|
{
|
|
176
176
|
name: NODE_CONDS_RESULT_KEY,
|
|
@@ -209,7 +209,7 @@ export const fillConfig = (
|
|
|
209
209
|
const propsConfig: FormConfig = [];
|
|
210
210
|
|
|
211
211
|
// 组件类型,必须要有
|
|
212
|
-
if (!config.find((item) => item.name === 'type')) {
|
|
212
|
+
if (!config.find((item) => 'name' in item && item.name === 'type')) {
|
|
213
213
|
propsConfig.push({
|
|
214
214
|
text: 'type',
|
|
215
215
|
name: 'type',
|
|
@@ -217,7 +217,7 @@ export const fillConfig = (
|
|
|
217
217
|
});
|
|
218
218
|
}
|
|
219
219
|
|
|
220
|
-
if (!config.find((item) => item.name === 'id')) {
|
|
220
|
+
if (!config.find((item) => 'name' in item && item.name === 'id')) {
|
|
221
221
|
// 组件id,必须要有
|
|
222
222
|
propsConfig.push({
|
|
223
223
|
name: 'id',
|
|
@@ -241,14 +241,16 @@ export const fillConfig = (
|
|
|
241
241
|
});
|
|
242
242
|
}
|
|
243
243
|
|
|
244
|
-
if (!config.find((item) => item.name === 'name')) {
|
|
244
|
+
if (!config.find((item) => 'name' in item && item.name === 'name')) {
|
|
245
245
|
propsConfig.push({
|
|
246
246
|
name: 'name',
|
|
247
247
|
text: '组件名称',
|
|
248
248
|
});
|
|
249
249
|
}
|
|
250
250
|
|
|
251
|
-
const noCodeAdvancedTabItems = advancedTabConfig.items.filter(
|
|
251
|
+
const noCodeAdvancedTabItems = advancedTabConfig.items.filter(
|
|
252
|
+
(item) => 'type' in item && item.type !== 'code-select',
|
|
253
|
+
);
|
|
252
254
|
|
|
253
255
|
if (noCodeAdvancedTabItems.length > 0 && disabledCodeBlock) {
|
|
254
256
|
advancedTabConfig.items = noCodeAdvancedTabItems;
|