@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.
Files changed (35) hide show
  1. package/dist/es/components/CodeBlockEditor.vue_vue_type_script_setup_true_lang.js +6 -6
  2. package/dist/es/fields/CodeSelectCol.vue_vue_type_script_setup_true_lang.js +1 -1
  3. package/dist/es/fields/DataSourceFieldSelect/Index.vue_vue_type_script_setup_true_lang.js +4 -3
  4. package/dist/es/fields/EventSelect.vue_vue_type_script_setup_true_lang.js +5 -5
  5. package/dist/es/fields/StyleSetter/components/Border.vue_vue_type_script_setup_true_lang.js +5 -4
  6. package/dist/es/fields/StyleSetter/pro/Background.vue_vue_type_script_setup_true_lang.js +8 -6
  7. package/dist/es/fields/StyleSetter/pro/Border.vue_vue_type_script_setup_true_lang.js +8 -6
  8. package/dist/es/fields/StyleSetter/pro/Font.vue_vue_type_script_setup_true_lang.js +8 -6
  9. package/dist/es/fields/StyleSetter/pro/Layout.vue_vue_type_script_setup_true_lang.js +9 -8
  10. package/dist/es/fields/StyleSetter/pro/Position.vue_vue_type_script_setup_true_lang.js +8 -6
  11. package/dist/es/services/props.js +2 -1
  12. package/dist/es/utils/data-source/index.js +65 -63
  13. package/dist/es/utils/dep/worker.js +1 -1
  14. package/dist/es/utils/props.js +4 -4
  15. package/dist/tmagic-editor.umd.cjs +120 -107
  16. package/package.json +7 -7
  17. package/src/components/CodeBlockEditor.vue +70 -66
  18. package/src/components/CodeParams.vue +3 -3
  19. package/src/fields/CodeSelectCol.vue +5 -2
  20. package/src/fields/DataSourceFieldSelect/Index.vue +10 -3
  21. package/src/fields/DataSourceFields.vue +4 -1
  22. package/src/fields/DataSourceMethodSelect.vue +4 -1
  23. package/src/fields/EventSelect.vue +69 -63
  24. package/src/fields/StyleSetter/components/BackgroundPosition.vue +2 -2
  25. package/src/fields/StyleSetter/components/Border.vue +35 -33
  26. package/src/fields/StyleSetter/pro/Background.vue +4 -4
  27. package/src/fields/StyleSetter/pro/Border.vue +3 -3
  28. package/src/fields/StyleSetter/pro/Font.vue +3 -3
  29. package/src/fields/StyleSetter/pro/Layout.vue +8 -8
  30. package/src/fields/StyleSetter/pro/Position.vue +3 -3
  31. package/src/services/props.ts +3 -1
  32. package/src/utils/data-source/formConfigs/base.ts +2 -2
  33. package/src/utils/data-source/index.ts +73 -75
  34. package/src/utils/props.ts +10 -8
  35. 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 { ContainerChangeEventData, FormState } from '@tmagic/form';
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: (mForm: FormState, { model }: { model: Record<any, any> }) => model.display === 'flex',
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: (mForm: FormState, { model }: { model: Record<any, any> }) => model.display === 'flex',
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: (mForm: FormState, { model }: { model: Record<any, any> }) => model.display === 'flex',
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: (mForm: FormState, { model }: { model: Record<any, any> }) => model.display === 'flex',
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);
@@ -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 = config;
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,6 +1,6 @@
1
- import { defineFormConfig } from '@tmagic/form';
1
+ import { defineFormConfig, type FormConfig } from '@tmagic/form';
2
2
 
3
- export default () =>
3
+ export default (): FormConfig =>
4
4
  defineFormConfig([
5
5
  {
6
6
  name: 'id',
@@ -1,83 +1,81 @@
1
- import { DataSchema, DataSourceFieldType, DataSourceSchema } from '@tmagic/core';
2
- import { CascaderOption, FormConfig, FormState } from '@tmagic/form';
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 fillConfig = (config: FormConfig): FormConfig => [
9
- ...BaseFormConfig(),
10
- ...config,
11
- {
12
- type: 'tab',
13
- items: [
14
- {
15
- title: '数据定义',
16
- items: [
17
- {
18
- name: 'fields',
19
- type: 'data-source-fields',
20
- defaultValue: () => [],
21
- },
22
- ],
23
- },
24
- {
25
- title: '方法定义',
26
- items: [
27
- {
28
- name: 'methods',
29
- type: 'data-source-methods',
30
- defaultValue: () => [],
31
- },
32
- ],
33
- },
34
- {
35
- title: '事件配置',
36
- items: [
37
- {
38
- name: 'events',
39
- src: 'datasource',
40
- type: 'event-select',
41
- },
42
- ],
43
- },
44
- {
45
- title: 'mock数据',
46
- items: [
47
- {
48
- name: 'mocks',
49
- type: 'data-source-mocks',
50
- defaultValue: () => [],
51
- },
52
- ],
53
- },
54
- {
55
- title: '请求参数裁剪',
56
- display: (_formState: FormState, { model }: any) => model.type === 'http',
57
- items: [
58
- {
59
- name: 'beforeRequest',
60
- type: 'vs-code',
61
- parse: true,
62
- autosize: { minRows: 10, maxRows: 30 },
63
- },
64
- ],
65
- },
66
- {
67
- title: '响应数据裁剪',
68
- display: (_formState: FormState, { model }: any) => model.type === 'http',
69
- items: [
70
- {
71
- name: 'afterResponse',
72
- type: 'vs-code',
73
- parse: true,
74
- autosize: { minRows: 10, maxRows: 30 },
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) {
@@ -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 { FormConfig, FormState, TabConfig, TabPaneConfig } from '@tmagic/form';
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: FormState, { model }: any) => model.type !== 'page',
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((item) => item.type !== 'code-select');
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;