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