@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
@@ -65,8 +65,9 @@ import type { CodeBlockContent } from '@tmagic/core';
65
65
  import { TMagicButton, TMagicDialog, tMagicMessage, tMagicMessageBox, TMagicTag } from '@tmagic/design';
66
66
  import {
67
67
  type ContainerChangeEventData,
68
+ defineFormConfig,
69
+ defineFormItem,
68
70
  type FormConfig,
69
- type FormState,
70
71
  MFormBox,
71
72
  type TableColumnConfig,
72
73
  } from '@tmagic/form';
@@ -118,7 +119,7 @@ const diffChange = () => {
118
119
  difVisible.value = false;
119
120
  };
120
121
 
121
- const defaultParamColConfig: TableColumnConfig = {
122
+ const defaultParamColConfig = defineFormItem<TableColumnConfig>({
122
123
  type: 'row',
123
124
  label: '参数类型',
124
125
  items: [
@@ -146,76 +147,79 @@ const defaultParamColConfig: TableColumnConfig = {
146
147
  ],
147
148
  },
148
149
  ],
149
- };
150
+ });
150
151
 
151
- const functionConfig = computed<FormConfig>(() => [
152
- {
153
- text: '名称',
154
- name: 'name',
155
- rules: [{ required: true, message: '请输入名称', trigger: 'blur' }],
156
- },
157
- {
158
- text: '描述',
159
- name: 'desc',
160
- },
161
- {
162
- text: '执行时机',
163
- name: 'timing',
164
- type: 'select',
165
- options: () => {
166
- const options = [
167
- { text: '初始化前', value: 'beforeInit' },
168
- { text: '初始化后', value: 'afterInit' },
169
- ];
170
- if (props.dataSourceType !== 'base') {
171
- options.push({ text: '请求前', value: 'beforeRequest' });
172
- options.push({ text: '请求后', value: 'afterRequest' });
173
- }
174
- return options;
175
- },
176
- display: () => props.isDataSource,
177
- },
178
- {
179
- type: 'table',
180
- border: true,
181
- text: '参数',
182
- enableFullscreen: false,
183
- enableToggleMode: false,
184
- name: 'params',
185
- dropSort: false,
186
- items: [
152
+ const functionConfig = computed(
153
+ () =>
154
+ defineFormConfig([
187
155
  {
188
- type: 'text',
189
- label: '参数名',
156
+ text: '名称',
190
157
  name: 'name',
158
+ rules: [{ required: true, message: '请输入名称', trigger: 'blur' }],
191
159
  },
192
160
  {
193
- type: 'text',
194
- label: '描述',
195
- name: 'extra',
161
+ text: '描述',
162
+ name: 'desc',
196
163
  },
197
- codeBlockService.getParamsColConfig() || defaultParamColConfig,
198
- ],
199
- },
200
- {
201
- name: 'content',
202
- type: 'vs-code',
203
- options: inject('codeOptions', {}),
204
- autosize: { minRows: 10, maxRows: 30 },
205
- onChange: (formState: FormState | undefined, code: string) => {
206
- try {
207
- // 检测js代码是否存在语法错误
208
- getEditorConfig('parseDSL')(code);
209
-
210
- return code;
211
- } catch (error: any) {
212
- tMagicMessage.error(error.message);
213
-
214
- throw error;
215
- }
216
- },
217
- },
218
- ]);
164
+ {
165
+ text: '执行时机',
166
+ name: 'timing',
167
+ type: 'select',
168
+ options: () => {
169
+ const options = [
170
+ { text: '初始化前', value: 'beforeInit' },
171
+ { text: '初始化后', value: 'afterInit' },
172
+ ];
173
+ if (props.dataSourceType !== 'base') {
174
+ options.push({ text: '请求前', value: 'beforeRequest' });
175
+ options.push({ text: '请求后', value: 'afterRequest' });
176
+ }
177
+ return options;
178
+ },
179
+ display: () => props.isDataSource,
180
+ },
181
+ {
182
+ type: 'table',
183
+ border: true,
184
+ text: '参数',
185
+ enableFullscreen: false,
186
+ enableToggleMode: false,
187
+ name: 'params',
188
+ dropSort: false,
189
+ items: [
190
+ {
191
+ type: 'text',
192
+ label: '参数名',
193
+ name: 'name',
194
+ },
195
+ {
196
+ type: 'text',
197
+ label: '描述',
198
+ name: 'extra',
199
+ },
200
+ codeBlockService.getParamsColConfig() || defaultParamColConfig,
201
+ ],
202
+ },
203
+ {
204
+ name: 'content',
205
+ type: 'vs-code',
206
+ options: inject('codeOptions', {}),
207
+ autosize: { minRows: 10, maxRows: 30 },
208
+ onChange: (_formState, code: string) => {
209
+ try {
210
+ // 检测js代码是否存在语法错误
211
+ getEditorConfig('parseDSL')(code);
212
+
213
+ return code;
214
+ } catch (error: any) {
215
+ tMagicMessage.error(error.message);
216
+
217
+ throw error;
218
+ }
219
+ },
220
+ },
221
+ ]) as FormConfig,
222
+ );
219
223
 
220
224
  const parseContent = (content: any) => {
221
225
  if (typeof content === 'string') {
@@ -13,7 +13,7 @@
13
13
  <script lang="ts" setup>
14
14
  import { computed, useTemplateRef } from 'vue';
15
15
 
16
- import { type ContainerChangeEventData, type FormConfig, type FormValue, MForm } from '@tmagic/form';
16
+ import { type ContainerChangeEventData, type FormItemConfig, type FormValue, MForm } from '@tmagic/form';
17
17
 
18
18
  import type { CodeParamStatement } from '@editor/type';
19
19
  import { error } from '@editor/utils';
@@ -34,7 +34,7 @@ const emit = defineEmits(['change']);
34
34
 
35
35
  const formRef = useTemplateRef<InstanceType<typeof MForm>>('form');
36
36
 
37
- const getFormConfig = (items: FormConfig = []) => [
37
+ const getFormConfig = (items: FormItemConfig[] = []) => [
38
38
  {
39
39
  type: 'fieldset',
40
40
  items,
@@ -51,7 +51,7 @@ const codeParamsConfig = computed(() =>
51
51
  name,
52
52
  text,
53
53
  extra,
54
- fieldConfig: config,
54
+ fieldConfig: config as FormItemConfig,
55
55
  })),
56
56
  ),
57
57
  );
@@ -50,6 +50,7 @@ import {
50
50
  createValues,
51
51
  type FieldProps,
52
52
  filterFunction,
53
+ type FormItemConfig,
53
54
  type FormState,
54
55
  MSelect,
55
56
  type SelectConfig,
@@ -115,7 +116,7 @@ watch(
115
116
  const selectConfig: SelectConfig = {
116
117
  type: 'select',
117
118
  name: props.name,
118
- disable: props.disabled,
119
+ disabled: props.disabled,
119
120
  options: () => {
120
121
  if (codeDsl.value) {
121
122
  return map(codeDsl.value, (value, key) => ({
@@ -141,7 +142,9 @@ const onCodeIdChangeHandler = (value: any) => {
141
142
 
142
143
  changeRecords.push({
143
144
  propPath: props.prop.replace(`${props.name}`, 'params'),
144
- value: paramsConfig.value.length ? createValues(mForm, paramsConfig.value, {}, props.model.params) : {},
145
+ value: paramsConfig.value.length
146
+ ? createValues(mForm, paramsConfig.value as unknown as FormItemConfig[], {}, props.model.params)
147
+ : {},
145
148
  });
146
149
 
147
150
  emit('change', value, {
@@ -98,7 +98,9 @@ const dataSources = computed(() => dataSourceService.get('dataSources') || []);
98
98
  const disabledDataSource = computed(() => propsService.getDisabledDataSource());
99
99
 
100
100
  const type = computed((): string => {
101
- let type = props.config.fieldConfig?.type;
101
+ if (!props.config.fieldConfig) return '';
102
+
103
+ let type = 'type' in props.config.fieldConfig ? props.config.fieldConfig.type : '';
102
104
  if (typeof type === 'function') {
103
105
  type = type(mForm, {
104
106
  model: props.model,
@@ -106,13 +108,18 @@ const type = computed((): string => {
106
108
  }
107
109
  if (type === 'form') return '';
108
110
  if (type === 'container') return '';
109
- return type?.replace(/([A-Z])/g, '-$1').toLowerCase() || (props.config.items ? '' : 'text');
111
+ return (
112
+ type?.replace(/([A-Z])/g, '-$1').toLowerCase() ||
113
+ (props.config.fieldConfig && 'items' in props.config.fieldConfig ? '' : 'text')
114
+ );
110
115
  });
111
116
 
112
117
  const tagName = computed(() => {
113
118
  const component =
114
119
  getFormField(type.value || 'container') ||
115
- resolveComponent(`m-${props.config.items ? 'form' : 'fields'}-${type.value}`);
120
+ resolveComponent(
121
+ `m-${props.config.fieldConfig && 'items' in props.config.fieldConfig ? 'form' : 'fields'}-${type.value}`,
122
+ );
116
123
  if (typeof component !== 'string') return component;
117
124
  return 'm-fields-text';
118
125
  });
@@ -52,12 +52,15 @@ import { inject, Ref, ref } from 'vue';
52
52
  import type { DataSchema } from '@tmagic/core';
53
53
  import { TMagicButton, tMagicMessage, tMagicMessageBox } from '@tmagic/design';
54
54
  import {
55
+ type CodeConfig,
55
56
  type ContainerChangeEventData,
56
57
  type DataSourceFieldsConfig,
57
58
  type FieldProps,
58
59
  type FormConfig,
59
60
  type FormState,
60
61
  MFormBox,
62
+ type NumberConfig,
63
+ type TextConfig,
61
64
  } from '@tmagic/form';
62
65
  import { type ColumnConfig, MagicTable } from '@tmagic/table';
63
66
  import { getDefaultValueFromFields } from '@tmagic/utils';
@@ -247,7 +250,7 @@ const dataSourceFieldsConfig: FormConfig = [
247
250
  { text: 'true', value: true },
248
251
  { text: 'false', value: false },
249
252
  ],
250
- },
253
+ } as unknown as CodeConfig | NumberConfig | TextConfig,
251
254
  {
252
255
  name: 'enable',
253
256
  text: '是否可用',
@@ -48,6 +48,7 @@ import {
48
48
  type DataSourceMethodSelectConfig,
49
49
  type FieldProps,
50
50
  filterFunction,
51
+ type FormItemConfig,
51
52
  type FormState,
52
53
  MCascader,
53
54
  } from '@tmagic/form';
@@ -142,7 +143,9 @@ const onChangeHandler = (value: any) => {
142
143
 
143
144
  changeRecords.push({
144
145
  propPath: props.prop.replace(`${props.name}`, 'params'),
145
- value: paramsConfig.value.length ? createValues(mForm, paramsConfig.value, {}, props.model.params) : {},
146
+ value: paramsConfig.value.length
147
+ ? createValues(mForm, paramsConfig.value as unknown as FormItemConfig[], {}, props.model.params)
148
+ : {},
146
149
  });
147
150
 
148
151
  emit('change', value, {
@@ -59,18 +59,18 @@ import { ActionType } from '@tmagic/core';
59
59
  import { TMagicButton } from '@tmagic/design';
60
60
  import type {
61
61
  CascaderOption,
62
- ChildConfig,
63
62
  CodeSelectColConfig,
64
63
  ContainerChangeEventData,
65
64
  DataSourceMethodSelectConfig,
65
+ DynamicTypeConfig,
66
66
  EventSelectConfig,
67
67
  FieldProps,
68
68
  FormState,
69
- OnChangeHandlerData,
70
69
  PanelConfig,
71
70
  TableConfig,
71
+ UISelectConfig,
72
72
  } from '@tmagic/form';
73
- import { MContainer as MFormContainer, MPanel, MTable } from '@tmagic/form';
73
+ import { defineFormItem, MContainer as MFormContainer, MPanel, MTable } from '@tmagic/form';
74
74
  import { DATA_SOURCE_FIELDS_CHANGE_EVENT_PREFIX, traverseNode } from '@tmagic/utils';
75
75
 
76
76
  import { useServices } from '@editor/hooks/use-services';
@@ -90,10 +90,10 @@ const { editorService, dataSourceService, eventsService, codeBlockService, props
90
90
 
91
91
  // 事件名称下拉框表单配置
92
92
  const eventNameConfig = computed(() => {
93
- const defaultEventNameConfig: ChildConfig = {
93
+ const defaultEventNameConfig = {
94
94
  name: 'name',
95
95
  text: '事件',
96
- type: (mForm, { formValue }: any) => {
96
+ type: (mForm: FormState | undefined, { formValue }: any) => {
97
97
  if (
98
98
  props.config.src !== 'component' ||
99
99
  (formValue.type === 'page-fragment-container' && formValue.pageFragmentId)
@@ -213,12 +213,12 @@ const actionTypeConfig = computed(() => {
213
213
 
214
214
  // 联动组件配置
215
215
  const targetCompConfig = computed(() => {
216
- const defaultTargetCompConfig = {
216
+ const defaultTargetCompConfig: UISelectConfig = {
217
217
  name: 'to',
218
218
  text: '联动组件',
219
219
  type: 'ui-select',
220
- display: (mForm: FormState, { model }: { model: Record<any, any> }) => model.actionType === ActionType.COMP,
221
- onChange: (MForm: FormState, v: string, { setModel }: OnChangeHandlerData) => {
220
+ display: (_mForm, { model }) => model.actionType === ActionType.COMP,
221
+ onChange: (_MForm, _v, { setModel }) => {
222
222
  setModel('method', '');
223
223
  },
224
224
  };
@@ -227,10 +227,10 @@ const targetCompConfig = computed(() => {
227
227
 
228
228
  // 联动组件动作配置
229
229
  const compActionConfig = computed(() => {
230
- const defaultCompActionConfig: ChildConfig = {
230
+ const defaultCompActionConfig: DynamicTypeConfig = {
231
231
  name: 'method',
232
232
  text: '动作',
233
- type: (mForm, { model }: any) => {
233
+ type: (mForm: FormState | undefined, { model }: any) => {
234
234
  const to = editorService.getNodeById(model.to);
235
235
 
236
236
  if (to && to.type === 'page-fragment-container' && to.pageFragmentId) {
@@ -240,7 +240,7 @@ const compActionConfig = computed(() => {
240
240
  return 'select';
241
241
  },
242
242
  checkStrictly: () => props.config.src !== 'component',
243
- display: (mForm, { model }: any) => model.actionType === ActionType.COMP,
243
+ display: (mForm: FormState | undefined, { model }: any) => model.actionType === ActionType.COMP,
244
244
  options: (mForm: FormState, { model }: any) => {
245
245
  const node = editorService.getNodeById(model.to);
246
246
  if (!node?.type) return [];
@@ -305,62 +305,68 @@ const dataSourceActionConfig = computed(() => {
305
305
  });
306
306
 
307
307
  // 兼容旧的数据格式
308
- const tableConfig = computed<TableConfig>(() => ({
309
- type: 'table',
310
- name: 'events',
311
- items: [
312
- {
313
- name: 'name',
314
- label: '事件名',
315
- type: eventNameConfig.value.type,
316
- options: (mForm: FormState, { formValue }: any) =>
317
- eventsService.getEvent(formValue.type).map((option: any) => ({
318
- text: option.label,
319
- value: option.value,
320
- })),
321
- },
322
- {
323
- name: 'to',
324
- label: '联动组件',
325
- type: 'ui-select',
326
- },
327
- {
328
- name: 'method',
329
- label: '动作',
330
- type: compActionConfig.value.type,
331
- options: (mForm: FormState, { model }: any) => {
332
- const node = editorService.getNodeById(model.to);
333
- if (!node?.type) return [];
334
-
335
- return eventsService.getMethod(node.type, model.to).map((option: any) => ({
336
- text: option.label,
337
- value: option.value,
338
- }));
339
- },
340
- },
341
- ],
342
- }));
308
+ const tableConfig = computed(
309
+ () =>
310
+ defineFormItem({
311
+ type: 'table',
312
+ name: 'events',
313
+ items: [
314
+ {
315
+ name: 'name',
316
+ label: '事件名',
317
+ type: eventNameConfig.value.type,
318
+ options: (mForm: FormState, { formValue }: any) =>
319
+ eventsService.getEvent(formValue.type).map((option: any) => ({
320
+ text: option.label,
321
+ value: option.value,
322
+ })),
323
+ },
324
+ {
325
+ name: 'to',
326
+ label: '联动组件',
327
+ type: 'ui-select',
328
+ },
329
+ {
330
+ name: 'method',
331
+ label: '动作',
332
+ type: compActionConfig.value.type,
333
+ options: (mForm: FormState, { model }: any) => {
334
+ const node = editorService.getNodeById(model.to);
335
+ if (!node?.type) return [];
336
+
337
+ return eventsService.getMethod(node.type, model.to).map((option: any) => ({
338
+ text: option.label,
339
+ value: option.value,
340
+ }));
341
+ },
342
+ },
343
+ ],
344
+ }) as TableConfig,
345
+ );
343
346
 
344
347
  // 组件动作组表单配置
345
- const actionsConfig = computed<PanelConfig>(() => ({
346
- type: 'panel',
347
- items: [
348
- {
349
- type: 'group-list',
350
- name: 'actions',
351
- expandAll: true,
352
- enableToggleMode: false,
353
- titlePrefix: '动作',
348
+ const actionsConfig = computed(
349
+ () =>
350
+ defineFormItem({
351
+ type: 'panel',
354
352
  items: [
355
- actionTypeConfig.value,
356
- targetCompConfig.value,
357
- compActionConfig.value,
358
- codeActionConfig.value,
359
- dataSourceActionConfig.value,
353
+ {
354
+ type: 'group-list',
355
+ name: 'actions',
356
+ expandAll: true,
357
+ enableToggleMode: false,
358
+ titlePrefix: '动作',
359
+ items: [
360
+ actionTypeConfig.value,
361
+ targetCompConfig.value,
362
+ compActionConfig.value,
363
+ codeActionConfig.value,
364
+ dataSourceActionConfig.value,
365
+ ],
366
+ },
360
367
  ],
361
- },
362
- ],
363
- }));
368
+ }) as PanelConfig,
369
+ );
364
370
 
365
371
  // 是否为旧的数据格式
366
372
  const isOldVersion = computed(() => {
@@ -28,10 +28,10 @@
28
28
 
29
29
  <script lang="ts" setup>
30
30
  import { TMagicButton, TMagicInput } from '@tmagic/design';
31
- import type { FieldProps, FormItem } from '@tmagic/form';
31
+ import type { FieldProps, StyleSetterConfig } from '@tmagic/form';
32
32
 
33
33
  const emit = defineEmits(['change']);
34
- defineProps<FieldProps<{ type: 'style-setter' } & FormItem>>();
34
+ defineProps<FieldProps<StyleSetterConfig>>();
35
35
 
36
36
  const horizontalList = [
37
37
  {
@@ -39,46 +39,48 @@
39
39
  import { computed, ref } from 'vue';
40
40
 
41
41
  import type { ContainerChangeEventData, FormValue } from '@tmagic/form';
42
- import { MContainer } from '@tmagic/form';
42
+ import { defineFormItem, type MContainer } from '@tmagic/form';
43
43
  import type { StyleSchema } from '@tmagic/schema';
44
44
 
45
45
  const direction = ref('');
46
46
 
47
- const config = computed(() => ({
48
- items: [
49
- {
50
- name: `border${direction.value}Width`,
51
- text: '边框宽度',
52
- labelWidth: '68px',
53
- type: 'data-source-field-select',
54
- fieldConfig: {
55
- type: 'text',
47
+ const config = computed(() =>
48
+ defineFormItem({
49
+ items: [
50
+ {
51
+ name: `border${direction.value}Width`,
52
+ text: '边框宽度',
53
+ labelWidth: '68px',
54
+ type: 'data-source-field-select',
55
+ fieldConfig: {
56
+ type: 'text',
57
+ },
56
58
  },
57
- },
58
- {
59
- name: `border${direction.value}Color`,
60
- text: '边框颜色',
61
- labelWidth: '68px',
62
- type: 'data-source-field-select',
63
- fieldConfig: {
64
- type: 'colorPicker',
59
+ {
60
+ name: `border${direction.value}Color`,
61
+ text: '边框颜色',
62
+ labelWidth: '68px',
63
+ type: 'data-source-field-select',
64
+ fieldConfig: {
65
+ type: 'colorPicker',
66
+ },
65
67
  },
66
- },
67
- {
68
- name: `border${direction.value}Style`,
69
- text: '边框样式',
70
- labelWidth: '68px',
71
- type: 'data-source-field-select',
72
- fieldConfig: {
73
- type: 'select',
74
- options: ['solid', 'dashed', 'dotted'].map((item) => ({
75
- value: item,
76
- text: item,
77
- })),
68
+ {
69
+ name: `border${direction.value}Style`,
70
+ text: '边框样式',
71
+ labelWidth: '68px',
72
+ type: 'data-source-field-select',
73
+ fieldConfig: {
74
+ type: 'select',
75
+ options: ['solid', 'dashed', 'dotted'].map((item) => ({
76
+ value: item,
77
+ text: item,
78
+ })),
79
+ },
78
80
  },
79
- },
80
- ],
81
- }));
81
+ ],
82
+ }),
83
+ );
82
84
 
83
85
  const selectDirection = (d?: string) => (direction.value = d || '');
84
86
 
@@ -5,7 +5,7 @@
5
5
  <script lang="ts" setup>
6
6
  import { markRaw } from 'vue';
7
7
 
8
- import { ContainerChangeEventData, MContainer } from '@tmagic/form';
8
+ import { type ContainerChangeEventData, defineFormItem, type MContainer } from '@tmagic/form';
9
9
  import type { StyleSchema } from '@tmagic/schema';
10
10
 
11
11
  import BackgroundPosition from '../components/BackgroundPosition.vue';
@@ -21,7 +21,7 @@ const emit = defineEmits<{
21
21
  change: [v: StyleSchema, eventData: ContainerChangeEventData];
22
22
  }>();
23
23
 
24
- const config = {
24
+ const config = defineFormItem({
25
25
  items: [
26
26
  {
27
27
  name: 'backgroundColor',
@@ -39,7 +39,7 @@ const config = {
39
39
  type: 'data-source-field-select',
40
40
  fieldConfig: {
41
41
  type: 'img-upload',
42
- },
42
+ } as any,
43
43
  },
44
44
  {
45
45
  name: 'backgroundSize',
@@ -74,7 +74,7 @@ const config = {
74
74
  labelWidth: '68px',
75
75
  },
76
76
  ],
77
- };
77
+ });
78
78
 
79
79
  const change = (value: StyleSchema, eventData: ContainerChangeEventData) => {
80
80
  emit('change', value, eventData);
@@ -4,7 +4,7 @@
4
4
  </template>
5
5
 
6
6
  <script lang="ts" setup>
7
- import { type ContainerChangeEventData, MContainer } from '@tmagic/form';
7
+ import { type ContainerChangeEventData, defineFormItem, type MContainer } from '@tmagic/form';
8
8
  import type { StyleSchema } from '@tmagic/schema';
9
9
 
10
10
  import Border from '../components/Border.vue';
@@ -19,7 +19,7 @@ const emit = defineEmits<{
19
19
  change: [v: StyleSchema, eventData: ContainerChangeEventData];
20
20
  }>();
21
21
 
22
- const config = {
22
+ const config = defineFormItem({
23
23
  items: [
24
24
  {
25
25
  labelWidth: '68px',
@@ -31,7 +31,7 @@ const config = {
31
31
  },
32
32
  },
33
33
  ],
34
- };
34
+ });
35
35
 
36
36
  const change = (value: StyleSchema, eventData: ContainerChangeEventData) => {
37
37
  emit('change', value, eventData);
@@ -5,7 +5,7 @@
5
5
  <script lang="ts" setup>
6
6
  import { markRaw } from 'vue';
7
7
 
8
- import { ContainerChangeEventData, MContainer } from '@tmagic/form';
8
+ import { type ContainerChangeEventData, defineFormItem, type MContainer } from '@tmagic/form';
9
9
  import type { StyleSchema } from '@tmagic/schema';
10
10
 
11
11
  import { AlignCenter, AlignLeft, AlignRight } from '../icons/text-align';
@@ -20,7 +20,7 @@ const emit = defineEmits<{
20
20
  change: [v: StyleSchema, eventData: ContainerChangeEventData];
21
21
  }>();
22
22
 
23
- const config = {
23
+ const config = defineFormItem({
24
24
  items: [
25
25
  {
26
26
  type: 'row',
@@ -86,7 +86,7 @@ const config = {
86
86
  ],
87
87
  },
88
88
  ],
89
- };
89
+ });
90
90
 
91
91
  const change = (value: StyleSchema, eventData: ContainerChangeEventData) => {
92
92
  emit('change', value, eventData);