amis-editor 4.1.0-beta.1 → 4.1.0-beta.20

Sign up to get free protection for your applications and to get access to all the features.
Files changed (196) hide show
  1. package/dist/component/Breadcrumb.d.ts +23 -2
  2. package/dist/component/Editor.d.ts +19 -0
  3. package/dist/component/Panel/RenderersPanel.d.ts +1 -2
  4. package/dist/component/RegionWrapper.d.ts +14 -7
  5. package/dist/component/RendererThumb.d.ts +5 -5
  6. package/dist/component/VRenderer.d.ts +4 -0
  7. package/dist/component/base/SearchCustomRendererPanel.d.ts +15 -0
  8. package/dist/component/base/SearchPanel.d.ts +83 -0
  9. package/dist/component/base/SearchRendererPanel.d.ts +2 -42
  10. package/dist/exports.min.js +1 -1
  11. package/dist/index.d.ts +4 -1
  12. package/dist/index.min.js +1 -1
  13. package/dist/manager.d.ts +14 -3
  14. package/dist/plugin/Card.d.ts +1 -0
  15. package/dist/plugin/Cards.d.ts +1 -0
  16. package/dist/plugin/Carousel.d.ts +1 -0
  17. package/dist/plugin/Chart.d.ts +1 -0
  18. package/dist/plugin/Collapse.d.ts +1 -0
  19. package/dist/plugin/Custom.d.ts +3 -0
  20. package/dist/plugin/CustomRegion.d.ts +43 -0
  21. package/dist/plugin/Flex.d.ts +1 -0
  22. package/dist/plugin/Form/Control.d.ts +1 -0
  23. package/dist/plugin/Form/Form.d.ts +19 -3
  24. package/dist/plugin/Form/InputURL.d.ts +1 -0
  25. package/dist/plugin/Grid.d.ts +1 -0
  26. package/dist/plugin/HBox.d.ts +1 -0
  27. package/dist/plugin/Json.d.ts +1 -0
  28. package/dist/plugin/List.d.ts +1 -0
  29. package/dist/plugin/Mapping.d.ts +1 -0
  30. package/dist/plugin/Markdown.d.ts +1 -0
  31. package/dist/plugin/Nav.d.ts +1 -0
  32. package/dist/plugin/Panel/Outline.d.ts +8 -0
  33. package/dist/plugin/Progress.d.ts +1 -0
  34. package/dist/plugin/QRCode.d.ts +1 -0
  35. package/dist/plugin/Reset.d.ts +0 -1
  36. package/dist/plugin/Service.d.ts +1 -0
  37. package/dist/plugin/Sparkline.d.ts +1 -0
  38. package/dist/plugin/Status.d.ts +1 -0
  39. package/dist/plugin/Steps.d.ts +1 -0
  40. package/dist/plugin/Submit.d.ts +0 -1
  41. package/dist/plugin/TableView.d.ts +1 -0
  42. package/dist/plugin/Tasks.d.ts +1 -0
  43. package/dist/plugin/TooltipWrapper.d.ts +1 -0
  44. package/dist/plugin/Video.d.ts +1 -0
  45. package/dist/plugin/WebComponent.d.ts +1 -0
  46. package/dist/plugin/Wizard.d.ts +11 -2
  47. package/dist/plugin/Wrapper.d.ts +1 -0
  48. package/dist/plugin.d.ts +2 -2
  49. package/dist/store/editor.d.ts +20 -2
  50. package/dist/store/node.d.ts +6 -0
  51. package/dist/style.css +1 -1
  52. package/dist/util.d.ts +7 -2
  53. package/package.json +6 -3
  54. package/src/component/schemaTpl.tsx +2155 -0
  55. package/src/plugin/Alert.tsx +87 -0
  56. package/src/plugin/AnchorNav.tsx +233 -0
  57. package/src/plugin/Audio.tsx +161 -0
  58. package/src/plugin/Avatar.tsx +77 -0
  59. package/src/plugin/Breadcrumb.tsx +107 -0
  60. package/src/plugin/Button.tsx +283 -0
  61. package/src/plugin/ButtonGroup.tsx +88 -0
  62. package/src/plugin/ButtonToolbar.tsx +89 -0
  63. package/src/plugin/CRUD.tsx +1832 -0
  64. package/src/plugin/Card.tsx +290 -0
  65. package/src/plugin/Cards.tsx +315 -0
  66. package/src/plugin/Carousel.tsx +386 -0
  67. package/src/plugin/Chart.tsx +218 -0
  68. package/src/plugin/CodeView.tsx +60 -0
  69. package/src/plugin/Collapse.tsx +143 -0
  70. package/src/plugin/CollapseGroup.tsx +167 -0
  71. package/src/plugin/Container.tsx +44 -0
  72. package/src/plugin/Custom.tsx +128 -0
  73. package/src/plugin/CustomRegion.tsx +150 -0
  74. package/src/plugin/Date.tsx +81 -0
  75. package/src/plugin/Datetime.tsx +75 -0
  76. package/src/plugin/Dialog.tsx +178 -0
  77. package/src/plugin/Divider.tsx +36 -0
  78. package/src/plugin/Drawer.tsx +217 -0
  79. package/src/plugin/DropDownButton.tsx +234 -0
  80. package/src/plugin/Each.tsx +152 -0
  81. package/src/plugin/ErrorRenderer.tsx +15 -0
  82. package/src/plugin/Flex.tsx +156 -0
  83. package/src/plugin/Form/ButtonGroupSelect.tsx +86 -0
  84. package/src/plugin/Form/ButtonToolbar.tsx +121 -0
  85. package/src/plugin/Form/ChainedSelect.tsx +70 -0
  86. package/src/plugin/Form/Checkbox.tsx +87 -0
  87. package/src/plugin/Form/Checkboxes.tsx +167 -0
  88. package/src/plugin/Form/CodeEditor.tsx +91 -0
  89. package/src/plugin/Form/Combo.tsx +582 -0
  90. package/src/plugin/Form/ConditionBuilder.tsx +324 -0
  91. package/src/plugin/Form/Control.tsx +139 -0
  92. package/src/plugin/Form/DiffEditor.tsx +117 -0
  93. package/src/plugin/Form/FieldSet.tsx +175 -0
  94. package/src/plugin/Form/Form.tsx +692 -0
  95. package/src/plugin/Form/Formula.tsx +91 -0
  96. package/src/plugin/Form/Group.tsx +300 -0
  97. package/src/plugin/Form/Hidden.tsx +56 -0
  98. package/src/plugin/Form/InputArray.tsx +228 -0
  99. package/src/plugin/Form/InputCity.tsx +93 -0
  100. package/src/plugin/Form/InputColor.tsx +123 -0
  101. package/src/plugin/Form/InputDate.tsx +175 -0
  102. package/src/plugin/Form/InputDateRange.tsx +225 -0
  103. package/src/plugin/Form/InputDateTime.tsx +183 -0
  104. package/src/plugin/Form/InputDateTimeRange.tsx +221 -0
  105. package/src/plugin/Form/InputEmail.tsx +33 -0
  106. package/src/plugin/Form/InputExcel.tsx +85 -0
  107. package/src/plugin/Form/InputFile.tsx +228 -0
  108. package/src/plugin/Form/InputGroup.tsx +105 -0
  109. package/src/plugin/Form/InputImage.tsx +277 -0
  110. package/src/plugin/Form/InputKV.tsx +72 -0
  111. package/src/plugin/Form/InputMonth.tsx +35 -0
  112. package/src/plugin/Form/InputMonthRange.tsx +195 -0
  113. package/src/plugin/Form/InputNumber.tsx +97 -0
  114. package/src/plugin/Form/InputPassword.tsx +33 -0
  115. package/src/plugin/Form/InputQuarter.tsx +35 -0
  116. package/src/plugin/Form/InputQuarterRange.tsx +195 -0
  117. package/src/plugin/Form/InputRange.tsx +121 -0
  118. package/src/plugin/Form/InputRating.tsx +78 -0
  119. package/src/plugin/Form/InputRepeat.tsx +69 -0
  120. package/src/plugin/Form/InputRichText.tsx +197 -0
  121. package/src/plugin/Form/InputSubForm.tsx +198 -0
  122. package/src/plugin/Form/InputTable.tsx +434 -0
  123. package/src/plugin/Form/InputTag.tsx +81 -0
  124. package/src/plugin/Form/InputText.tsx +186 -0
  125. package/src/plugin/Form/InputTime.tsx +95 -0
  126. package/src/plugin/Form/InputTree.tsx +240 -0
  127. package/src/plugin/Form/InputURL.tsx +34 -0
  128. package/src/plugin/Form/InputYear.tsx +35 -0
  129. package/src/plugin/Form/Item.tsx +325 -0
  130. package/src/plugin/Form/ListSelect.tsx +84 -0
  131. package/src/plugin/Form/LocationPicker.tsx +75 -0
  132. package/src/plugin/Form/MatrixCheckboxes.tsx +147 -0
  133. package/src/plugin/Form/NestedSelect.tsx +222 -0
  134. package/src/plugin/Form/Picker.tsx +217 -0
  135. package/src/plugin/Form/Radios.tsx +130 -0
  136. package/src/plugin/Form/Select.tsx +216 -0
  137. package/src/plugin/Form/Static.tsx +335 -0
  138. package/src/plugin/Form/Switch.tsx +116 -0
  139. package/src/plugin/Form/TabsTransfer.tsx +270 -0
  140. package/src/plugin/Form/Textarea.tsx +94 -0
  141. package/src/plugin/Form/Transfer.tsx +379 -0
  142. package/src/plugin/Form/TreeSelect.tsx +263 -0
  143. package/src/plugin/Form/UUID.tsx +48 -0
  144. package/src/plugin/Grid.tsx +799 -0
  145. package/src/plugin/HBox.tsx +727 -0
  146. package/src/plugin/IFrame.tsx +72 -0
  147. package/src/plugin/Image.tsx +318 -0
  148. package/src/plugin/Images.tsx +238 -0
  149. package/src/plugin/Json.tsx +76 -0
  150. package/src/plugin/Link.tsx +95 -0
  151. package/src/plugin/List.tsx +278 -0
  152. package/src/plugin/ListItem.tsx +233 -0
  153. package/src/plugin/Log.tsx +52 -0
  154. package/src/plugin/Mapping.tsx +156 -0
  155. package/src/plugin/Markdown.tsx +47 -0
  156. package/src/plugin/Nav.tsx +186 -0
  157. package/src/plugin/Operation.tsx +97 -0
  158. package/src/plugin/Others/Action.tsx +428 -0
  159. package/src/plugin/Others/BasicToolbar.tsx +591 -0
  160. package/src/plugin/Others/DataDebug.tsx +134 -0
  161. package/src/plugin/Others/TableCell.tsx +480 -0
  162. package/src/plugin/Others/Unknown.tsx +37 -0
  163. package/src/plugin/Page.tsx +308 -0
  164. package/src/plugin/Panel/AvailableRenderers.tsx +41 -0
  165. package/src/plugin/Panel/Code.tsx +44 -0
  166. package/src/plugin/Panel/Name.tsx +26 -0
  167. package/src/plugin/Panel/Outline.tsx +40 -0
  168. package/src/plugin/Panel.tsx +243 -0
  169. package/src/plugin/Plain.tsx +91 -0
  170. package/src/plugin/Progress.tsx +132 -0
  171. package/src/plugin/Property.tsx +139 -0
  172. package/src/plugin/QRCode.tsx +98 -0
  173. package/src/plugin/Reset.tsx +23 -0
  174. package/src/plugin/Service.tsx +167 -0
  175. package/src/plugin/Sparkline.tsx +40 -0
  176. package/src/plugin/Status.tsx +78 -0
  177. package/src/plugin/Steps.tsx +140 -0
  178. package/src/plugin/Submit.tsx +23 -0
  179. package/src/plugin/Table.tsx +440 -0
  180. package/src/plugin/TableView.tsx +711 -0
  181. package/src/plugin/Tabs.tsx +364 -0
  182. package/src/plugin/Tasks.tsx +276 -0
  183. package/src/plugin/Time.tsx +75 -0
  184. package/src/plugin/TooltipWrapper.tsx +193 -0
  185. package/src/plugin/Tpl.tsx +162 -0
  186. package/src/plugin/Video.tsx +160 -0
  187. package/src/plugin/WebComponent.tsx +56 -0
  188. package/src/plugin/Wizard.tsx +743 -0
  189. package/src/plugin/Wrapper.tsx +107 -0
  190. package/src/plugin.ts +1046 -0
  191. package/dist/150a58f3318ca7541ed9.png +0 -0
  192. package/dist/471adb97c322b226e589.png +0 -0
  193. package/dist/4de5f42360bc5946c3c2.png +0 -0
  194. package/dist/4e9968bba3855f088fed.png +0 -0
  195. package/dist/7f09c38ebc687fea847a.png +0 -0
  196. package/dist/c94073576487510314ea.png +0 -0
@@ -0,0 +1,364 @@
1
+ import {Button, SchemaObject} from 'amis';
2
+ import React from 'react';
3
+ import {registerEditorPlugin} from '../manager';
4
+ import {
5
+ BaseEventContext,
6
+ BasePlugin,
7
+ BasicToolbarItem,
8
+ PluginEvent,
9
+ PreventClickEventContext,
10
+ RegionConfig,
11
+ RendererInfo,
12
+ VRendererConfig
13
+ } from '../plugin';
14
+ import {defaultValue, getSchemaTpl} from '../component/schemaTpl';
15
+ import {mapReactElement} from '../component/factory';
16
+ import {VRenderer} from '../component/VRenderer';
17
+ import findIndex from 'lodash/findIndex';
18
+ import {RegionWrapper as Region} from '../component/RegionWrapper';
19
+ import {Tab} from 'amis';
20
+
21
+ export class TabsPlugin extends BasePlugin {
22
+ // 关联渲染器名字
23
+ rendererName = 'tabs';
24
+ $schema = '/schemas/TabsSchema.json';
25
+
26
+ // 组件名称
27
+ name = '选项卡';
28
+ isBaseComponent = true;
29
+ description = '选项卡,可以将内容分组用选项卡的形式展示,降低用户使用成本。';
30
+ docLink = '/amis/zh-CN/components/tabs';
31
+ tags = ['容器'];
32
+ icon = 'fa fa-folder-o';
33
+ scaffold = {
34
+ type: 'tabs',
35
+ tabs: [
36
+ {
37
+ title: '选项卡1',
38
+ body: '内容1'
39
+ },
40
+
41
+ {
42
+ title: '选项卡2',
43
+ body: '内容2'
44
+ }
45
+ ]
46
+ };
47
+ previewSchema = {
48
+ ...this.scaffold
49
+ };
50
+
51
+ panelTitle = '选项卡';
52
+ panelBody = [
53
+ getSchemaTpl('tabs', [
54
+ {
55
+ title: '常规',
56
+ body: [
57
+ {
58
+ name: 'tabs',
59
+ type: 'combo',
60
+ label: '选项卡管理',
61
+ multiple: true,
62
+ draggable: true,
63
+ minLength: 1,
64
+ items: [{type: 'input-text', name: 'title', required: true}],
65
+ scaffold: {
66
+ title: '选项卡',
67
+ body: {
68
+ type: 'tpl',
69
+ tpl: '内容',
70
+ inline: false
71
+ }
72
+ },
73
+ addButtonText: '新增选项卡',
74
+ draggableTip: ''
75
+ }
76
+ ]
77
+ },
78
+ {
79
+ title: '外观',
80
+ body: [
81
+ {
82
+ name: 'tabsMode',
83
+ label: '样式',
84
+ type: 'select',
85
+ className: 'block',
86
+ pipeIn: defaultValue(''),
87
+ options: [
88
+ {
89
+ label: '默认',
90
+ value: ''
91
+ },
92
+ {
93
+ label: '线型',
94
+ value: 'line'
95
+ },
96
+ {
97
+ label: '卡片',
98
+ value: 'card'
99
+ },
100
+ {
101
+ label: '仿 Chrome',
102
+ value: 'chrome'
103
+ },
104
+ {
105
+ label: '水平铺满',
106
+ value: 'tiled'
107
+ },
108
+ {
109
+ label: '选择器',
110
+ value: 'radio'
111
+ },
112
+ {
113
+ label: '垂直',
114
+ value: 'vertical'
115
+ }
116
+ ]
117
+ },
118
+ getSchemaTpl('className'),
119
+ getSchemaTpl('className', {
120
+ name: 'contentClassName',
121
+ label: '选项卡成员 CSS 类名'
122
+ }),
123
+
124
+ getSchemaTpl('subFormItemMode'),
125
+ getSchemaTpl('subFormHorizontalMode'),
126
+ getSchemaTpl('subFormHorizontal')
127
+ ]
128
+ },
129
+ {
130
+ title: '显隐',
131
+ body: [
132
+ {
133
+ type: 'switch',
134
+ name: 'mountOnEnter',
135
+ label: '激活时才渲染',
136
+ mode: 'inline',
137
+ className: 'block',
138
+ description:
139
+ '设置后选项卡的内容只有点开才会渲染,如果有选项卡放的可拉取接口的组件,那么这个接口只有在点开的时候才会拉取。'
140
+ },
141
+
142
+ {
143
+ type: 'switch',
144
+ name: 'unmountOnExit',
145
+ label: '隐藏即销毁',
146
+ mode: 'inline',
147
+ className: 'block',
148
+ description:
149
+ '设置后,如果选项卡内容关闭则销毁,配置「激活时才渲染」选项可以做到卡片内容每次点开都重新加载的效果。'
150
+ },
151
+ getSchemaTpl('visible')
152
+ ]
153
+ }
154
+ ])
155
+ ];
156
+
157
+ patchContainers = ['tabs.body'];
158
+
159
+ vRendererConfig: VRendererConfig = {
160
+ regions: {
161
+ body: {
162
+ key: 'body',
163
+ label: '内容区'
164
+ }
165
+ },
166
+ panelTitle: '卡片',
167
+ panelBody: [
168
+ getSchemaTpl('tabs', [
169
+ {
170
+ title: '常规',
171
+ body: [
172
+ {
173
+ name: 'title',
174
+ label: '标题',
175
+ type: 'input-text',
176
+ required: true
177
+ },
178
+ getSchemaTpl('icon'),
179
+ {
180
+ label: 'Hash',
181
+ name: 'hash',
182
+ type: 'input-text',
183
+ description: '设置后,会同步更新地址栏的 Hash。'
184
+ }
185
+ ]
186
+ },
187
+ {
188
+ title: '外观',
189
+ body: [getSchemaTpl('className')]
190
+ },
191
+ {
192
+ title: '显隐',
193
+ body: [getSchemaTpl('visible'), getSchemaTpl('disabled')]
194
+ },
195
+ {
196
+ title: '其他',
197
+ body: [
198
+ {
199
+ type: 'switch',
200
+ name: 'reload',
201
+ label: '内容刷新',
202
+ mode: 'inline',
203
+ className: 'block',
204
+ description:
205
+ '配置后,每次点开内容都会重新刷新,如果配置了,下面两个选项就不用配置了。'
206
+ },
207
+ {
208
+ type: 'switch',
209
+ name: 'mountOnEnter',
210
+ visibleOn: '!this.reload',
211
+ label: '激活时才渲染',
212
+ mode: 'inline',
213
+ className: 'block',
214
+ description:
215
+ '设置后选项卡的内容只有点开才会渲染,如果有选项卡放的可拉取接口的组件,那么这个接口只有在点开的时候才会拉取。'
216
+ },
217
+ {
218
+ visibleOn: '!this.reload',
219
+ type: 'switch',
220
+ name: 'unmountOnExit',
221
+ label: '隐藏即销毁',
222
+ mode: 'inline',
223
+ className: 'block',
224
+ description:
225
+ '设置后,如果选项卡内容关闭则销毁,配置「激活时才渲染」选项可以做到卡片内容每次点开都重新加载的效果。'
226
+ }
227
+ ]
228
+ }
229
+ ])
230
+ ]
231
+ };
232
+
233
+ wrapperProps = {
234
+ unmountOnExit: true,
235
+ mountOnEnter: true
236
+ };
237
+
238
+ tabWrapperResolve = (dom: HTMLElement) => dom.parentElement!;
239
+ overrides = {
240
+ renderTabs(this: any) {
241
+ const dom = this.super();
242
+
243
+ if (!this.renderTab && this.props.$$editor && dom) {
244
+ const tabs = this.props.tabs;
245
+ return mapReactElement(dom, item => {
246
+ if (item.type === Tab && item.props.$$id) {
247
+ const id = item.props.$$id;
248
+ const index = findIndex(tabs, (tab: any) => tab.$$id === id);
249
+ const info: RendererInfo = this.props.$$editor;
250
+ const plugin: TabsPlugin = info.plugin as any;
251
+
252
+ if (~index) {
253
+ const region = plugin.vRendererConfig?.regions?.body;
254
+
255
+ if (!region) {
256
+ return item;
257
+ }
258
+
259
+ return React.cloneElement(item, {
260
+ children: (
261
+ <VRenderer
262
+ key={id}
263
+ plugin={info.plugin}
264
+ renderer={info.renderer}
265
+ $schema="/schemas/TabSchema.json"
266
+ hostId={info.id}
267
+ memberIndex={index}
268
+ name={`${item.props.title || `卡片${index + 1}`}`}
269
+ id={id}
270
+ draggable={false}
271
+ wrapperResolve={plugin.tabWrapperResolve}
272
+ schemaPath={`${info.schemaPath}/tabs/${index}`}
273
+ path={`${this.props.$path}/${index}`} // 好像没啥用
274
+ data={this.props.data} // 好像没啥用
275
+ >
276
+ <Region
277
+ key={region.key}
278
+ preferTag={region.preferTag}
279
+ name={region.key}
280
+ label={region.label}
281
+ regionConfig={region}
282
+ placeholder={region.placeholder}
283
+ editorStore={plugin.manager.store}
284
+ manager={plugin.manager}
285
+ children={item.props.children}
286
+ wrapperResolve={region.wrapperResolve}
287
+ rendererName={info.renderer.name}
288
+ />
289
+ </VRenderer>
290
+ )
291
+ });
292
+ }
293
+ }
294
+
295
+ return item;
296
+ });
297
+ }
298
+
299
+ return dom;
300
+ }
301
+ };
302
+
303
+ /**
304
+ * 补充切换的 toolbar
305
+ * @param context
306
+ * @param toolbars
307
+ */
308
+ buildEditorToolbar(
309
+ context: BaseEventContext,
310
+ toolbars: Array<BasicToolbarItem>
311
+ ) {
312
+ if (
313
+ context.info.plugin === this &&
314
+ context.info.renderer.name === 'tabs' &&
315
+ !context.info.hostId
316
+ ) {
317
+ const node = context.node;
318
+
319
+ toolbars.push({
320
+ level: 'secondary',
321
+ icon: 'fa fa-chevron-left',
322
+ tooltip: '上个卡片',
323
+ onClick: () => {
324
+ const control = node.getComponent();
325
+
326
+ if (control?.switchTo) {
327
+ const currentIndex = control.currentIndex();
328
+ control.switchTo(currentIndex - 1);
329
+ }
330
+ }
331
+ });
332
+
333
+ toolbars.push({
334
+ level: 'secondary',
335
+ icon: 'fa fa-chevron-right',
336
+ tooltip: '下个卡片',
337
+ onClick: () => {
338
+ const control = node.getComponent();
339
+
340
+ if (control?.switchTo) {
341
+ const currentIndex = control.currentIndex();
342
+ control.switchTo(currentIndex + 1);
343
+ }
344
+ }
345
+ });
346
+ }
347
+ }
348
+
349
+ onPreventClick(e: PluginEvent<PreventClickEventContext>) {
350
+ const mouseEvent = e.context.data;
351
+
352
+ if (mouseEvent.defaultPrevented) {
353
+ return false;
354
+ } else if (
355
+ (mouseEvent.target as HTMLElement).closest('[role=tablist]>li')
356
+ ) {
357
+ return false;
358
+ }
359
+
360
+ return;
361
+ }
362
+ }
363
+
364
+ registerEditorPlugin(TabsPlugin);
@@ -0,0 +1,276 @@
1
+ import {Button, SchemaObject} from 'amis';
2
+ import React from 'react';
3
+ import {registerEditorPlugin} from '../manager';
4
+ import {BasePlugin, RegionConfig, RendererInfo} from '../plugin';
5
+ import {defaultValue, getSchemaTpl} from '../component/schemaTpl';
6
+
7
+ export class TasksPlugin extends BasePlugin {
8
+ // 关联渲染器名字
9
+ rendererName = 'tasks';
10
+ $schema = '/schemas/TasksSchema.json';
11
+
12
+ // 组件名称
13
+ name = '异步任务';
14
+ isBaseComponent = true;
15
+ description = '用来做异步任务呈现或者操作。';
16
+ docLink = '/amis/zh-CN/components/tasks';
17
+ tags = ['功能'];
18
+ icon = '';
19
+ scaffold = {
20
+ type: 'tasks',
21
+ name: 'tasks',
22
+ items: [
23
+ {
24
+ label: 'hive 任务',
25
+ key: 'hive',
26
+ status: 4,
27
+ remark:
28
+ '查看详情<a target="_blank" href="http://www.baidu.com">日志</a>。'
29
+ },
30
+ {
31
+ label: '小流量',
32
+ key: 'partial',
33
+ status: 4
34
+ },
35
+ {
36
+ label: '全量',
37
+ key: 'full',
38
+ status: 4
39
+ }
40
+ ]
41
+ };
42
+ previewSchema = {
43
+ ...this.scaffold
44
+ };
45
+
46
+ panelTitle = '异步任务';
47
+ panelBody = [
48
+ getSchemaTpl('tabs', [
49
+ {
50
+ title: '常规',
51
+ body: [
52
+ {
53
+ name: 'items',
54
+ label: '初始任务信息',
55
+ type: 'combo',
56
+ multiple: true,
57
+ multiLine: true,
58
+ items: [
59
+ {
60
+ name: 'label',
61
+ type: 'input-text',
62
+ label: '任务名称'
63
+ },
64
+ {
65
+ name: 'key',
66
+ type: 'input-text',
67
+ label: '任务ID'
68
+ },
69
+ {
70
+ name: 'status',
71
+ type: 'input-number',
72
+ label: '任务状态'
73
+ },
74
+ {
75
+ name: 'remark',
76
+ type: 'textarea',
77
+ label: '任务说明'
78
+ }
79
+ ],
80
+ addButtonText: '新增任务信息',
81
+ scaffold: {
82
+ label: '名称',
83
+ key: 'key',
84
+ status: 0,
85
+ remark: '说明'
86
+ },
87
+ description: '可以不设置,如果检测接口返回这些信息的话。'
88
+ },
89
+
90
+ getSchemaTpl('api', {
91
+ name: 'checkApi',
92
+ label: '状态检测接口'
93
+ }),
94
+
95
+ {
96
+ name: 'interval',
97
+ type: 'input-number',
98
+ min: 3000,
99
+ step: 500,
100
+ visibleOn: 'data.checkApi',
101
+ pipeIn: defaultValue(3000),
102
+ label: '定时检测间隔'
103
+ },
104
+
105
+ getSchemaTpl('api', {
106
+ name: 'submitApi',
107
+ label: '提交接口'
108
+ }),
109
+
110
+ getSchemaTpl('api', {
111
+ name: 'reSubmitApi',
112
+ label: '重试接口'
113
+ }),
114
+
115
+ {
116
+ name: 'taskNameLabel',
117
+ type: 'input-text',
118
+ pipeIn: defaultValue('任务名称'),
119
+ label: '任务名称栏标题'
120
+ },
121
+
122
+ {
123
+ name: 'operationLabel',
124
+ type: 'input-text',
125
+ pipeIn: defaultValue('操作'),
126
+ label: '操作栏标题'
127
+ },
128
+
129
+ {
130
+ name: 'statusLabel',
131
+ type: 'input-text',
132
+ pipeIn: defaultValue('状态'),
133
+ label: '状态栏标题'
134
+ },
135
+
136
+ {
137
+ name: 'remarkLabel',
138
+ type: 'input-text',
139
+ pipeIn: defaultValue('备注说明'),
140
+ label: '备注栏标题'
141
+ },
142
+
143
+ {
144
+ name: 'btnText',
145
+ label: '按钮名称',
146
+ type: 'input-text',
147
+ pipeIn: defaultValue('上线')
148
+ },
149
+
150
+ {
151
+ name: 'retryBtnText',
152
+ label: '重试按钮名称',
153
+ type: 'input-text',
154
+ pipeIn: defaultValue('重试')
155
+ },
156
+
157
+ {
158
+ name: 'statusTextMap',
159
+ pipeIn: defaultValue([
160
+ '未开始',
161
+ '就绪',
162
+ '进行中',
163
+ '出错',
164
+ '已完成',
165
+ '出错'
166
+ ]),
167
+ type: 'input-array',
168
+ label: '状态标签文字配置',
169
+ multiple: true,
170
+ addable: false,
171
+ removable: false,
172
+ items: {
173
+ type: 'input-text',
174
+ placeholder: '名称'
175
+ }
176
+ },
177
+
178
+ {
179
+ name: 'initialStatusCode',
180
+ label: '初始状态码',
181
+ pipeIn: defaultValue(0),
182
+ type: 'input-number'
183
+ },
184
+
185
+ {
186
+ name: 'readyStatusCode',
187
+ label: '就绪状态码',
188
+ pipeIn: defaultValue(1),
189
+ type: 'input-number'
190
+ },
191
+
192
+ {
193
+ name: 'loadingStatusCode',
194
+ label: '进行中状态码',
195
+ pipeIn: defaultValue(2),
196
+ type: 'input-number'
197
+ },
198
+
199
+ {
200
+ name: 'errorStatusCode',
201
+ label: '错误状态码',
202
+ pipeIn: defaultValue(3),
203
+ type: 'input-number'
204
+ },
205
+
206
+ {
207
+ name: 'finishStatusCode',
208
+ label: '完成状态码',
209
+ pipeIn: defaultValue(4),
210
+ type: 'input-number'
211
+ },
212
+
213
+ {
214
+ name: 'canRetryStatusCode',
215
+ label: '出错但可重试状态码',
216
+ pipeIn: defaultValue(5),
217
+ type: 'input-number'
218
+ }
219
+ ]
220
+ },
221
+ {
222
+ title: '外观',
223
+ body: [
224
+ getSchemaTpl('className', {
225
+ pipeIn: defaultValue('b-a bg-white table-responsive')
226
+ }),
227
+
228
+ getSchemaTpl('className', {
229
+ name: 'tableClassName',
230
+ label: '表格 CSS 类名',
231
+ pipeIn: defaultValue('table table-striped m-b-none')
232
+ }),
233
+
234
+ getSchemaTpl('className', {
235
+ name: 'btnClassName',
236
+ label: '按钮 CSS 类名',
237
+ pipeIn: defaultValue('btn-sm btn-default')
238
+ }),
239
+
240
+ getSchemaTpl('className', {
241
+ name: 'retryBtnClassName',
242
+ label: '重试按钮 CSS 类名',
243
+ pipeIn: defaultValue('btn-sm btn-danger')
244
+ }),
245
+
246
+ {
247
+ name: 'statusLabelMap',
248
+ pipeIn: defaultValue([
249
+ 'label-warning',
250
+ 'label-info',
251
+ 'label-info',
252
+ 'label-danger',
253
+ 'label-success',
254
+ 'label-danger'
255
+ ]),
256
+ type: 'input-array',
257
+ label: '状态标签 CSS 类名配置',
258
+ multiple: true,
259
+ addable: false,
260
+ removable: false,
261
+ items: {
262
+ type: 'input-text',
263
+ placeholder: 'CSS 类名'
264
+ }
265
+ }
266
+ ]
267
+ },
268
+ {
269
+ title: '显隐',
270
+ body: [getSchemaTpl('visible')]
271
+ }
272
+ ])
273
+ ];
274
+ }
275
+
276
+ registerEditorPlugin(TasksPlugin);
@@ -0,0 +1,75 @@
1
+ import {Button, SchemaObject} from 'amis';
2
+ import React from 'react';
3
+ import {registerEditorPlugin} from '../manager';
4
+ import {
5
+ BaseEventContext,
6
+ BasePlugin,
7
+ RegionConfig,
8
+ RendererInfo
9
+ } from '../plugin';
10
+ import {defaultValue, getSchemaTpl} from '../component/schemaTpl';
11
+ import {DatePlugin} from './Date';
12
+
13
+ export class TimePlugin extends DatePlugin {
14
+ // 关联渲染器名字
15
+ rendererName = 'time';
16
+ name = '时间展示';
17
+ isBaseComponent = true;
18
+
19
+ scaffold = {
20
+ type: 'time',
21
+ value: Math.round(Date.now() / 1000)
22
+ };
23
+
24
+ previewSchema = {
25
+ ...this.scaffold,
26
+ format: 'HH:mm:ss',
27
+ value: Math.round(Date.now() / 1000)
28
+ };
29
+ panelBodyCreator = (context: BaseEventContext) => {
30
+ return [
31
+ getSchemaTpl('tabs', [
32
+ {
33
+ title: '常规',
34
+ body: [
35
+ {
36
+ type: 'input-time',
37
+ name: 'value',
38
+ label: '时间数值'
39
+ },
40
+ {
41
+ type: 'input-text',
42
+ name: 'format',
43
+ label: '显示时间格式',
44
+ description: '请参考 moment 中的格式用法。',
45
+ pipeIn: defaultValue('HH:mm:ss')
46
+ },
47
+ {
48
+ type: 'input-text',
49
+ name: 'valueFormat',
50
+ label: '数据日期格式',
51
+ description: '请参考 moment 中的格式用法。',
52
+ pipeIn: defaultValue('X')
53
+ },
54
+ {
55
+ name: 'placeholder',
56
+ type: 'input-text',
57
+ pipeIn: defaultValue('-'),
58
+ label: '占位符'
59
+ }
60
+ ]
61
+ },
62
+ {
63
+ title: '外观',
64
+ body: [getSchemaTpl('className')]
65
+ },
66
+ {
67
+ title: '显隐',
68
+ body: [getSchemaTpl('ref'), getSchemaTpl('visible')]
69
+ }
70
+ ])
71
+ ];
72
+ };
73
+ }
74
+
75
+ registerEditorPlugin(TimePlugin);