amis-editor 4.1.0-beta.4 → 4.2.0-beta.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (218) hide show
  1. package/dist/component/Breadcrumb.d.ts +23 -2
  2. package/dist/component/ClassNameControl.d.ts +1 -1
  3. package/dist/component/Control/APIControl.d.ts +2 -2
  4. package/dist/component/Control/OptionControl.d.ts +3 -3
  5. package/dist/component/Control/PopoverEdit.d.ts +4 -4
  6. package/dist/component/Control/ValidationControl.d.ts +1 -1
  7. package/dist/component/Editor.d.ts +20 -1
  8. package/dist/component/IFramePreview.d.ts +2 -1
  9. package/dist/component/NodeWrapper.d.ts +1 -1
  10. package/dist/component/Panel/RenderersPanel.d.ts +1 -2
  11. package/dist/component/Preview.d.ts +3 -1
  12. package/dist/component/RegionWrapper.d.ts +4 -0
  13. package/dist/component/ScaffoldModal.d.ts +1 -1
  14. package/dist/component/VRenderer.d.ts +4 -0
  15. package/dist/component/base/InputComponentName.d.ts +1 -1
  16. package/dist/component/base/SearchCustomRendererPanel.d.ts +15 -0
  17. package/dist/component/base/SearchPanel.d.ts +83 -0
  18. package/dist/component/base/SearchRendererPanel.d.ts +2 -42
  19. package/dist/component/base/ShortcutKey.d.ts +23 -0
  20. package/dist/env.d.ts +1 -1
  21. package/dist/exports.min.js +1 -1
  22. package/dist/index.d.ts +5 -1
  23. package/dist/index.min.js +1 -1
  24. package/dist/manager.d.ts +16 -4
  25. package/dist/plugin/Alert.d.ts +1 -1
  26. package/dist/plugin/Button.d.ts +1 -1
  27. package/dist/plugin/Card.d.ts +1 -0
  28. package/dist/plugin/Cards.d.ts +2 -1
  29. package/dist/plugin/Carousel.d.ts +1 -0
  30. package/dist/plugin/Chart.d.ts +1 -0
  31. package/dist/plugin/Collapse.d.ts +1 -0
  32. package/dist/plugin/Custom.d.ts +3 -0
  33. package/dist/plugin/CustomRegion.d.ts +40 -0
  34. package/dist/plugin/Dialog.d.ts +1 -1
  35. package/dist/plugin/Drawer.d.ts +1 -1
  36. package/dist/plugin/DropDownButton.d.ts +1 -1
  37. package/dist/plugin/Each.d.ts +1 -1
  38. package/dist/plugin/Flex.d.ts +1 -0
  39. package/dist/plugin/Form/Control.d.ts +1 -0
  40. package/dist/plugin/Form/Form.d.ts +19 -3
  41. package/dist/plugin/Form/Formula.d.ts +3 -3
  42. package/dist/plugin/Form/InputURL.d.ts +1 -0
  43. package/dist/plugin/Form/Switch.d.ts +2 -0
  44. package/dist/plugin/Grid.d.ts +1 -0
  45. package/dist/plugin/HBox.d.ts +1 -0
  46. package/dist/plugin/IFrame.d.ts +3 -3
  47. package/dist/plugin/Json.d.ts +1 -0
  48. package/dist/plugin/List.d.ts +2 -1
  49. package/dist/plugin/Mapping.d.ts +1 -0
  50. package/dist/plugin/Markdown.d.ts +1 -0
  51. package/dist/plugin/Nav.d.ts +1 -0
  52. package/dist/plugin/Page.d.ts +1 -1
  53. package/dist/plugin/Panel/Outline.d.ts +8 -0
  54. package/dist/plugin/Progress.d.ts +1 -0
  55. package/dist/plugin/QRCode.d.ts +1 -0
  56. package/dist/plugin/Reset.d.ts +0 -1
  57. package/dist/plugin/Service.d.ts +1 -0
  58. package/dist/plugin/Sparkline.d.ts +1 -0
  59. package/dist/plugin/Status.d.ts +1 -0
  60. package/dist/plugin/Steps.d.ts +1 -0
  61. package/dist/plugin/Submit.d.ts +0 -1
  62. package/dist/plugin/Table.d.ts +1 -1
  63. package/dist/plugin/TableView.d.ts +1 -0
  64. package/dist/plugin/Tasks.d.ts +1 -0
  65. package/dist/plugin/TooltipWrapper.d.ts +1 -0
  66. package/dist/plugin/Video.d.ts +1 -0
  67. package/dist/plugin/WebComponent.d.ts +1 -0
  68. package/dist/plugin/Wizard.d.ts +11 -2
  69. package/dist/plugin/Wrapper.d.ts +1 -0
  70. package/dist/plugin.d.ts +8 -7
  71. package/dist/store/editor.d.ts +58 -22
  72. package/dist/store/node.d.ts +6 -0
  73. package/dist/style.css +1 -1
  74. package/dist/util.d.ts +1 -1
  75. package/package.json +9 -3
  76. package/src/component/schemaTpl.tsx +2157 -0
  77. package/src/plugin/Alert.tsx +87 -0
  78. package/src/plugin/AnchorNav.tsx +233 -0
  79. package/src/plugin/Audio.tsx +154 -0
  80. package/src/plugin/Avatar.tsx +77 -0
  81. package/src/plugin/Breadcrumb.tsx +107 -0
  82. package/src/plugin/Button.tsx +281 -0
  83. package/src/plugin/ButtonGroup.tsx +85 -0
  84. package/src/plugin/ButtonToolbar.tsx +87 -0
  85. package/src/plugin/CRUD.tsx +1835 -0
  86. package/src/plugin/Card.tsx +290 -0
  87. package/src/plugin/Cards.tsx +318 -0
  88. package/src/plugin/Carousel.tsx +377 -0
  89. package/src/plugin/Chart.tsx +218 -0
  90. package/src/plugin/CodeView.tsx +60 -0
  91. package/src/plugin/Collapse.tsx +136 -0
  92. package/src/plugin/CollapseGroup.tsx +167 -0
  93. package/src/plugin/Container.tsx +40 -0
  94. package/src/plugin/Custom.tsx +128 -0
  95. package/src/plugin/CustomRegion.tsx +156 -0
  96. package/src/plugin/Date.tsx +74 -0
  97. package/src/plugin/Datetime.tsx +68 -0
  98. package/src/plugin/Dialog.tsx +176 -0
  99. package/src/plugin/Divider.tsx +36 -0
  100. package/src/plugin/Drawer.tsx +214 -0
  101. package/src/plugin/DropDownButton.tsx +235 -0
  102. package/src/plugin/Each.tsx +150 -0
  103. package/src/plugin/ErrorRenderer.tsx +15 -0
  104. package/src/plugin/Flex.tsx +151 -0
  105. package/src/plugin/Form/ButtonGroupSelect.tsx +75 -0
  106. package/src/plugin/Form/ButtonToolbar.tsx +110 -0
  107. package/src/plugin/Form/ChainedSelect.tsx +70 -0
  108. package/src/plugin/Form/Checkbox.tsx +87 -0
  109. package/src/plugin/Form/Checkboxes.tsx +167 -0
  110. package/src/plugin/Form/CodeEditor.tsx +81 -0
  111. package/src/plugin/Form/Combo.tsx +582 -0
  112. package/src/plugin/Form/ConditionBuilder.tsx +315 -0
  113. package/src/plugin/Form/Control.tsx +139 -0
  114. package/src/plugin/Form/DiffEditor.tsx +111 -0
  115. package/src/plugin/Form/FieldSet.tsx +163 -0
  116. package/src/plugin/Form/Form.tsx +687 -0
  117. package/src/plugin/Form/Formula.tsx +79 -0
  118. package/src/plugin/Form/Group.tsx +295 -0
  119. package/src/plugin/Form/Hidden.tsx +44 -0
  120. package/src/plugin/Form/InputArray.tsx +228 -0
  121. package/src/plugin/Form/InputCity.tsx +93 -0
  122. package/src/plugin/Form/InputColor.tsx +123 -0
  123. package/src/plugin/Form/InputDate.tsx +175 -0
  124. package/src/plugin/Form/InputDateRange.tsx +225 -0
  125. package/src/plugin/Form/InputDateTime.tsx +183 -0
  126. package/src/plugin/Form/InputDateTimeRange.tsx +221 -0
  127. package/src/plugin/Form/InputEmail.tsx +33 -0
  128. package/src/plugin/Form/InputExcel.tsx +85 -0
  129. package/src/plugin/Form/InputFile.tsx +221 -0
  130. package/src/plugin/Form/InputGroup.tsx +96 -0
  131. package/src/plugin/Form/InputImage.tsx +266 -0
  132. package/src/plugin/Form/InputKV.tsx +72 -0
  133. package/src/plugin/Form/InputMonth.tsx +35 -0
  134. package/src/plugin/Form/InputMonthRange.tsx +195 -0
  135. package/src/plugin/Form/InputNumber.tsx +89 -0
  136. package/src/plugin/Form/InputPassword.tsx +33 -0
  137. package/src/plugin/Form/InputQuarter.tsx +35 -0
  138. package/src/plugin/Form/InputQuarterRange.tsx +195 -0
  139. package/src/plugin/Form/InputRange.tsx +121 -0
  140. package/src/plugin/Form/InputRating.tsx +78 -0
  141. package/src/plugin/Form/InputRepeat.tsx +57 -0
  142. package/src/plugin/Form/InputRichText.tsx +186 -0
  143. package/src/plugin/Form/InputSubForm.tsx +189 -0
  144. package/src/plugin/Form/InputTable.tsx +434 -0
  145. package/src/plugin/Form/InputTag.tsx +70 -0
  146. package/src/plugin/Form/InputText.tsx +186 -0
  147. package/src/plugin/Form/InputTime.tsx +85 -0
  148. package/src/plugin/Form/InputTree.tsx +229 -0
  149. package/src/plugin/Form/InputURL.tsx +34 -0
  150. package/src/plugin/Form/InputYear.tsx +35 -0
  151. package/src/plugin/Form/Item.tsx +327 -0
  152. package/src/plugin/Form/ListSelect.tsx +73 -0
  153. package/src/plugin/Form/LocationPicker.tsx +62 -0
  154. package/src/plugin/Form/MatrixCheckboxes.tsx +136 -0
  155. package/src/plugin/Form/NestedSelect.tsx +211 -0
  156. package/src/plugin/Form/Picker.tsx +209 -0
  157. package/src/plugin/Form/Radios.tsx +119 -0
  158. package/src/plugin/Form/Select.tsx +233 -0
  159. package/src/plugin/Form/Static.tsx +322 -0
  160. package/src/plugin/Form/Switch.tsx +107 -0
  161. package/src/plugin/Form/TabsTransfer.tsx +259 -0
  162. package/src/plugin/Form/Textarea.tsx +83 -0
  163. package/src/plugin/Form/Transfer.tsx +368 -0
  164. package/src/plugin/Form/TreeSelect.tsx +263 -0
  165. package/src/plugin/Form/UUID.tsx +48 -0
  166. package/src/plugin/Grid.tsx +798 -0
  167. package/src/plugin/HBox.tsx +727 -0
  168. package/src/plugin/IFrame.tsx +70 -0
  169. package/src/plugin/Image.tsx +314 -0
  170. package/src/plugin/Images.tsx +231 -0
  171. package/src/plugin/Json.tsx +69 -0
  172. package/src/plugin/Link.tsx +93 -0
  173. package/src/plugin/List.tsx +278 -0
  174. package/src/plugin/ListItem.tsx +229 -0
  175. package/src/plugin/Log.tsx +52 -0
  176. package/src/plugin/Mapping.tsx +149 -0
  177. package/src/plugin/Markdown.tsx +47 -0
  178. package/src/plugin/Nav.tsx +184 -0
  179. package/src/plugin/Operation.tsx +95 -0
  180. package/src/plugin/Others/Action.tsx +426 -0
  181. package/src/plugin/Others/BasicToolbar.tsx +585 -0
  182. package/src/plugin/Others/DataDebug.tsx +134 -0
  183. package/src/plugin/Others/TableCell.tsx +480 -0
  184. package/src/plugin/Others/Unknown.tsx +37 -0
  185. package/src/plugin/Page.tsx +306 -0
  186. package/src/plugin/Panel/AvailableRenderers.tsx +41 -0
  187. package/src/plugin/Panel/Code.tsx +44 -0
  188. package/src/plugin/Panel/Name.tsx +26 -0
  189. package/src/plugin/Panel/Outline.tsx +40 -0
  190. package/src/plugin/Panel.tsx +243 -0
  191. package/src/plugin/Plain.tsx +84 -0
  192. package/src/plugin/Progress.tsx +125 -0
  193. package/src/plugin/Property.tsx +139 -0
  194. package/src/plugin/QRCode.tsx +96 -0
  195. package/src/plugin/Reset.tsx +23 -0
  196. package/src/plugin/Service.tsx +162 -0
  197. package/src/plugin/Sparkline.tsx +40 -0
  198. package/src/plugin/Status.tsx +76 -0
  199. package/src/plugin/Steps.tsx +128 -0
  200. package/src/plugin/Submit.tsx +23 -0
  201. package/src/plugin/Table.tsx +428 -0
  202. package/src/plugin/TableView.tsx +709 -0
  203. package/src/plugin/Tabs.tsx +362 -0
  204. package/src/plugin/Tasks.tsx +274 -0
  205. package/src/plugin/Time.tsx +68 -0
  206. package/src/plugin/TooltipWrapper.tsx +193 -0
  207. package/src/plugin/Tpl.tsx +158 -0
  208. package/src/plugin/Video.tsx +158 -0
  209. package/src/plugin/WebComponent.tsx +53 -0
  210. package/src/plugin/Wizard.tsx +740 -0
  211. package/src/plugin/Wrapper.tsx +107 -0
  212. package/src/plugin.ts +1050 -0
  213. package/dist/150a58f3318ca7541ed9.png +0 -0
  214. package/dist/471adb97c322b226e589.png +0 -0
  215. package/dist/4de5f42360bc5946c3c2.png +0 -0
  216. package/dist/4e9968bba3855f088fed.png +0 -0
  217. package/dist/7f09c38ebc687fea847a.png +0 -0
  218. package/dist/c94073576487510314ea.png +0 -0
@@ -0,0 +1,315 @@
1
+ import {registerEditorPlugin} from '../../manager';
2
+ import {
3
+ BaseEventContext,
4
+ BasePlugin,
5
+ BasicSubRenderInfo,
6
+ PluginInterface,
7
+ RendererEventContext,
8
+ ScaffoldForm,
9
+ SubRendererInfo
10
+ } from '../../plugin';
11
+ import {getSchemaTpl} from '../../component/schemaTpl';
12
+
13
+ import {isObject, isString} from 'lodash';
14
+ import defaultConfig, {
15
+ OperationMap
16
+ } from 'amis-ui/lib/components/condition-builder/config';
17
+
18
+ export class ConditionBilderPlugin extends BasePlugin {
19
+ // 关联渲染器名字
20
+ rendererName = 'condition-builder';
21
+ $schema = '/schemas/ConditionBuilderControlSchema.json';
22
+
23
+ // 组件名称
24
+ name = '条件组件';
25
+ isBaseComponent = true;
26
+ icon = 'fa fa-group';
27
+ description =
28
+ '用于设置复杂组合条件,支持添加条件,添加分组,设置组合方式,拖拽排序等功能。';
29
+ docLink = '/amis/zh-CN/components/form/condition-builder';
30
+ tags = ['表单项'];
31
+
32
+ scaffold = {
33
+ type: 'condition-builder',
34
+ label: '条件组件',
35
+ name: 'conditions',
36
+ description: '适合让用户自己拼查询条件,然后后端根据数据生成 query where',
37
+ fields: [
38
+ {
39
+ label: '文本',
40
+ type: 'text',
41
+ name: 'text'
42
+ },
43
+ {
44
+ label: '数字',
45
+ type: 'number',
46
+ name: 'number'
47
+ },
48
+ {
49
+ label: '布尔',
50
+ type: 'boolean',
51
+ name: 'boolean'
52
+ },
53
+ {
54
+ label: '选项',
55
+ type: 'select',
56
+ name: 'select',
57
+ options: [
58
+ {
59
+ label: 'A',
60
+ value: 'a'
61
+ },
62
+ {
63
+ label: 'B',
64
+ value: 'b'
65
+ },
66
+ {
67
+ label: 'C',
68
+ value: 'c'
69
+ },
70
+ {
71
+ label: 'D',
72
+ value: 'd'
73
+ },
74
+ {
75
+ label: 'E',
76
+ value: 'e'
77
+ }
78
+ ]
79
+ },
80
+ {
81
+ label: '日期',
82
+ type: 'date',
83
+ name: 'date'
84
+ },
85
+ {
86
+ label: '时间',
87
+ type: 'time',
88
+ name: 'time'
89
+ },
90
+ {
91
+ label: '日期时间',
92
+ type: 'datetime',
93
+ name: 'datetime'
94
+ }
95
+ ]
96
+ };
97
+
98
+ scaffoldForm: ScaffoldForm = {
99
+ title: '快速开始-条件组合',
100
+ body: [
101
+ {
102
+ type: 'combo',
103
+ name: 'fields',
104
+ multiple: true,
105
+ draggable: true,
106
+ multiLine: true,
107
+ items: [
108
+ {
109
+ type: 'group',
110
+ body: [
111
+ {
112
+ type: 'select',
113
+ name: 'type',
114
+ placeholder: '条件类型',
115
+ options: [
116
+ {
117
+ label: '文本',
118
+ value: 'text'
119
+ },
120
+ {
121
+ label: '数字',
122
+ value: 'number'
123
+ },
124
+ {
125
+ label: '布尔',
126
+ value: 'boolean'
127
+ },
128
+ {
129
+ label: '日期',
130
+ value: 'date'
131
+ },
132
+ {
133
+ label: '日期时间',
134
+ value: 'datetime'
135
+ },
136
+ {
137
+ label: '时间',
138
+ value: 'time'
139
+ },
140
+ {
141
+ label: '选项',
142
+ value: 'select'
143
+ }
144
+ ]
145
+ },
146
+ {
147
+ type: 'input-text',
148
+ name: 'name',
149
+ placeholder: '字段名'
150
+ },
151
+ {
152
+ type: 'input-text',
153
+ placeholder: '字段名称',
154
+ name: 'label'
155
+ }
156
+ ]
157
+ },
158
+
159
+ {
160
+ type: 'group',
161
+ visibleOn: 'data.type === "number"',
162
+ body: [
163
+ {
164
+ type: 'input-number',
165
+ name: 'minimum',
166
+ placeholder: '最小值'
167
+ },
168
+ {
169
+ type: 'input-number',
170
+ name: 'maximum',
171
+ placeholder: '最大值'
172
+ },
173
+ {
174
+ type: 'input-number',
175
+ name: 'step',
176
+ min: 0,
177
+ placeholder: '步长'
178
+ }
179
+ ]
180
+ },
181
+
182
+ {
183
+ type: 'group',
184
+ visibleOn: '!!~["date", "datetime", "time"].indexOf(data.type)',
185
+ body: [
186
+ {
187
+ type: 'input-text',
188
+ name: 'format',
189
+ placeholder: '值格式'
190
+ },
191
+ {
192
+ type: 'input-text',
193
+ name: 'inputFormat',
194
+ placeholder: '日期显示格式'
195
+ },
196
+ {
197
+ type: 'input-text',
198
+ name: 'timeFormat',
199
+ placeholder: '时间显示格式',
200
+ visibleOn: 'data.type === "datetime"'
201
+ }
202
+ ]
203
+ },
204
+
205
+ {
206
+ type: 'group',
207
+ visibleOn: 'data.type === "select"',
208
+ body: [
209
+ {
210
+ type: 'input-text',
211
+ name: 'source',
212
+ placeholder: '字段选项远程拉取,支持接口或数据映射'
213
+ }
214
+ ]
215
+ },
216
+
217
+ {
218
+ type: 'group',
219
+ body: [
220
+ {
221
+ type: 'input-text',
222
+ placeholder: '占位符',
223
+ name: 'placeholder'
224
+ },
225
+
226
+ {
227
+ name: 'operators',
228
+ placeholder: '操作符',
229
+ asFormItem: true,
230
+ children: ({data, render, onChange}: any) =>
231
+ render(
232
+ 'operations',
233
+ {
234
+ type: 'select',
235
+ name: 'operators',
236
+ multiple: true,
237
+ value:
238
+ data.value ||
239
+ defaultConfig.types[data.type]?.operators ||
240
+ [],
241
+ joinValues: false,
242
+ extractValue: true,
243
+ options: defaultConfig.types[data.type]?.operators.map(
244
+ item => {
245
+ if (isObject(item) && item.label && item.value) {
246
+ return (
247
+ {
248
+ label: item.label,
249
+ value: item.value
250
+ } || []
251
+ );
252
+ } else if (isString(item)) {
253
+ return (
254
+ {
255
+ label: OperationMap[item],
256
+ value: item
257
+ } || []
258
+ );
259
+ } else {
260
+ return [];
261
+ }
262
+ }
263
+ )
264
+ },
265
+ {
266
+ onChange: (value: any) => onChange(value)
267
+ }
268
+ )
269
+ }
270
+ ]
271
+ }
272
+ ]
273
+ }
274
+ ],
275
+ canRebuild: true
276
+ };
277
+
278
+ previewSchema: any = {
279
+ type: 'form',
280
+ mode: 'horizontal',
281
+ wrapWithPanel: false,
282
+ body: [this.scaffold]
283
+ };
284
+
285
+ panelTitle = '条件组件';
286
+ panelBodyCreator = (context: BaseEventContext) => {
287
+ return [getSchemaTpl('source')];
288
+ };
289
+
290
+ buildSubRenderers(
291
+ context: RendererEventContext,
292
+ renderers: Array<SubRendererInfo>
293
+ ): BasicSubRenderInfo | Array<BasicSubRenderInfo> | void {
294
+ const plugin: PluginInterface = this;
295
+ // return super.buildSubRenderers.apply(this, arguments);
296
+ if (plugin.name && plugin.description) {
297
+ return {
298
+ name: plugin.name,
299
+ icon: plugin.icon,
300
+ description: plugin.description,
301
+ previewSchema: plugin.previewSchema,
302
+ tags: plugin.tags,
303
+ docLink: plugin.docLink,
304
+ type: plugin.type,
305
+ scaffold: plugin.scaffold,
306
+ scaffoldForm: this.scaffoldForm,
307
+ disabledRendererPlugin: plugin.disabledRendererPlugin,
308
+ isBaseComponent: plugin.isBaseComponent,
309
+ rendererName: plugin.rendererName
310
+ };
311
+ }
312
+ }
313
+ }
314
+
315
+ registerEditorPlugin(ConditionBilderPlugin);
@@ -0,0 +1,139 @@
1
+ import React from 'react';
2
+ import {Button} from 'amis';
3
+ import {getSchemaTpl} from '../../component/schemaTpl';
4
+ import {registerEditorPlugin} from '../../manager';
5
+ import {BasePlugin, RegionConfig} from '../../plugin';
6
+
7
+ export class ControlPlugin extends BasePlugin {
8
+ // 关联渲染器名字
9
+ rendererName = 'control';
10
+ $schema = '/schemas/FormControlSchema.json';
11
+
12
+ // 组件名称
13
+ name = '表单项容器';
14
+ isBaseComponent = true;
15
+ icon = 'fa fa-object-group';
16
+ description = `表单项容器`;
17
+ docLink = '/amis/zh-CN/components/form/group';
18
+ tags = ['容器'];
19
+ scaffold = {
20
+ type: 'control',
21
+ label: '表单项容器',
22
+ body: [
23
+ {
24
+ type: 'tpl',
25
+ tpl: 'a'
26
+ }
27
+ ]
28
+ };
29
+ previewSchema: any = {
30
+ type: 'form',
31
+ className: 'text-left',
32
+ mode: 'horizontal',
33
+ wrapWithPanel: false,
34
+ body: [
35
+ {
36
+ ...this.scaffold
37
+ }
38
+ ]
39
+ };
40
+
41
+ // 容器配置
42
+ regions: Array<RegionConfig> = [
43
+ {
44
+ key: 'body',
45
+ label: '元素集合',
46
+ preferTag: '展示'
47
+ }
48
+ ];
49
+
50
+ panelTitle = '表单项容器';
51
+ panelBody = [
52
+ getSchemaTpl('tabs', [
53
+ {
54
+ title: '常规',
55
+ body: [
56
+ {
57
+ children: (
58
+ <Button
59
+ className="m-b"
60
+ onClick={() => this.manager.showRendererPanel('表单项')}
61
+ level="danger"
62
+ tooltip="插入一个新的元素"
63
+ size="sm"
64
+ block
65
+ >
66
+ 新增元素
67
+ </Button>
68
+ )
69
+ },
70
+ getSchemaTpl('description'),
71
+ getSchemaTpl('placeholder'),
72
+ 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')
133
+ ]
134
+ }
135
+ ])
136
+ ];
137
+ }
138
+
139
+ registerEditorPlugin(ControlPlugin);
@@ -0,0 +1,111 @@
1
+ import {availableLanguages} from 'amis/lib/renderers/Form/Editor';
2
+ import {
3
+ defaultValue,
4
+ getSchemaTpl,
5
+ valuePipeOut
6
+ } from '../../component/schemaTpl';
7
+ import {registerEditorPlugin} from '../../manager';
8
+ import {BasePlugin} from '../../plugin';
9
+
10
+ export class DiffEditorControlPlugin extends BasePlugin {
11
+ // 关联渲染器名字
12
+ rendererName = 'diff-editor';
13
+ $schema = '/schemas/DiffEditorControlSchema.json';
14
+
15
+ // 组件名称
16
+ name = 'Diff编辑器';
17
+ isBaseComponent = true;
18
+ icon = 'fa fa-columns';
19
+ description = `左右两边的代码做对比,支持的语言包括:${availableLanguages
20
+ .slice(0, 10)
21
+ .join(',')}等等`;
22
+ docLink = '/amis/zh-CN/components/form/diff-editor';
23
+ tags = ['表单项'];
24
+ scaffold = {
25
+ type: 'diff-editor',
26
+ label: 'diff编辑器',
27
+ name: 'diff'
28
+ };
29
+ previewSchema: any = {
30
+ type: 'form',
31
+ className: 'text-left',
32
+ mode: 'horizontal',
33
+ wrapWithPanel: false,
34
+ body: [
35
+ {
36
+ ...this.scaffold,
37
+ value: 'Hello World\nLine 1\nNew line\nBla Bla',
38
+ diffValue: 'Hello World\nLine 2'
39
+ }
40
+ ]
41
+ };
42
+
43
+ panelTitle = 'Diff编辑器';
44
+ panelBody = [
45
+ {
46
+ type: 'textarea',
47
+ name: 'diffValue',
48
+ label: '左侧值',
49
+ pipeOut: valuePipeOut,
50
+ description: '支持使用 <code>\\${xxx}</code> 来获取变量'
51
+ },
52
+
53
+ getSchemaTpl('switchDefaultValue', {
54
+ label: '设置右侧默认值'
55
+ }),
56
+
57
+ {
58
+ type: 'textarea',
59
+ name: 'value',
60
+ label: '右侧默认值',
61
+ pipeOut: valuePipeOut,
62
+ visibleOn: 'typeof this.value !== "undefined"'
63
+ },
64
+
65
+ {
66
+ label: '语言',
67
+ name: 'language',
68
+ type: 'select',
69
+ value: 'javascript',
70
+ searchable: true,
71
+ options: availableLanguages.concat()
72
+ },
73
+
74
+ {
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
+ },
86
+
87
+ {
88
+ label: '中',
89
+ value: 'md'
90
+ },
91
+
92
+ {
93
+ label: '大',
94
+ value: 'lg'
95
+ },
96
+
97
+ {
98
+ label: '加大',
99
+ value: 'xl'
100
+ },
101
+
102
+ {
103
+ label: '再加大',
104
+ value: 'xxl'
105
+ }
106
+ ]
107
+ }
108
+ ];
109
+ }
110
+
111
+ registerEditorPlugin(DiffEditorControlPlugin);