@tmagic/editor 1.7.8-beta.1 → 1.7.8-beta.2

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.
@@ -5,79 +5,77 @@ import { dataSourceTemplateRegExp, getKeysArray, isNumber } from '@tmagic/utils'
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 = {
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: FormState, { model }: any) => 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: (_formState: FormState, { model }: any) => 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, 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
  ],
@@ -170,7 +170,7 @@ export const advancedTabConfig: TabPaneConfig = {
170
170
 
171
171
  export const displayTabConfig: TabPaneConfig = {
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;