@tmagic/editor 1.3.16 → 1.4.0-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.
Files changed (129) hide show
  1. package/dist/style.css +25 -9
  2. package/dist/tmagic-editor.js +1048 -632
  3. package/dist/tmagic-editor.umd.cjs +1065 -647
  4. package/package.json +23 -21
  5. package/src/components/CodeBlockEditor.vue +82 -59
  6. package/src/components/FloatingBox.vue +71 -25
  7. package/src/components/SplitView.vue +46 -35
  8. package/src/fields/Code.vue +12 -10
  9. package/src/fields/CodeLink.vue +9 -9
  10. package/src/fields/CodeSelect.vue +7 -5
  11. package/src/fields/CodeSelectCol.vue +1 -1
  12. package/src/fields/DataSourceFieldSelect.vue +118 -27
  13. package/src/fields/DataSourceFields.vue +10 -3
  14. package/src/fields/DataSourceInput.vue +7 -7
  15. package/src/fields/DataSourceMethodSelect.vue +1 -1
  16. package/src/fields/DataSourceMethods.vue +3 -3
  17. package/src/fields/DataSourceMocks.vue +3 -3
  18. package/src/fields/DataSourceSelect.vue +6 -18
  19. package/src/fields/EventSelect.vue +1 -1
  20. package/src/fields/KeyValue.vue +8 -8
  21. package/src/fields/PageFragmentSelect.vue +1 -1
  22. package/src/fields/UISelect.vue +5 -5
  23. package/src/hooks/index.ts +2 -0
  24. package/src/hooks/use-code-block-edit.ts +1 -2
  25. package/src/hooks/use-editor-content-height.ts +20 -0
  26. package/src/hooks/use-float-box.ts +8 -8
  27. package/src/hooks/use-window-rect.ts +20 -0
  28. package/src/index.ts +2 -2
  29. package/src/layouts/Framework.vue +33 -34
  30. package/src/layouts/NavMenu.vue +21 -2
  31. package/src/layouts/PropsPanel.vue +35 -0
  32. package/src/layouts/sidebar/Sidebar.vue +18 -8
  33. package/src/layouts/sidebar/code-block/CodeBlockListPanel.vue +0 -1
  34. package/src/layouts/workspace/viewer/NodeListMenu.vue +1 -0
  35. package/src/services/BaseService.ts +5 -2
  36. package/src/services/codeBlock.ts +14 -8
  37. package/src/services/dataSource.ts +39 -26
  38. package/src/services/editor.ts +46 -25
  39. package/src/services/events.ts +4 -4
  40. package/src/services/props.ts +44 -35
  41. package/src/services/stageOverlay.ts +16 -9
  42. package/src/services/storage.ts +14 -8
  43. package/src/services/ui.ts +26 -19
  44. package/src/theme/code-block.scss +0 -5
  45. package/src/theme/code-editor.scss +6 -0
  46. package/src/theme/floating-box.scss +4 -2
  47. package/src/theme/props-panel.scss +14 -0
  48. package/src/theme/sidebar.scss +6 -3
  49. package/src/type.ts +87 -37
  50. package/src/utils/operator.ts +37 -39
  51. package/src/utils/props.ts +174 -37
  52. package/types/components/CodeBlockEditor.vue.d.ts +46 -25
  53. package/types/components/CodeParams.vue.d.ts +5 -5
  54. package/types/components/ContentMenu.vue.d.ts +12 -12
  55. package/types/components/FloatingBox.vue.d.ts +42 -55
  56. package/types/components/Icon.vue.d.ts +3 -3
  57. package/types/components/Resizer.vue.d.ts +3 -3
  58. package/types/components/ScrollBar.vue.d.ts +3 -3
  59. package/types/components/ScrollViewer.vue.d.ts +12 -12
  60. package/types/components/SearchInput.vue.d.ts +1 -1
  61. package/types/components/SplitView.vue.d.ts +13 -11
  62. package/types/components/ToolButton.vue.d.ts +13 -13
  63. package/types/components/Tree.vue.d.ts +24 -14
  64. package/types/components/TreeNode.vue.d.ts +22 -12
  65. package/types/fields/Code.vue.d.ts +14 -14
  66. package/types/fields/CodeLink.vue.d.ts +6 -10
  67. package/types/fields/CodeSelect.vue.d.ts +14 -14
  68. package/types/fields/CodeSelectCol.vue.d.ts +11 -11
  69. package/types/fields/DataSourceFieldSelect.vue.d.ts +11 -11
  70. package/types/fields/DataSourceFields.vue.d.ts +11 -11
  71. package/types/fields/DataSourceInput.vue.d.ts +14 -18
  72. package/types/fields/DataSourceMethodSelect.vue.d.ts +11 -11
  73. package/types/fields/DataSourceMethods.vue.d.ts +11 -11
  74. package/types/fields/DataSourceMocks.vue.d.ts +11 -11
  75. package/types/fields/DataSourceSelect.vue.d.ts +13 -26
  76. package/types/fields/EventSelect.vue.d.ts +3 -3
  77. package/types/fields/KeyValue.vue.d.ts +14 -18
  78. package/types/fields/PageFragmentSelect.vue.d.ts +11 -11
  79. package/types/fields/UISelect.vue.d.ts +8 -4
  80. package/types/hooks/index.d.ts +2 -0
  81. package/types/hooks/use-code-block-edit.d.ts +66 -90
  82. package/types/hooks/use-data-source-method.d.ts +66 -90
  83. package/types/hooks/use-editor-content-height.d.ts +3 -0
  84. package/types/hooks/use-node-status.d.ts +6 -1
  85. package/types/hooks/use-window-rect.d.ts +6 -0
  86. package/types/icons/AppManageIcon.vue.d.ts +1 -1
  87. package/types/icons/CenterIcon.vue.d.ts +1 -1
  88. package/types/icons/CodeIcon.vue.d.ts +1 -1
  89. package/types/icons/FolderMinusIcon.vue.d.ts +1 -1
  90. package/types/icons/PinIcon.vue.d.ts +1 -1
  91. package/types/icons/PinnedIcon.vue.d.ts +1 -1
  92. package/types/layouts/AddPageBox.vue.d.ts +3 -3
  93. package/types/layouts/CodeEditor.vue.d.ts +12 -12
  94. package/types/layouts/Framework.vue.d.ts +9 -9
  95. package/types/layouts/NavMenu.vue.d.ts +11 -11
  96. package/types/layouts/PropsPanel.vue.d.ts +193 -243
  97. package/types/layouts/page-bar/AddButton.vue.d.ts +3 -3
  98. package/types/layouts/page-bar/PageBar.vue.d.ts +8 -8
  99. package/types/layouts/page-bar/PageBarScrollContainer.vue.d.ts +8 -8
  100. package/types/layouts/page-bar/SwitchTypeButton.vue.d.ts +3 -3
  101. package/types/layouts/sidebar/ComponentListPanel.vue.d.ts +1 -1
  102. package/types/layouts/sidebar/Sidebar.vue.d.ts +13 -13
  103. package/types/layouts/sidebar/code-block/CodeBlockList.vue.d.ts +10 -10
  104. package/types/layouts/sidebar/code-block/CodeBlockListPanel.vue.d.ts +9 -9
  105. package/types/layouts/sidebar/data-source/DataSourceConfigPanel.vue.d.ts +3 -3
  106. package/types/layouts/sidebar/data-source/DataSourceList.vue.d.ts +3 -3
  107. package/types/layouts/sidebar/data-source/DataSourceListPanel.vue.d.ts +9 -9
  108. package/types/layouts/sidebar/layer/LayerMenu.vue.d.ts +11 -11
  109. package/types/layouts/sidebar/layer/LayerNodeTool.vue.d.ts +3 -3
  110. package/types/layouts/sidebar/layer/LayerPanel.vue.d.ts +9 -9
  111. package/types/layouts/sidebar/layer/use-click.d.ts +42 -76
  112. package/types/layouts/sidebar/layer/use-node-status.d.ts +6 -1
  113. package/types/layouts/workspace/Breadcrumb.vue.d.ts +1 -1
  114. package/types/layouts/workspace/Workspace.vue.d.ts +12 -12
  115. package/types/layouts/workspace/viewer/NodeListMenu.vue.d.ts +1 -1
  116. package/types/layouts/workspace/viewer/Stage.vue.d.ts +11 -11
  117. package/types/layouts/workspace/viewer/StageOverlay.vue.d.ts +1 -1
  118. package/types/layouts/workspace/viewer/ViewerMenu.vue.d.ts +12 -12
  119. package/types/services/BaseService.d.ts +5 -2
  120. package/types/services/codeBlock.d.ts +8 -0
  121. package/types/services/dataSource.d.ts +9 -2
  122. package/types/services/editor.d.ts +8 -1
  123. package/types/services/props.d.ts +15 -22
  124. package/types/services/stageOverlay.d.ts +9 -2
  125. package/types/services/storage.d.ts +8 -0
  126. package/types/services/ui.d.ts +20 -8
  127. package/types/type.d.ts +56 -32
  128. package/types/utils/operator.d.ts +1 -1
  129. package/types/utils/props.d.ts +2 -13
@@ -15,55 +15,53 @@ import { generatePageNameByApp, getInitPositionStyle } from '@editor/utils/edito
15
15
  * @param config 待粘贴的元素配置(复制时保存的那份配置)
16
16
  * @returns
17
17
  */
18
- export const beforePaste = async (position: PastePosition, config: MNode[]): Promise<MNode[]> => {
18
+ export const beforePaste = (position: PastePosition, config: MNode[]): MNode[] => {
19
19
  if (!config[0]?.style) return config;
20
20
  const curNode = editorService.get('node');
21
21
  // 将数组中第一个元素的坐标作为参照点
22
22
  const { left: referenceLeft, top: referenceTop } = config[0].style;
23
23
  // 坐标校准后的粘贴数据
24
- const pasteConfigs: MNode[] = await Promise.all(
25
- config.map(async (configItem: MNode): Promise<MNode> => {
26
- // 解构 position 对象,从 position 删除 offsetX、offsetY字段
27
- const { offsetX = 0, offsetY = 0, ...positionClone } = position;
28
- let pastePosition = positionClone;
24
+ const pasteConfigs: MNode[] = config.map((configItem: MNode): MNode => {
25
+ // 解构 position 对象,从 position 删除 offsetX、offsetY字段
26
+ const { offsetX = 0, offsetY = 0, ...positionClone } = position;
27
+ let pastePosition = positionClone;
29
28
 
30
- if (!isEmpty(pastePosition) && curNode?.items) {
31
- // 如果没有传入粘贴坐标则可能为键盘操作,不再转换
32
- // 如果粘贴时选中了容器,则将元素粘贴到容器内,坐标需要转换为相对于容器的坐标
33
- pastePosition = getPositionInContainer(pastePosition, curNode.id);
34
- }
29
+ if (!isEmpty(pastePosition) && curNode?.items) {
30
+ // 如果没有传入粘贴坐标则可能为键盘操作,不再转换
31
+ // 如果粘贴时选中了容器,则将元素粘贴到容器内,坐标需要转换为相对于容器的坐标
32
+ pastePosition = getPositionInContainer(pastePosition, curNode.id);
33
+ }
35
34
 
36
- // 将所有待粘贴元素坐标相对于多选第一个元素坐标重新计算,以保证多选粘贴后元素间距不变
37
- if (pastePosition.left && configItem.style?.left) {
38
- pastePosition.left = configItem.style.left - referenceLeft + pastePosition.left;
39
- }
40
- if (pastePosition.top && configItem.style?.top) {
41
- pastePosition.top = configItem.style?.top - referenceTop + pastePosition.top;
42
- }
43
- const pasteConfig = await propsService.setNewItemId(configItem, false);
35
+ // 将所有待粘贴元素坐标相对于多选第一个元素坐标重新计算,以保证多选粘贴后元素间距不变
36
+ if (pastePosition.left && configItem.style?.left) {
37
+ pastePosition.left = configItem.style.left - referenceLeft + pastePosition.left;
38
+ }
39
+ if (pastePosition.top && configItem.style?.top) {
40
+ pastePosition.top = configItem.style?.top - referenceTop + pastePosition.top;
41
+ }
42
+ const pasteConfig = propsService.setNewItemId(configItem, false);
44
43
 
45
- if (pasteConfig.style) {
46
- const { left, top } = pasteConfig.style;
47
- // 判断能转换为数字时,做粘贴偏移量计算
48
- if (typeof left === 'number' || (!!left && !isNaN(Number(left)))) {
49
- pasteConfig.style.left = Number(left) + offsetX;
50
- }
51
- if (typeof top === 'number' || (!!top && !isNaN(Number(top)))) {
52
- pasteConfig.style.top = Number(top) + offsetY;
53
- }
54
-
55
- pasteConfig.style = {
56
- ...pasteConfig.style,
57
- ...pastePosition,
58
- };
44
+ if (pasteConfig.style) {
45
+ const { left, top } = pasteConfig.style;
46
+ // 判断能转换为数字时,做粘贴偏移量计算
47
+ if (typeof left === 'number' || (!!left && !isNaN(Number(left)))) {
48
+ pasteConfig.style.left = Number(left) + offsetX;
59
49
  }
60
- const root = editorService.get('root');
61
- if ((isPage(pasteConfig) || isPageFragment(pasteConfig)) && root) {
62
- pasteConfig.name = generatePageNameByApp(root, isPage(pasteConfig) ? NodeType.PAGE : NodeType.PAGE_FRAGMENT);
50
+ if (typeof top === 'number' || (!!top && !isNaN(Number(top)))) {
51
+ pasteConfig.style.top = Number(top) + offsetY;
63
52
  }
64
- return pasteConfig as MNode;
65
- }),
66
- );
53
+
54
+ pasteConfig.style = {
55
+ ...pasteConfig.style,
56
+ ...pastePosition,
57
+ };
58
+ }
59
+ const root = editorService.get('root');
60
+ if ((isPage(pasteConfig) || isPageFragment(pasteConfig)) && root) {
61
+ pasteConfig.name = generatePageNameByApp(root, isPage(pasteConfig) ? NodeType.PAGE : NodeType.PAGE_FRAGMENT);
62
+ }
63
+ return pasteConfig as MNode;
64
+ });
67
65
  return pasteConfigs;
68
66
  };
69
67
 
@@ -41,7 +41,6 @@ const numberOptions = [
41
41
 
42
42
  export const styleTabConfig: TabPaneConfig = {
43
43
  title: '样式',
44
- labelWidth: '80px',
45
44
  items: [
46
45
  {
47
46
  name: 'style',
@@ -51,30 +50,59 @@ export const styleTabConfig: TabPaneConfig = {
51
50
  legend: '位置',
52
51
  items: [
53
52
  {
53
+ type: 'data-source-field-select',
54
54
  name: 'position',
55
- type: 'checkbox',
56
- activeValue: 'fixed',
57
- inactiveValue: 'absolute',
58
- defaultValue: 'absolute',
59
55
  text: '固定定位',
56
+ checkStrictly: false,
57
+ dataSourceFieldType: ['string'],
58
+ fieldConfig: {
59
+ type: 'checkbox',
60
+ activeValue: 'fixed',
61
+ inactiveValue: 'absolute',
62
+ defaultValue: 'absolute',
63
+ },
60
64
  },
61
65
  {
66
+ type: 'data-source-field-select',
62
67
  name: 'left',
63
68
  text: 'left',
69
+ checkStrictly: false,
70
+ dataSourceFieldType: ['string', 'number'],
71
+ fieldConfig: {
72
+ type: 'text',
73
+ },
64
74
  },
65
75
  {
76
+ type: 'data-source-field-select',
66
77
  name: 'top',
67
78
  text: 'top',
79
+ checkStrictly: false,
80
+ dataSourceFieldType: ['string', 'number'],
81
+ fieldConfig: {
82
+ type: 'text',
83
+ },
68
84
  disabled: (vm: FormState, { model }: any) =>
69
85
  model.position === 'fixed' && model._magic_position === 'fixedBottom',
70
86
  },
71
87
  {
88
+ type: 'data-source-field-select',
72
89
  name: 'right',
73
90
  text: 'right',
91
+ checkStrictly: false,
92
+ dataSourceFieldType: ['string', 'number'],
93
+ fieldConfig: {
94
+ type: 'text',
95
+ },
74
96
  },
75
97
  {
98
+ type: 'data-source-field-select',
76
99
  name: 'bottom',
77
100
  text: 'bottom',
101
+ checkStrictly: false,
102
+ dataSourceFieldType: ['string', 'number'],
103
+ fieldConfig: {
104
+ type: 'text',
105
+ },
78
106
  disabled: (vm: FormState, { model }: any) =>
79
107
  model.position === 'fixed' && model._magic_position === 'fixedTop',
80
108
  },
@@ -85,12 +113,42 @@ export const styleTabConfig: TabPaneConfig = {
85
113
  legend: '盒子',
86
114
  items: [
87
115
  {
116
+ type: 'data-source-field-select',
88
117
  name: 'width',
89
118
  text: '宽度',
119
+ checkStrictly: false,
120
+ dataSourceFieldType: ['string', 'number'],
121
+ fieldConfig: {
122
+ type: 'text',
123
+ },
90
124
  },
91
125
  {
126
+ type: 'data-source-field-select',
92
127
  name: 'height',
93
128
  text: '高度',
129
+ checkStrictly: false,
130
+ dataSourceFieldType: ['string', 'number'],
131
+ fieldConfig: {
132
+ type: 'text',
133
+ },
134
+ },
135
+ {
136
+ type: 'data-source-field-select',
137
+ text: 'overflow',
138
+ name: 'overflow',
139
+ checkStrictly: false,
140
+ dataSourceFieldType: ['string'],
141
+ fieldConfig: {
142
+ type: 'select',
143
+ options: [
144
+ { text: 'visible', value: 'visible' },
145
+ { text: 'hidden', value: 'hidden' },
146
+ { text: 'clip', value: 'clip' },
147
+ { text: 'scroll', value: 'scroll' },
148
+ { text: 'auto', value: 'auto' },
149
+ { text: 'overlay', value: 'overlay' },
150
+ ],
151
+ },
94
152
  },
95
153
  ],
96
154
  },
@@ -99,32 +157,48 @@ export const styleTabConfig: TabPaneConfig = {
99
157
  legend: '边框',
100
158
  items: [
101
159
  {
160
+ type: 'data-source-field-select',
102
161
  name: 'borderWidth',
103
162
  text: '宽度',
104
163
  defaultValue: '0',
164
+ checkStrictly: false,
165
+ dataSourceFieldType: ['string', 'number'],
166
+ fieldConfig: {
167
+ type: 'text',
168
+ },
105
169
  },
106
170
  {
171
+ type: 'data-source-field-select',
107
172
  name: 'borderColor',
108
173
  text: '颜色',
109
- type: 'colorPicker',
174
+ checkStrictly: false,
175
+ dataSourceFieldType: ['string'],
176
+ fieldConfig: {
177
+ type: 'text',
178
+ },
110
179
  },
111
180
  {
181
+ type: 'data-source-field-select',
112
182
  name: 'borderStyle',
113
183
  text: '样式',
114
- type: 'select',
115
184
  defaultValue: 'none',
116
- options: [
117
- { text: 'none', value: 'none' },
118
- { text: 'hidden', value: 'hidden' },
119
- { text: 'dotted', value: 'dotted' },
120
- { text: 'dashed', value: 'dashed' },
121
- { text: 'solid', value: 'solid' },
122
- { text: 'double', value: 'double' },
123
- { text: 'groove', value: 'groove' },
124
- { text: 'ridge', value: 'ridge' },
125
- { text: 'inset', value: 'inset' },
126
- { text: 'outset', value: 'outset' },
127
- ],
185
+ checkStrictly: false,
186
+ dataSourceFieldType: ['string'],
187
+ fieldConfig: {
188
+ type: 'select',
189
+ options: [
190
+ { text: 'none', value: 'none' },
191
+ { text: 'hidden', value: 'hidden' },
192
+ { text: 'dotted', value: 'dotted' },
193
+ { text: 'dashed', value: 'dashed' },
194
+ { text: 'solid', value: 'solid' },
195
+ { text: 'double', value: 'double' },
196
+ { text: 'groove', value: 'groove' },
197
+ { text: 'ridge', value: 'ridge' },
198
+ { text: 'inset', value: 'inset' },
199
+ { text: 'outset', value: 'outset' },
200
+ ],
201
+ },
128
202
  },
129
203
  ],
130
204
  },
@@ -133,31 +207,53 @@ export const styleTabConfig: TabPaneConfig = {
133
207
  legend: '背景',
134
208
  items: [
135
209
  {
210
+ type: 'data-source-field-select',
136
211
  name: 'backgroundImage',
137
212
  text: '背景图',
213
+ checkStrictly: false,
214
+ dataSourceFieldType: ['string'],
215
+ fieldConfig: {
216
+ type: 'text',
217
+ },
138
218
  },
139
219
  {
220
+ type: 'data-source-field-select',
140
221
  name: 'backgroundColor',
141
222
  text: '背景颜色',
142
- type: 'colorPicker',
223
+ checkStrictly: false,
224
+ dataSourceFieldType: ['string'],
225
+ fieldConfig: {
226
+ type: 'colorPicker',
227
+ },
143
228
  },
144
229
  {
230
+ type: 'data-source-field-select',
145
231
  name: 'backgroundRepeat',
146
232
  text: '背景图重复',
147
- type: 'select',
148
233
  defaultValue: 'no-repeat',
149
- options: [
150
- { text: 'repeat', value: 'repeat' },
151
- { text: 'repeat-x', value: 'repeat-x' },
152
- { text: 'repeat-y', value: 'repeat-y' },
153
- { text: 'no-repeat', value: 'no-repeat' },
154
- { text: 'inherit', value: 'inherit' },
155
- ],
234
+ checkStrictly: false,
235
+ dataSourceFieldType: ['string'],
236
+ fieldConfig: {
237
+ type: 'select',
238
+ options: [
239
+ { text: 'repeat', value: 'repeat' },
240
+ { text: 'repeat-x', value: 'repeat-x' },
241
+ { text: 'repeat-y', value: 'repeat-y' },
242
+ { text: 'no-repeat', value: 'no-repeat' },
243
+ { text: 'inherit', value: 'inherit' },
244
+ ],
245
+ },
156
246
  },
157
247
  {
248
+ type: 'data-source-field-select',
158
249
  name: 'backgroundSize',
159
250
  text: '背景图大小',
160
251
  defaultValue: '100% 100%',
252
+ checkStrictly: false,
253
+ dataSourceFieldType: ['string'],
254
+ fieldConfig: {
255
+ type: 'text',
256
+ },
161
257
  },
162
258
  ],
163
259
  },
@@ -166,17 +262,34 @@ export const styleTabConfig: TabPaneConfig = {
166
262
  legend: '字体',
167
263
  items: [
168
264
  {
265
+ type: 'data-source-field-select',
169
266
  name: 'color',
170
267
  text: '颜色',
171
- type: 'colorPicker',
268
+ checkStrictly: false,
269
+ dataSourceFieldType: ['string'],
270
+ fieldConfig: {
271
+ type: 'colorPicker',
272
+ },
172
273
  },
173
274
  {
275
+ type: 'data-source-field-select',
174
276
  name: 'fontSize',
175
277
  text: '大小',
278
+ checkStrictly: false,
279
+ dataSourceFieldType: ['string', 'number'],
280
+ fieldConfig: {
281
+ type: 'text',
282
+ },
176
283
  },
177
284
  {
285
+ type: 'data-source-field-select',
178
286
  name: 'fontWeight',
179
287
  text: '粗细',
288
+ checkStrictly: false,
289
+ dataSourceFieldType: ['string', 'number'],
290
+ fieldConfig: {
291
+ type: 'text',
292
+ },
180
293
  },
181
294
  ],
182
295
  },
@@ -186,12 +299,24 @@ export const styleTabConfig: TabPaneConfig = {
186
299
  name: 'transform',
187
300
  items: [
188
301
  {
302
+ type: 'data-source-field-select',
189
303
  name: 'rotate',
190
304
  text: '旋转角度',
305
+ checkStrictly: false,
306
+ dataSourceFieldType: ['string'],
307
+ fieldConfig: {
308
+ type: 'text',
309
+ },
191
310
  },
192
311
  {
312
+ type: 'data-source-field-select',
193
313
  name: 'scale',
194
314
  text: '缩放',
315
+ checkStrictly: false,
316
+ dataSourceFieldType: ['number', 'string'],
317
+ fieldConfig: {
318
+ type: 'text',
319
+ },
195
320
  },
196
321
  ],
197
322
  },
@@ -219,13 +344,11 @@ export const advancedTabConfig: TabPaneConfig = {
219
344
  {
220
345
  name: 'created',
221
346
  text: 'created',
222
- labelWidth: '100px',
223
347
  type: 'code-select',
224
348
  },
225
349
  {
226
350
  name: 'mounted',
227
351
  text: 'mounted',
228
- labelWidth: '100px',
229
352
  type: 'code-select',
230
353
  },
231
354
  ],
@@ -250,15 +373,23 @@ export const displayTabConfig: TabPaneConfig = {
250
373
  name: 'field',
251
374
  value: 'key',
252
375
  label: '字段',
376
+ checkStrictly: false,
377
+ dataSourceFieldType: ['string', 'number', 'boolean', 'any'],
253
378
  },
254
379
  {
255
380
  type: 'select',
256
381
  options: (mForm, { model }) => {
257
- const [id, field] = model.field;
382
+ const [id, ...fieldNames] = model.field;
258
383
 
259
384
  const ds = dataSourceService.getDataSourceById(id);
260
385
 
261
- const type = ds?.fields.find((f) => f.name === field)?.type;
386
+ let fields = ds?.fields || [];
387
+ let type = '';
388
+ (fieldNames || []).forEach((fieldName: string) => {
389
+ const field = fields.find((f) => f.name === fieldName);
390
+ fields = field?.fields || [];
391
+ type = field?.type || '';
392
+ });
262
393
 
263
394
  if (type === 'array') {
264
395
  return arrayOptions;
@@ -290,11 +421,17 @@ export const displayTabConfig: TabPaneConfig = {
290
421
  {
291
422
  name: 'value',
292
423
  type: (mForm, { model }) => {
293
- const [id, field] = model.field;
424
+ const [id, ...fieldNames] = model.field;
294
425
 
295
426
  const ds = dataSourceService.getDataSourceById(id);
296
427
 
297
- const type = ds?.fields.find((f) => f.name === field)?.type;
428
+ let fields = ds?.fields || [];
429
+ let type = '';
430
+ (fieldNames || []).forEach((fieldName: string) => {
431
+ const field = fields.find((f) => f.name === fieldName);
432
+ fields = field?.fields || [];
433
+ type = field?.type || '';
434
+ });
298
435
 
299
436
  if (type === 'number') {
300
437
  return 'number';
@@ -331,13 +468,13 @@ export const displayTabConfig: TabPaneConfig = {
331
468
  * @param config 组件属性配置
332
469
  * @returns Object
333
470
  */
334
- export const fillConfig = (config: FormConfig = []) => [
471
+ export const fillConfig = (config: FormConfig = [], labelWidth = '80px'): FormConfig => [
335
472
  {
336
473
  type: 'tab',
474
+ labelWidth,
337
475
  items: [
338
476
  {
339
477
  title: '属性',
340
- labelWidth: '80px',
341
478
  items: [
342
479
  // 组件类型,必须要有
343
480
  {
@@ -1,32 +1,53 @@
1
1
  import type { CodeBlockContent } from '@tmagic/schema';
2
2
  import type { SlideType } from '../type';
3
- declare const _default: import("vue").DefineComponent<__VLS_TypePropsToRuntimeProps<{
4
- content: CodeBlockContent;
5
- disabled?: boolean | undefined;
6
- isDataSource?: boolean | undefined;
7
- dataSourceType?: string | undefined;
8
- slideType?: SlideType | undefined;
9
- }>, {
10
- show(): void;
11
- hide(): void;
3
+ declare const _default: import("vue").DefineComponent<{
4
+ width: import("vue").PropType<number>;
5
+ visible: import("vue").PropType<boolean>;
6
+ content: {
7
+ type: import("vue").PropType<CodeBlockContent>;
8
+ required: true;
9
+ };
10
+ disabled: {
11
+ type: import("vue").PropType<boolean>;
12
+ };
13
+ isDataSource: {
14
+ type: import("vue").PropType<boolean>;
15
+ };
16
+ dataSourceType: {
17
+ type: import("vue").PropType<string>;
18
+ };
19
+ slideType: {
20
+ type: import("vue").PropType<SlideType>;
21
+ };
22
+ }, {
23
+ show(): Promise<void>;
24
+ hide(): Promise<void>;
12
25
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
26
+ "update:width": (width: number) => void;
27
+ "update:visible": (visible: boolean) => void;
13
28
  submit: (values: CodeBlockContent) => void;
14
- }, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
15
- content: CodeBlockContent;
16
- disabled?: boolean | undefined;
17
- isDataSource?: boolean | undefined;
18
- dataSourceType?: string | undefined;
19
- slideType?: SlideType | undefined;
20
- }>>> & {
29
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
30
+ width: import("vue").PropType<number>;
31
+ visible: import("vue").PropType<boolean>;
32
+ content: {
33
+ type: import("vue").PropType<CodeBlockContent>;
34
+ required: true;
35
+ };
36
+ disabled: {
37
+ type: import("vue").PropType<boolean>;
38
+ };
39
+ isDataSource: {
40
+ type: import("vue").PropType<boolean>;
41
+ };
42
+ dataSourceType: {
43
+ type: import("vue").PropType<string>;
44
+ };
45
+ slideType: {
46
+ type: import("vue").PropType<SlideType>;
47
+ };
48
+ }>> & {
21
49
  onSubmit?: ((values: CodeBlockContent) => any) | undefined;
50
+ "onUpdate:width"?: ((width: number) => any) | undefined;
51
+ "onUpdate:visible"?: ((visible: boolean) => any) | undefined;
22
52
  }, {}, {}>;
23
53
  export default _default;
24
- type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
25
- type __VLS_TypePropsToRuntimeProps<T> = {
26
- [K in keyof T]-?: {} extends Pick<T, K> ? {
27
- type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
28
- } : {
29
- type: import('vue').PropType<T[K]>;
30
- required: true;
31
- };
32
- };
@@ -1,15 +1,15 @@
1
1
  import type { CodeParamStatement } from '../type';
2
- declare const _default: import("vue").DefineComponent<__VLS_TypePropsToRuntimeProps<{
2
+ declare const _default: import("vue").DefineComponent<__VLS_TypePropsToOption<{
3
3
  model: any;
4
- size?: "default" | "small" | "large" | undefined;
4
+ size?: "small" | "large" | "default" | undefined;
5
5
  disabled?: boolean | undefined;
6
6
  name: string;
7
7
  paramsConfig: CodeParamStatement[];
8
8
  }>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
9
9
  change: (...args: any[]) => void;
10
- }, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
10
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<{
11
11
  model: any;
12
- size?: "default" | "small" | "large" | undefined;
12
+ size?: "small" | "large" | "default" | undefined;
13
13
  disabled?: boolean | undefined;
14
14
  name: string;
15
15
  paramsConfig: CodeParamStatement[];
@@ -18,7 +18,7 @@ declare const _default: import("vue").DefineComponent<__VLS_TypePropsToRuntimePr
18
18
  }, {}, {}>;
19
19
  export default _default;
20
20
  type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
21
- type __VLS_TypePropsToRuntimeProps<T> = {
21
+ type __VLS_TypePropsToOption<T> = {
22
22
  [K in keyof T]-?: {} extends Pick<T, K> ? {
23
23
  type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
24
24
  } : {
@@ -1,5 +1,5 @@
1
1
  import { MenuButton, MenuComponent } from '../type';
2
- declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
2
+ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToOption<{
3
3
  menuData?: (MenuButton | MenuComponent)[] | undefined;
4
4
  isSubMenu?: boolean | undefined;
5
5
  active?: string | number | undefined;
@@ -25,10 +25,10 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
25
25
  clientX: number;
26
26
  }) => void;
27
27
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
28
- mouseenter: () => void;
29
28
  show: () => void;
30
29
  hide: () => void;
31
- }, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
30
+ mouseenter: () => void;
31
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<{
32
32
  menuData?: (MenuButton | MenuComponent)[] | undefined;
33
33
  isSubMenu?: boolean | undefined;
34
34
  active?: string | number | undefined;
@@ -49,15 +49,6 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
49
49
  title?(_: {}): any;
50
50
  }>;
51
51
  export default _default;
52
- type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
53
- type __VLS_TypePropsToRuntimeProps<T> = {
54
- [K in keyof T]-?: {} extends Pick<T, K> ? {
55
- type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
56
- } : {
57
- type: import('vue').PropType<T[K]>;
58
- required: true;
59
- };
60
- };
61
52
  type __VLS_WithDefaults<P, D> = {
62
53
  [K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
63
54
  default: D[K];
@@ -71,3 +62,12 @@ type __VLS_WithTemplateSlots<T, S> = T & {
71
62
  $slots: S;
72
63
  };
73
64
  };
65
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
66
+ type __VLS_TypePropsToOption<T> = {
67
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
68
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
69
+ } : {
70
+ type: import('vue').PropType<T[K]>;
71
+ required: true;
72
+ };
73
+ };