amis-editor 4.2.0-beta.3 → 5.1.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (221) hide show
  1. package/dist/6dbcbb49b6fd405190a9.png +0 -0
  2. package/dist/component/Editor.d.ts +16 -0
  3. package/dist/component/RegionWrapper.d.ts +10 -0
  4. package/dist/component/ScaffoldModal.d.ts +1 -1
  5. package/dist/component/VRenderer.d.ts +10 -0
  6. package/dist/component/control/APIControl.d.ts +1158 -0
  7. package/dist/component/control/ActionAPIControl.d.ts +1158 -0
  8. package/dist/component/control/BadgeControl.d.ts +133 -0
  9. package/dist/component/control/BaseControl.d.ts +248 -0
  10. package/dist/component/control/DataBindingControl.d.ts +14 -0
  11. package/dist/component/control/DataPickerControl.d.ts +13 -0
  12. package/dist/component/control/DateShortCutControl.d.ts +83 -0
  13. package/dist/component/control/FormulaControl.d.ts +51 -0
  14. package/dist/component/{Control → control}/OptionControl.d.ts +23 -34
  15. package/dist/component/{Control → control}/PopoverEdit.d.ts +0 -0
  16. package/dist/component/control/StatusControl.d.ts +39 -0
  17. package/dist/component/control/SwitchMoreControl.d.ts +224 -0
  18. package/dist/component/control/ValidationControl.d.ts +65 -0
  19. package/dist/component/control/ValidationItem.d.ts +46 -0
  20. package/dist/component/control/style-control/Background.d.ts +17 -0
  21. package/dist/component/control/style-control/Border.d.ts +18 -0
  22. package/dist/component/control/style-control/BoxModel.d.ts +17 -0
  23. package/dist/component/control/style-control/BoxShadow.d.ts +18 -0
  24. package/dist/component/control/style-control/Display.d.ts +14 -0
  25. package/dist/component/control/style-control/Font.d.ts +16 -0
  26. package/dist/component/control/style-control/font-family.d.ts +11 -0
  27. package/dist/component/control/style-control/transformation.d.ts +29 -0
  28. package/dist/component/control/style-control/types.d.ts +8 -0
  29. package/dist/component/schemaTpl.d.ts +8 -0
  30. package/dist/component/validator.d.ts +62 -0
  31. package/dist/dnd/index.d.ts +1 -1
  32. package/dist/event-action/action-config-panel.d.ts +8 -0
  33. package/dist/event-action/actions.d.ts +3 -0
  34. package/dist/event-action/comp-action-select.d.ts +11 -0
  35. package/dist/event-action/config.d.ts +13 -0
  36. package/dist/event-action/index.d.ts +459 -0
  37. package/dist/event-action/schema.d.ts +32 -0
  38. package/dist/exports.min.js +1 -1
  39. package/dist/index.d.ts +23 -5
  40. package/dist/index.min.js +1 -1
  41. package/dist/manager.d.ts +46 -1
  42. package/dist/plugin/Alert.d.ts +4 -2
  43. package/dist/plugin/Button.d.ts +5 -1
  44. package/dist/plugin/ButtonGroup.d.ts +13 -34
  45. package/dist/plugin/ButtonToolbar.d.ts +4 -10
  46. package/dist/plugin/CRUD.d.ts +2 -0
  47. package/dist/plugin/Chart.d.ts +2 -0
  48. package/dist/plugin/Collapse.d.ts +1 -0
  49. package/dist/plugin/CollapseGroup.d.ts +28 -4
  50. package/dist/plugin/Container.d.ts +2 -1
  51. package/dist/plugin/Dialog.d.ts +12 -2
  52. package/dist/plugin/Drawer.d.ts +12 -2
  53. package/dist/plugin/DropDownButton.d.ts +11 -11
  54. package/dist/plugin/Form/ButtonGroupSelect.d.ts +7 -2
  55. package/dist/plugin/Form/ButtonToolbar.d.ts +8 -7
  56. package/dist/plugin/Form/ChainedSelect.d.ts +3 -0
  57. package/dist/plugin/Form/Checkbox.d.ts +7 -2
  58. package/dist/plugin/Form/Checkboxes.d.ts +8 -2
  59. package/dist/plugin/Form/CodeEditor.d.ts +7 -22
  60. package/dist/plugin/Form/Combo.d.ts +3 -0
  61. package/dist/plugin/Form/Control.d.ts +6 -2
  62. package/dist/plugin/Form/DiffEditor.d.ts +7 -1
  63. package/dist/plugin/Form/Form.d.ts +6 -0
  64. package/dist/plugin/Form/Formula.d.ts +1 -25
  65. package/dist/plugin/Form/InputDate.d.ts +8 -2
  66. package/dist/plugin/Form/InputDateRange.d.ts +8 -2
  67. package/dist/plugin/Form/InputDateTime.d.ts +4 -4
  68. package/dist/plugin/Form/InputDateTimeRange.d.ts +4 -4
  69. package/dist/plugin/Form/InputEmail.d.ts +1 -0
  70. package/dist/plugin/Form/InputExcel.d.ts +6 -41
  71. package/dist/plugin/Form/InputFile.d.ts +7 -3
  72. package/dist/plugin/Form/InputKV.d.ts +6 -0
  73. package/dist/plugin/Form/InputMonth.d.ts +1 -0
  74. package/dist/plugin/Form/InputMonthRange.d.ts +4 -4
  75. package/dist/plugin/Form/InputPassword.d.ts +1 -0
  76. package/dist/plugin/Form/InputQuarter.d.ts +1 -0
  77. package/dist/plugin/Form/InputQuarterRange.d.ts +4 -4
  78. package/dist/plugin/Form/InputRange.d.ts +3 -0
  79. package/dist/plugin/Form/InputRating.d.ts +9 -3
  80. package/dist/plugin/Form/InputText.d.ts +24 -2
  81. package/dist/plugin/Form/InputTime.d.ts +3 -3
  82. package/dist/plugin/Form/InputTimeRange.d.ts +20 -0
  83. package/dist/plugin/Form/InputTree.d.ts +6 -2
  84. package/dist/plugin/Form/InputURL.d.ts +1 -0
  85. package/dist/plugin/Form/InputYear.d.ts +1 -0
  86. package/dist/plugin/Form/InputYearRange.d.ts +20 -0
  87. package/dist/plugin/Form/ListSelect.d.ts +6 -2
  88. package/dist/plugin/Form/LocationPicker.d.ts +1 -31
  89. package/dist/plugin/Form/NestedSelect.d.ts +5 -2
  90. package/dist/plugin/Form/Radios.d.ts +7 -2
  91. package/dist/plugin/Form/Select.d.ts +7 -2
  92. package/dist/plugin/Form/Switch.d.ts +7 -2
  93. package/dist/plugin/Form/TabsTransfer.d.ts +5 -2
  94. package/dist/plugin/Form/Textarea.d.ts +7 -1
  95. package/dist/plugin/Form/Transfer.d.ts +5 -2
  96. package/dist/plugin/Form/TreeSelect.d.ts +6 -2
  97. package/dist/plugin/IFrame.d.ts +2 -2
  98. package/dist/plugin/Nav.d.ts +1 -116
  99. package/dist/plugin/Others/Action.d.ts +5 -1
  100. package/dist/plugin/Page.d.ts +5 -2
  101. package/dist/plugin/Progress.d.ts +5 -1
  102. package/dist/plugin/Table.d.ts +2 -0
  103. package/dist/plugin/Tabs.d.ts +33 -2
  104. package/dist/plugin/TooltipWrapper.d.ts +10 -0
  105. package/dist/plugin/Tpl.d.ts +2 -1
  106. package/dist/plugin/Wizard.d.ts +4 -1
  107. package/dist/plugin.d.ts +37 -1
  108. package/dist/store/editor.d.ts +55 -28
  109. package/dist/store/node.d.ts +16 -0
  110. package/dist/style.css +1 -1
  111. package/dist/util.d.ts +36 -3
  112. package/package.json +14 -8
  113. package/src/component/schemaTpl.tsx +1198 -474
  114. package/src/plugin/.DS_Store +0 -0
  115. package/src/plugin/Alert.tsx +69 -48
  116. package/src/plugin/AnchorNav.tsx +1 -0
  117. package/src/plugin/Audio.tsx +9 -15
  118. package/src/plugin/Avatar.tsx +2 -1
  119. package/src/plugin/Breadcrumb.tsx +2 -1
  120. package/src/plugin/Button.tsx +257 -188
  121. package/src/plugin/ButtonGroup.tsx +99 -38
  122. package/src/plugin/ButtonToolbar.tsx +7 -13
  123. package/src/plugin/CRUD.tsx +77 -135
  124. package/src/plugin/Card.tsx +1 -0
  125. package/src/plugin/Cards.tsx +8 -14
  126. package/src/plugin/Carousel.tsx +1 -1
  127. package/src/plugin/Chart.tsx +26 -14
  128. package/src/plugin/Collapse.tsx +78 -78
  129. package/src/plugin/CollapseGroup.tsx +165 -83
  130. package/src/plugin/Container.tsx +59 -6
  131. package/src/plugin/Custom.tsx +2 -8
  132. package/src/plugin/CustomRegion.tsx +4 -3
  133. package/src/plugin/Dialog.tsx +55 -24
  134. package/src/plugin/Drawer.tsx +65 -35
  135. package/src/plugin/DropDownButton.tsx +95 -79
  136. package/src/plugin/Flex.tsx +123 -65
  137. package/src/plugin/Form/ButtonGroupSelect.tsx +114 -26
  138. package/src/plugin/Form/ButtonToolbar.tsx +62 -55
  139. package/src/plugin/Form/ChainedSelect.tsx +45 -0
  140. package/src/plugin/Form/Checkbox.tsx +122 -33
  141. package/src/plugin/Form/Checkboxes.tsx +154 -87
  142. package/src/plugin/Form/CodeEditor.tsx +163 -34
  143. package/src/plugin/Form/Combo.tsx +104 -65
  144. package/src/plugin/Form/Control.tsx +16 -70
  145. package/src/plugin/Form/DiffEditor.tsx +158 -54
  146. package/src/plugin/Form/FieldSet.tsx +6 -11
  147. package/src/plugin/Form/Form.tsx +277 -70
  148. package/src/plugin/Form/Formula.tsx +8 -14
  149. package/src/plugin/Form/InputArray.tsx +7 -16
  150. package/src/plugin/Form/InputCity.tsx +1 -1
  151. package/src/plugin/Form/InputDate.tsx +344 -121
  152. package/src/plugin/Form/InputDateRange.tsx +303 -161
  153. package/src/plugin/Form/InputDateTime.tsx +6 -150
  154. package/src/plugin/Form/InputDateTimeRange.tsx +7 -187
  155. package/src/plugin/Form/InputEmail.tsx +1 -0
  156. package/src/plugin/Form/InputExcel.tsx +70 -27
  157. package/src/plugin/Form/InputFile.tsx +326 -152
  158. package/src/plugin/Form/InputImage.tsx +1 -1
  159. package/src/plugin/Form/InputKV.tsx +61 -0
  160. package/src/plugin/Form/InputMonth.tsx +3 -1
  161. package/src/plugin/Form/InputMonthRange.tsx +6 -160
  162. package/src/plugin/Form/InputNumber.tsx +1 -1
  163. package/src/plugin/Form/InputPassword.tsx +2 -0
  164. package/src/plugin/Form/InputQuarter.tsx +3 -1
  165. package/src/plugin/Form/InputQuarterRange.tsx +6 -160
  166. package/src/plugin/Form/InputRange.tsx +74 -4
  167. package/src/plugin/Form/InputRating.tsx +347 -35
  168. package/src/plugin/Form/InputRichText.tsx +2 -3
  169. package/src/plugin/Form/InputTable.tsx +33 -49
  170. package/src/plugin/Form/InputTag.tsx +1 -1
  171. package/src/plugin/Form/InputText.tsx +310 -132
  172. package/src/plugin/Form/InputTime.tsx +4 -53
  173. package/src/plugin/Form/InputTimeRange.tsx +41 -0
  174. package/src/plugin/Form/InputTree.tsx +196 -46
  175. package/src/plugin/Form/InputURL.tsx +2 -0
  176. package/src/plugin/Form/InputYear.tsx +2 -0
  177. package/src/plugin/Form/InputYearRange.tsx +41 -0
  178. package/src/plugin/Form/Item.tsx +17 -18
  179. package/src/plugin/Form/ListSelect.tsx +75 -20
  180. package/src/plugin/Form/LocationPicker.tsx +2 -7
  181. package/src/plugin/Form/MatrixCheckboxes.tsx +1 -1
  182. package/src/plugin/Form/NestedSelect.tsx +110 -43
  183. package/src/plugin/Form/Picker.tsx +2 -5
  184. package/src/plugin/Form/Radios.tsx +122 -52
  185. package/src/plugin/Form/Select.tsx +239 -168
  186. package/src/plugin/Form/Static.tsx +1 -1
  187. package/src/plugin/Form/Switch.tsx +170 -58
  188. package/src/plugin/Form/TabsTransfer.tsx +175 -79
  189. package/src/plugin/Form/Textarea.tsx +146 -36
  190. package/src/plugin/Form/Transfer.tsx +295 -233
  191. package/src/plugin/Form/TreeSelect.tsx +287 -146
  192. package/src/plugin/Grid.tsx +340 -312
  193. package/src/plugin/HBox.tsx +1 -0
  194. package/src/plugin/IFrame.tsx +21 -12
  195. package/src/plugin/Image.tsx +7 -12
  196. package/src/plugin/Images.tsx +7 -12
  197. package/src/plugin/Link.tsx +6 -12
  198. package/src/plugin/List.tsx +6 -10
  199. package/src/plugin/ListItem.tsx +1 -0
  200. package/src/plugin/Nav.tsx +7 -9
  201. package/src/plugin/Others/Action.tsx +16 -10
  202. package/src/plugin/Others/BasicToolbar.tsx +4 -1
  203. package/src/plugin/Others/TableCell.tsx +19 -39
  204. package/src/plugin/Page.tsx +315 -229
  205. package/src/plugin/Panel.tsx +6 -7
  206. package/src/plugin/Plain.tsx +3 -6
  207. package/src/plugin/Progress.tsx +234 -94
  208. package/src/plugin/Service.tsx +10 -6
  209. package/src/plugin/Table.tsx +49 -20
  210. package/src/plugin/TableView.tsx +212 -106
  211. package/src/plugin/Tabs.tsx +306 -146
  212. package/src/plugin/TooltipWrapper.tsx +231 -135
  213. package/src/plugin/Tpl.tsx +68 -52
  214. package/src/plugin/Video.tsx +9 -20
  215. package/src/plugin/Wizard.tsx +537 -336
  216. package/src/plugin/Wrapper.tsx +82 -61
  217. package/src/plugin.ts +66 -4
  218. package/static/empty.png +0 -0
  219. package/dist/component/Control/APIControl.d.ts +0 -504
  220. package/dist/component/Control/ValidationControl.d.ts +0 -30
  221. package/dist/component/remarkTpl.d.ts +0 -150
@@ -19,6 +19,7 @@ import React from 'react';
19
19
  import {diff, JSONPipeIn} from '../../../src/util';
20
20
  import {JSONPipeOut} from '../../util';
21
21
  import {mockValue} from '../../mocker';
22
+ import {RendererAction, RendererEvent} from '../../event-action';
22
23
  import {setVariable} from 'amis-core';
23
24
 
24
25
  export class ComboControlPlugin extends BasePlugin {
@@ -75,6 +76,81 @@ export class ComboControlPlugin extends BasePlugin {
75
76
  ]
76
77
  };
77
78
 
79
+ // 事件定义
80
+ events: RendererEvent[] = [
81
+ {
82
+ eventName: 'add',
83
+ eventLabel: '添加',
84
+ description: '添加组合项时触发',
85
+ dataSchema: [
86
+ {
87
+ type: 'object',
88
+ properties: {
89
+ 'event.data.value': {
90
+ type: 'object',
91
+ title: '当前组合项的值'
92
+ }
93
+ }
94
+ }
95
+ ]
96
+ },
97
+ {
98
+ eventName: 'delete',
99
+ eventLabel: '删除',
100
+ description: '删除组合项',
101
+ dataSchema: [
102
+ {
103
+ type: 'object',
104
+ properties: {
105
+ 'event.data.key': {
106
+ type: 'string',
107
+ title: '删除项的索引'
108
+ },
109
+ 'event.data.value': {
110
+ type: 'string',
111
+ title: '现有组合项的值'
112
+ }
113
+ }
114
+ }
115
+ ]
116
+ },
117
+ {
118
+ eventName: 'tabsChange',
119
+ eventLabel: '切换tab',
120
+ description: '当设置 tabsMode 为 true 时,切换选项卡时触发',
121
+ dataSchema: [
122
+ {
123
+ type: 'object',
124
+ properties: {
125
+ 'event.data.key': {
126
+ type: 'string',
127
+ title: '选项卡索引'
128
+ }
129
+ }
130
+ }
131
+ ]
132
+ }
133
+ ];
134
+
135
+ // 动作定义
136
+ actions: RendererAction[] = [
137
+ {
138
+ actionType: 'clear',
139
+ actionLabel: '清空',
140
+ description: '清除选中值'
141
+ },
142
+ {
143
+ actionType: 'reset',
144
+ actionLabel: '重置',
145
+ description: '将值重置为resetValue,若没有配置resetValue,则清空'
146
+ },
147
+ {
148
+ actionType: 'setValue',
149
+ actionLabel: '赋值',
150
+ description: '触发组件数据更新'
151
+ }
152
+ ];
153
+
78
154
  panelTitle = '组合输入';
79
155
  panelBodyCreator = (context: BaseEventContext) => {
80
156
  return [
@@ -191,15 +267,12 @@ export class ComboControlPlugin extends BasePlugin {
191
267
  }
192
268
  },
193
269
 
194
- {
270
+ getSchemaTpl('switch', {
195
271
  name: 'typeSwitchable',
196
272
  visibleOn: 'this.conditions',
197
273
  label: '是否可切换类型',
198
- type: 'switch',
199
- mode: 'inline',
200
- className: 'block',
201
274
  pipeIn: defaultValue(true)
202
- },
275
+ }),
203
276
 
204
277
  {
205
278
  name: 'items',
@@ -245,41 +318,32 @@ export class ComboControlPlugin extends BasePlugin {
245
318
  visibleOn: 'typeof this.value !== "undefined"'
246
319
  },
247
320
 
248
- {
321
+ getSchemaTpl('switch', {
249
322
  label: '多行模式',
250
323
  name: 'multiLine',
251
- type: 'switch',
252
- mode: 'inline',
253
- className: 'w-full',
254
324
  value: false,
255
- option: '即是否要换行'
256
- },
325
+ description: '即是否要换行'
326
+ }),
257
327
 
258
328
  getSchemaTpl('multiple'),
259
329
  getSchemaTpl('joinValues'),
260
330
  getSchemaTpl('delimiter'),
261
331
 
262
- {
263
- type: 'switch',
332
+ getSchemaTpl('switch', {
264
333
  name: 'flat',
265
- mode: 'inline',
266
- className: 'w-full',
267
334
  label: '是否将值打平',
268
335
  visibleOn:
269
336
  'Array.isArray(data.items) && data.items.length === 1 && data.multiple',
270
337
  description:
271
338
  '默认数组内的数据结构为对象,如果只有一个表单项,可以配置将值打平,那么数组内放置的就是那个表单项的值'
272
- },
339
+ }),
273
340
 
274
- {
341
+ getSchemaTpl('switch', {
275
342
  label: '是否可新增',
276
- type: 'switch',
277
343
  name: 'addable',
278
- mode: 'inline',
279
- className: 'w-full',
280
344
  visibleOn: 'this.multiple',
281
345
  pipeIn: defaultValue(true)
282
- },
346
+ }),
283
347
 
284
348
  {
285
349
  type: 'textarea',
@@ -298,15 +362,12 @@ export class ComboControlPlugin extends BasePlugin {
298
362
  pipeIn: defaultValue('新增')
299
363
  },
300
364
 
301
- {
365
+ getSchemaTpl('switch', {
302
366
  label: '是否可删除',
303
- type: 'switch',
304
367
  name: 'removable',
305
- mode: 'inline',
306
- className: 'w-full',
307
368
  visibleOn: 'this.multiple',
308
369
  pipeIn: defaultValue(true)
309
- },
370
+ }),
310
371
 
311
372
  getSchemaTpl('api', {
312
373
  name: 'deleteApi',
@@ -322,14 +383,11 @@ export class ComboControlPlugin extends BasePlugin {
322
383
  pipeIn: defaultValue('确认要删除')
323
384
  },
324
385
 
325
- {
386
+ getSchemaTpl('switch', {
326
387
  name: 'draggable',
327
388
  label: '是否可拖拽排序',
328
- type: 'switch',
329
- visibleOn: 'this.multiple',
330
- mode: 'inline',
331
- className: 'w-full'
332
- },
389
+ visibleOn: 'this.multiple'
390
+ }),
333
391
 
334
392
  {
335
393
  label: '拖拽排序的提示文字',
@@ -339,14 +397,11 @@ export class ComboControlPlugin extends BasePlugin {
339
397
  pipeIn: defaultValue('可通过拖动每行中的【交换】按钮进行顺序调整')
340
398
  },
341
399
 
342
- {
400
+ getSchemaTpl('switch', {
343
401
  name: 'noBorder',
344
402
  label: '去掉边框',
345
- type: 'switch',
346
- visibleOn: 'this.multiLine',
347
- mode: 'inline',
348
- className: 'w-full'
349
- },
403
+ visibleOn: 'this.multiLine'
404
+ }),
350
405
 
351
406
  {
352
407
  name: 'minLength',
@@ -387,23 +442,17 @@ export class ComboControlPlugin extends BasePlugin {
387
442
  ]
388
443
  },
389
444
 
390
- {
445
+ getSchemaTpl('switch', {
391
446
  name: 'canAccessSuperData',
392
447
  label: '是否自动填充父级同名变量',
393
- type: 'switch',
394
- pipeIn: defaultValue(false),
395
- mode: 'inline',
396
- className: 'w-full'
397
- },
448
+ pipeIn: defaultValue(false)
449
+ }),
398
450
 
399
- {
451
+ getSchemaTpl('switch', {
400
452
  name: 'tabsMode',
401
453
  label: '采用 Tabs 展示方式',
402
- type: 'switch',
403
- mode: 'inline',
404
- className: 'w-full',
405
454
  pipeIn: defaultValue(false)
406
- },
455
+ }),
407
456
 
408
457
  {
409
458
  name: 'tabsStyle',
@@ -437,25 +486,19 @@ export class ComboControlPlugin extends BasePlugin {
437
486
  className: 'w-full'
438
487
  },
439
488
 
440
- {
489
+ getSchemaTpl('switch', {
441
490
  name: 'lazyLoad',
442
491
  label: '懒加载',
443
- type: 'switch',
444
- mode: 'inline',
445
- className: 'w-full',
446
492
  pipeIn: defaultValue(false),
447
493
  description: '如果数据比较多,比较卡顿时,可开启此配置项'
448
- },
494
+ }),
449
495
 
450
- {
496
+ getSchemaTpl('switch', {
451
497
  name: 'strictMode',
452
498
  label: '严格模式',
453
- type: 'switch',
454
- mode: 'inline',
455
- className: 'w-full',
456
499
  pipeIn: defaultValue(true),
457
500
  description: '如果你希望环境变量的值实时透传到 Combo 中,请关闭此选项。'
458
- },
501
+ }),
459
502
 
460
503
  {
461
504
  name: 'syncFields',
@@ -468,17 +511,13 @@ export class ComboControlPlugin extends BasePlugin {
468
511
  description:
469
512
  '如果 Combo 层级比较深,底层的获取外层的数据可能不同步。但是给 combo 配置这个属性就能同步下来。'
470
513
  },
471
-
472
- {
514
+ getSchemaTpl('switch', {
473
515
  name: 'nullable',
474
516
  label: '允许为空',
475
- type: 'switch',
476
- mode: 'inline',
477
- className: 'w-full',
478
517
  pipeIn: defaultValue(false),
479
518
  description:
480
519
  '如果子表单项里面配置验证器,且又是单条模式。可以允许用户选择清空(不填)。'
481
- },
520
+ }),
482
521
 
483
522
  {
484
523
  name: 'items',
@@ -2,7 +2,8 @@ import React from 'react';
2
2
  import {Button} from 'amis';
3
3
  import {getSchemaTpl} from '../../component/schemaTpl';
4
4
  import {registerEditorPlugin} from '../../manager';
5
- import {BasePlugin, RegionConfig} from '../../plugin';
5
+ import {BasePlugin, RegionConfig, BaseEventContext} from '../../plugin';
6
+ import {formItemControl} from '../../component/control/BaseControl';
6
7
 
7
8
  export class ControlPlugin extends BasePlugin {
8
9
  // 关联渲染器名字
@@ -16,6 +17,10 @@ export class ControlPlugin extends BasePlugin {
16
17
  description = `表单项容器`;
17
18
  docLink = '/amis/zh-CN/components/form/group';
18
19
  tags = ['容器'];
20
+ /**
21
+ * 组件选择面板中隐藏,和Container合并
22
+ */
23
+ disabledRendererPlugin = true;
19
24
  scaffold = {
20
25
  type: 'control',
21
26
  label: '表单项容器',
@@ -43,15 +48,15 @@ export class ControlPlugin extends BasePlugin {
43
48
  {
44
49
  key: 'body',
45
50
  label: '元素集合',
46
- preferTag: '展示'
51
+ preferTag: '表单项'
47
52
  }
48
53
  ];
49
54
 
50
55
  panelTitle = '表单项容器';
51
- panelBody = [
52
- getSchemaTpl('tabs', [
53
- {
54
- title: '常规',
56
+ panelBodyCreator = (context: BaseEventContext) => {
57
+ return formItemControl({
58
+ common: {
59
+ replace: true,
55
60
  body: [
56
61
  {
57
62
  children: (
@@ -67,73 +72,14 @@ export class ControlPlugin extends BasePlugin {
67
72
  </Button>
68
73
  )
69
74
  },
70
- getSchemaTpl('description'),
71
- getSchemaTpl('placeholder'),
75
+ getSchemaTpl('labelRemark'),
72
76
  getSchemaTpl('remark'),
73
- getSchemaTpl('labelRemark')
74
- ]
75
- },
76
-
77
- {
78
- title: '外观',
79
- body: [
80
- getSchemaTpl('formItemMode'),
81
- getSchemaTpl('horizontalMode'),
82
- getSchemaTpl('horizontal', {
83
- label: '',
84
- visibleOn:
85
- 'data.mode == "horizontal" && data.label !== false && data.horizontal'
86
- }),
87
-
88
- // renderer.sizeMutable !== false
89
- // ? getSchemaTpl('formItemSize')
90
- // : null,
91
- getSchemaTpl('formItemInline'),
92
-
93
- getSchemaTpl('className'),
94
- getSchemaTpl('className', {
95
- label: 'Label CSS 类名',
96
- name: 'labelClassName'
97
- }),
98
- getSchemaTpl('className', {
99
- label: '控件 CSS 类名',
100
- name: 'inputClassName'
101
- }),
102
- getSchemaTpl('className', {
103
- label: '描述 CSS 类名',
104
- name: 'descriptionClassName',
105
- visibleOn: 'this.description'
106
- })
107
- ]
108
- },
109
-
110
- {
111
- title: '显隐',
112
- body: [
113
- // TODO: 有些表单项没有 disabled
114
- getSchemaTpl('disabled'),
115
- getSchemaTpl('visible'),
116
- {
117
- type: 'switch',
118
- name: 'clearValueOnHidden',
119
- label: '隐藏时删除表单项值',
120
- mode: 'inline',
121
- className: 'w-full'
122
- }
123
- ]
124
- },
125
- {
126
- title: '验证',
127
- body: [
128
- // getSchemaTplByName('ref'),
129
- getSchemaTpl('validations'),
130
- getSchemaTpl('validationErrors'),
131
- getSchemaTpl('validateOnChange'),
132
- getSchemaTpl('submitOnChange')
77
+ getSchemaTpl('placeholder'),
78
+ getSchemaTpl('description')
133
79
  ]
134
80
  }
135
- ])
136
- ];
81
+ });
82
+ };
137
83
  }
138
84
 
139
85
  registerEditorPlugin(ControlPlugin);
@@ -2,11 +2,17 @@ import {availableLanguages} from 'amis/lib/renderers/Form/Editor';
2
2
  import {
3
3
  defaultValue,
4
4
  getSchemaTpl,
5
+ undefinedPipeOut,
5
6
  valuePipeOut
6
7
  } from '../../component/schemaTpl';
7
8
  import {registerEditorPlugin} from '../../manager';
8
9
  import {BasePlugin} from '../../plugin';
9
10
 
11
+ import type {BaseEventContext} from '../../plugin';
12
+ import {ValidatorTag} from '../../component/validator';
13
+ import {getEventControlConfig} from '../../util';
14
+ import {RendererAction, RendererEvent} from '../../event-action';
15
+
10
16
  export class DiffEditorControlPlugin extends BasePlugin {
11
17
  // 关联渲染器名字
12
18
  rendererName = 'diff-editor';
@@ -40,72 +46,170 @@ export class DiffEditorControlPlugin extends BasePlugin {
40
46
  ]
41
47
  };
42
48
 
43
- panelTitle = 'Diff编辑器';
44
- panelBody = [
49
+ events: RendererEvent[] = [
45
50
  {
46
- type: 'textarea',
47
- name: 'diffValue',
48
- label: '左侧值',
49
- pipeOut: valuePipeOut,
50
- description: '支持使用 <code>\\${xxx}</code> 来获取变量'
51
+ eventName: 'focus',
52
+ eventLabel: '获取焦点',
53
+ description: '右侧输入框获取焦点时触发',
54
+ dataSchema: [
55
+ {
56
+ type: 'object',
57
+ properties: {
58
+ 'event.data.value': {
59
+ type: 'string',
60
+ title: '当前代码'
61
+ }
62
+ }
63
+ }
64
+ ]
51
65
  },
66
+ {
67
+ eventName: 'blur',
68
+ eventLabel: '失去焦点',
69
+ description: '右侧输入框失去焦点时触发',
70
+ dataSchema: [
71
+ {
72
+ type: 'object',
73
+ properties: {
74
+ 'event.data.value': {
75
+ type: 'string',
76
+ title: '当前代码'
77
+ }
78
+ }
79
+ }
80
+ ]
81
+ }
82
+ ];
52
83
 
53
- getSchemaTpl('switchDefaultValue', {
54
- label: '设置右侧默认值'
55
- }),
56
-
84
+ actions: RendererAction[] = [
57
85
  {
58
- type: 'textarea',
59
- name: 'value',
60
- label: '右侧默认值',
61
- pipeOut: valuePipeOut,
62
- visibleOn: 'typeof this.value !== "undefined"'
86
+ actionType: 'clear',
87
+ actionLabel: '清空',
88
+ description: '清除选中值'
63
89
  },
64
-
65
90
  {
66
- label: '语言',
67
- name: 'language',
68
- type: 'select',
69
- value: 'javascript',
70
- searchable: true,
71
- options: availableLanguages.concat()
91
+ actionType: 'reset',
92
+ actionLabel: '重置',
93
+ description: '将值重置为resetValue,若没有配置resetValue,则清空'
72
94
  },
73
-
74
95
  {
75
- name: 'size',
76
- type: 'button-group-select',
77
- size: 'sm',
78
- pipeIn: defaultValue(''),
79
- className: 'w-full',
80
- label: '控件尺寸',
81
- options: [
82
- {
83
- label: '默认',
84
- value: ''
85
- },
96
+ actionType: 'focus',
97
+ actionLabel: '获取焦点',
98
+ description: '获取焦点,焦点落在右侧编辑面板'
99
+ },
100
+ {
101
+ actionType: 'setValue',
102
+ actionLabel: '赋值',
103
+ description: '触发组件数据更新'
104
+ }
105
+ ];
86
106
 
87
- {
88
- label: '中',
89
- value: 'md'
90
- },
107
+ notRenderFormZone = true;
91
108
 
92
- {
93
- label: '大',
94
- value: 'lg'
95
- },
109
+ panelTitle = 'Diff编辑器';
96
110
 
97
- {
98
- label: '加大',
99
- value: 'xl'
100
- },
111
+ panelJustify = true;
101
112
 
102
- {
103
- label: '再加大',
104
- value: 'xxl'
105
- }
106
- ]
107
- }
108
- ];
113
+ panelBodyCreator = (context: BaseEventContext) => {
114
+ return getSchemaTpl('tabs', [
115
+ {
116
+ title: '属性',
117
+ body: getSchemaTpl('collapseGroup', [
118
+ {
119
+ title: '基本',
120
+ body: [
121
+ getSchemaTpl('formItemName', {
122
+ required: true
123
+ }),
124
+ getSchemaTpl('label'),
125
+ {
126
+ label: '语言',
127
+ name: 'language',
128
+ type: 'select',
129
+ value: 'javascript',
130
+ searchable: true,
131
+ options: availableLanguages.concat()
132
+ },
133
+ {
134
+ type: 'textarea',
135
+ name: 'diffValue',
136
+ label: '左侧默认值',
137
+ pipeOut: valuePipeOut,
138
+ placeholder: '支持使用 ${xxx} 来获取变量'
139
+ },
140
+ {
141
+ type: 'textarea',
142
+ name: 'value',
143
+ label: '右侧默认值',
144
+ placeholder: '支持使用 ${xxx} 来获取变量'
145
+ },
146
+ getSchemaTpl('labelRemark'),
147
+ getSchemaTpl('remark'),
148
+ getSchemaTpl('description')
149
+ ]
150
+ },
151
+ getSchemaTpl('status', {isFormItem: true}),
152
+ getSchemaTpl('validation', {
153
+ tag: ValidatorTag.All
154
+ })
155
+ ])
156
+ },
157
+ {
158
+ title: '外观',
159
+ body: getSchemaTpl('collapseGroup', [
160
+ getSchemaTpl('style:formItem', {
161
+ renderer: context.info.renderer,
162
+ schema: [
163
+ {
164
+ name: 'size',
165
+ type: 'select',
166
+ pipeIn: defaultValue(''),
167
+ pipeOut: undefinedPipeOut,
168
+ label: '控件尺寸',
169
+ options: [
170
+ {
171
+ label: '默认',
172
+ value: ''
173
+ },
174
+
175
+ {
176
+ label: '中',
177
+ value: 'md'
178
+ },
179
+
180
+ {
181
+ label: '大',
182
+ value: 'lg'
183
+ },
184
+
185
+ {
186
+ label: '特大',
187
+ value: 'xl'
188
+ },
189
+
190
+ {
191
+ label: '超大',
192
+ value: 'xxl'
193
+ }
194
+ ]
195
+ }
196
+ ]
197
+ }),
198
+ getSchemaTpl('style:classNames')
199
+ ])
200
+ },
201
+ {
202
+ title: '事件',
203
+ className: 'p-none',
204
+ body: [
205
+ getSchemaTpl('eventControl', {
206
+ name: 'onEvent',
207
+ ...getEventControlConfig(this.manager, context)
208
+ })
209
+ ]
210
+ }
211
+ ]);
212
+ };
109
213
  }
110
214
 
111
215
  registerEditorPlugin(DiffEditorControlPlugin);
@@ -66,22 +66,17 @@ export class FieldSetControlPlugin extends BasePlugin {
66
66
  // required: true
67
67
  },
68
68
 
69
- {
69
+ getSchemaTpl('switch', {
70
70
  name: 'collapsable',
71
71
  label: '是否可折叠',
72
- type: 'switch',
73
- mode: 'inline',
74
- className: 'w-full',
75
72
  pipeIn: defaultValue(false)
76
- },
77
- {
73
+ }),
74
+
75
+ getSchemaTpl('switch', {
78
76
  name: 'collapsed',
79
77
  label: '默认是否折叠',
80
- type: 'switch',
81
- mode: 'inline',
82
- visibleOn: 'this.collapsable',
83
- className: 'w-full'
84
- },
78
+ visibleOn: 'this.collapsable'
79
+ }),
85
80
 
86
81
  {
87
82
  name: 'className',