amis-editor 4.1.0-beta.2 → 4.1.0-beta.22

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 +4 -0
  5. package/dist/component/VRenderer.d.ts +4 -0
  6. package/dist/component/base/SearchCustomRendererPanel.d.ts +15 -0
  7. package/dist/component/base/SearchPanel.d.ts +83 -0
  8. package/dist/component/base/SearchRendererPanel.d.ts +2 -42
  9. package/dist/exports.min.js +1 -1
  10. package/dist/index.d.ts +4 -1
  11. package/dist/index.min.js +1 -1
  12. package/dist/manager.d.ts +14 -3
  13. package/dist/plugin/Card.d.ts +1 -0
  14. package/dist/plugin/Cards.d.ts +1 -0
  15. package/dist/plugin/Carousel.d.ts +1 -0
  16. package/dist/plugin/Chart.d.ts +1 -0
  17. package/dist/plugin/Collapse.d.ts +1 -0
  18. package/dist/plugin/Custom.d.ts +3 -0
  19. package/dist/plugin/CustomRegion.d.ts +43 -0
  20. package/dist/plugin/Flex.d.ts +1 -0
  21. package/dist/plugin/Form/Control.d.ts +1 -0
  22. package/dist/plugin/Form/Form.d.ts +19 -3
  23. package/dist/plugin/Form/InputURL.d.ts +1 -0
  24. package/dist/plugin/Form/Switch.d.ts +2 -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 +2157 -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 +1835 -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 +327 -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 +233 -0
  137. package/src/plugin/Form/Static.tsx +335 -0
  138. package/src/plugin/Form/Switch.tsx +118 -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,156 @@
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 {isObject} from '../util';
12
+
13
+ export class MappingPlugin extends BasePlugin {
14
+ // 关联渲染器名字
15
+ rendererName = 'mapping';
16
+ $schema = '/schemas/MappingSchema.json';
17
+
18
+ // 组件名称
19
+ name = '映射';
20
+ isBaseComponent = true;
21
+ description =
22
+ '对现有值做映射展示,比如原始值是:1、2、3...,需要展示成:下线、上线、过期等等。';
23
+ docLink = '/amis/zh-CN/components/mapping';
24
+ tags = ['展示'];
25
+ icon = 'fa fa-exchange';
26
+ scaffold = {
27
+ type: 'mapping',
28
+ value: 2,
29
+ map: {
30
+ 0: '<span class="label label-info">一</span>',
31
+ 1: '<span class="label label-success">二</span>',
32
+ 2: '<span class="label label-danger">三</span>',
33
+ 3: '<span class="label label-warning">四</span>',
34
+ 4: '<span class="label label-primary">五</span>',
35
+ '*': '<span class="label label-default">-</span>'
36
+ }
37
+ };
38
+ previewSchema = {
39
+ ...this.scaffold
40
+ };
41
+
42
+ panelTitle = '映射';
43
+ panelBodyCreator = (context: BaseEventContext) => {
44
+ const isUnderField = /\/field\/\w+$/.test(context.path as string);
45
+ return [
46
+ getSchemaTpl('tabs', [
47
+ {
48
+ title: '常规',
49
+ body: [
50
+ isUnderField
51
+ ? {
52
+ type: 'tpl',
53
+ inline: false,
54
+ className: 'text-info text-sm',
55
+ tpl: '<p>当前为字段内容节点配置,选择上层还有更多的配置。</p>'
56
+ }
57
+ : null,
58
+
59
+ {
60
+ label: '映射表',
61
+ type: 'combo',
62
+ scaffold: {
63
+ key: 'key-{index}',
64
+ value: 'value-{index}'
65
+ },
66
+ required: true,
67
+ name: 'map',
68
+ descriptionClassName: 'help-block text-xs m-b-none',
69
+ description:
70
+ '<p>当值命中左侧 Key 时,展示右侧内容,当没有命中时,默认实现 Key 为 <code>*</code>的内容</div>(请确保key值唯一)',
71
+ multiple: true,
72
+ pipeIn: (value: any) => {
73
+ if (!isObject(value)) {
74
+ return [
75
+ {
76
+ key: '*',
77
+ value: '通配值'
78
+ }
79
+ ];
80
+ }
81
+
82
+ let arr: Array<any> = [];
83
+
84
+ Object.keys(value).forEach(key => {
85
+ arr.push({
86
+ key: key || '',
87
+ value:
88
+ typeof value[key] === 'string'
89
+ ? value[key]
90
+ : JSON.stringify(value[key])
91
+ });
92
+ });
93
+ return arr;
94
+ },
95
+ pipeOut: (value: any) => {
96
+ if (!Array.isArray(value)) {
97
+ return value;
98
+ }
99
+ let obj: any = {};
100
+
101
+ value.forEach((item: any, idx: number) => {
102
+ let key: string = item.key || '';
103
+ let value: any = item.value;
104
+ if (key === 'key-{index}' && value === 'value-{index}') {
105
+ key = key.replace('-{index}', `${idx}`);
106
+ value = value.replace('-{index}', `${idx}`);
107
+ }
108
+ try {
109
+ value = JSON.parse(value);
110
+ } catch (e) {}
111
+
112
+ obj[key] = value;
113
+ });
114
+
115
+ return obj;
116
+ },
117
+ items: [
118
+ {
119
+ placeholder: 'Key',
120
+ type: 'input-text',
121
+ unique: true,
122
+ name: 'key',
123
+ required: true,
124
+ columnClassName: 'w-xs'
125
+ },
126
+
127
+ {
128
+ placeholder: '内容',
129
+ type: 'input-text',
130
+ name: 'value'
131
+ }
132
+ ]
133
+ },
134
+
135
+ {
136
+ name: 'placeholder',
137
+ type: 'input-text',
138
+ pipeIn: defaultValue('-'),
139
+ label: '占位符'
140
+ }
141
+ ]
142
+ },
143
+ {
144
+ title: '外观',
145
+ body: [getSchemaTpl('className')]
146
+ },
147
+ {
148
+ title: '显隐',
149
+ body: [getSchemaTpl('ref'), getSchemaTpl('visible')]
150
+ }
151
+ ])
152
+ ];
153
+ };
154
+ }
155
+
156
+ registerEditorPlugin(MappingPlugin);
@@ -0,0 +1,47 @@
1
+ import {registerEditorPlugin} from '../manager';
2
+ import {BaseEventContext, BasePlugin} from '../plugin';
3
+ import {defaultValue, getSchemaTpl} from '../component/schemaTpl';
4
+
5
+ export class MarkdownPlugin extends BasePlugin {
6
+ // 关联渲染器名字
7
+ rendererName = 'markdown';
8
+ $schema = '/schemas/MarkdownSchema.json';
9
+
10
+ // 组件名称
11
+ name = 'Markdown';
12
+ isBaseComponent = true;
13
+ description = '展示 markdown 内容';
14
+ docLink = '/amis/zh-CN/components/markdown';
15
+ tags = ['展示'];
16
+ icon = 'fa fa-file-text';
17
+ scaffold = {
18
+ type: 'markdown',
19
+ value: '## 这是标题'
20
+ };
21
+ previewSchema = {
22
+ ...this.scaffold
23
+ };
24
+
25
+ panelTitle = 'MD';
26
+ panelBodyCreator = (context: BaseEventContext) => {
27
+ const isUnderField = /\/field\/\w+$/.test(context.path as string);
28
+ return [
29
+ getSchemaTpl('tabs', [
30
+ {
31
+ title: '常规',
32
+ body: [getSchemaTpl('markdownBody')]
33
+ },
34
+ {
35
+ title: '外观',
36
+ body: [getSchemaTpl('className')]
37
+ },
38
+ {
39
+ title: '显隐',
40
+ body: [getSchemaTpl('ref'), getSchemaTpl('visible')]
41
+ }
42
+ ])
43
+ ];
44
+ };
45
+ }
46
+
47
+ registerEditorPlugin(MarkdownPlugin);
@@ -0,0 +1,186 @@
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 NavPlugin extends BasePlugin {
8
+ // 关联渲染器名字
9
+ rendererName = 'nav';
10
+ $schema = '/schemas/NavSchema.json';
11
+
12
+ // 组件名称
13
+ name = '导航';
14
+ isBaseComponent = true;
15
+ description = '用来渲染导航菜单,支持横排和竖排。';
16
+ docLink = '/amis/zh-CN/components/nav';
17
+ tags = ['功能'];
18
+ icon = 'fa fa-map-signs';
19
+ scaffold = {
20
+ type: 'nav',
21
+ stacked: true,
22
+ links: [
23
+ {
24
+ label: '页面1',
25
+ to: '?id=1'
26
+ },
27
+ {
28
+ label: '页面2',
29
+ to: '?id=2'
30
+ }
31
+ ]
32
+ };
33
+ previewSchema = {
34
+ ...this.scaffold
35
+ };
36
+
37
+ panelTitle = '导航';
38
+
39
+ panelDefinitions = {
40
+ links: {
41
+ label: '菜单管理',
42
+ name: 'links',
43
+ type: 'combo',
44
+ multiple: true,
45
+ draggable: true,
46
+ addButtonText: '新增菜单',
47
+ multiLine: true,
48
+ messages: {
49
+ validateFailed: '菜单中存在配置错误,请仔细检查'
50
+ },
51
+ scaffold: {
52
+ label: '',
53
+ to: ''
54
+ },
55
+ items: [
56
+ {
57
+ type: 'input-text',
58
+ name: 'label',
59
+ label: '名称',
60
+ required: true
61
+ },
62
+
63
+ {
64
+ type: 'input-text',
65
+ name: 'to',
66
+ label: '跳转地址',
67
+ required: true
68
+ },
69
+
70
+ {
71
+ type: 'icon-picker',
72
+ name: 'icon',
73
+ label: '图标'
74
+ },
75
+
76
+ {
77
+ type: 'group',
78
+ label: '是否高亮',
79
+ direction: 'vertical',
80
+ className: 'm-b-none',
81
+ labelRemark: {
82
+ trigger: 'click',
83
+ rootClose: true,
84
+ className: 'm-l-xs',
85
+ content: '可以配置该菜单是否要高亮',
86
+ placement: 'left'
87
+ },
88
+ body: [
89
+ {
90
+ name: 'active',
91
+ type: 'radios',
92
+ inline: true,
93
+ // pipeIn: (value:any) => typeof value === 'boolean' ? value : '1'
94
+ options: [
95
+ {
96
+ label: '是',
97
+ value: true
98
+ },
99
+
100
+ {
101
+ label: '否',
102
+ value: false
103
+ },
104
+
105
+ {
106
+ label: '表达式',
107
+ value: ''
108
+ }
109
+ ]
110
+ },
111
+
112
+ {
113
+ name: 'activeOn',
114
+ autoComplete: false,
115
+ visibleOn: 'typeof this.active !== "boolean"',
116
+ type: 'input-text',
117
+ placeholder: '留空将自动分析菜单地址',
118
+ className: 'm-t-n-sm'
119
+ }
120
+ ]
121
+ },
122
+
123
+ {
124
+ type: 'switch',
125
+ label: '包含子菜单',
126
+ name: 'children',
127
+ mode: 'inline',
128
+ className: 'block',
129
+ pipeIn: (value: any) => !!value,
130
+ pipeOut: (value: any) => (value ? [{label: '', to: ''}] : undefined),
131
+ messages: {
132
+ validateFailed: '子菜单中存在配置错误,请仔细检查'
133
+ }
134
+ },
135
+
136
+ {
137
+ name: 'children',
138
+ $ref: 'links',
139
+ visibleOn: 'this.hasOwnProperty("children") && this.children',
140
+ label: '子菜单管理',
141
+ addButtonText: '新增子菜单'
142
+ }
143
+ ]
144
+ }
145
+ };
146
+ panelBody = [
147
+ getSchemaTpl('tabs', [
148
+ {
149
+ title: '常规',
150
+ body: [
151
+ {
152
+ $ref: 'links',
153
+ name: 'links'
154
+ },
155
+
156
+ {type: 'divider'},
157
+
158
+ getSchemaTpl('api', {
159
+ name: 'source',
160
+ label: '获取菜单接口',
161
+ description: '如果菜单地址希望可以动态设置,请在此填入接口地址'
162
+ })
163
+ ]
164
+ },
165
+ {
166
+ title: '外观',
167
+ body: [
168
+ {
169
+ name: 'stacked',
170
+ type: 'switch',
171
+ mode: 'inline',
172
+ className: 'block',
173
+ label: '是否竖着摆放'
174
+ },
175
+ getSchemaTpl('className')
176
+ ]
177
+ },
178
+ {
179
+ title: '显隐',
180
+ body: [getSchemaTpl('ref'), getSchemaTpl('visible')]
181
+ }
182
+ ])
183
+ ];
184
+ }
185
+
186
+ registerEditorPlugin(NavPlugin);
@@ -0,0 +1,97 @@
1
+ import {Button, SchemaObject} from 'amis';
2
+ import React from 'react';
3
+ import {registerEditorPlugin} from '../manager';
4
+ import {
5
+ BaseEventContext,
6
+ BasePlugin,
7
+ BasicSubRenderInfo,
8
+ PluginInterface,
9
+ RegionConfig,
10
+ RendererEventContext,
11
+ RendererInfo,
12
+ SubRendererInfo
13
+ } from '../plugin';
14
+ import {defaultValue, getSchemaTpl} from '../component/schemaTpl';
15
+
16
+ export class OperationPlugin extends BasePlugin {
17
+ // 关联渲染器名字
18
+ rendererName = 'operation';
19
+ $schema = '/schemas/OperationSchema.json';
20
+
21
+ // 组件名称
22
+ name = '操作栏';
23
+ isBaseComponent = true;
24
+ description = '操作栏,用于表格。';
25
+ tags = ['展示'];
26
+ icon = '';
27
+ scaffold = {
28
+ type: 'operation',
29
+ label: '操作',
30
+ buttons: [
31
+ {
32
+ label: '按钮',
33
+ type: 'button'
34
+ }
35
+ ]
36
+ };
37
+ previewSchema = {
38
+ type: 'tpl',
39
+ tpl: '操作栏'
40
+ };
41
+
42
+ regions: Array<RegionConfig> = [
43
+ {
44
+ key: 'buttons',
45
+ label: '按钮集',
46
+ renderMethod: 'render',
47
+ insertPosition: 'inner',
48
+ preferTag: '按钮'
49
+ }
50
+ ];
51
+
52
+ panelTitle = '操作栏';
53
+ panelBodyCreator = (context: BaseEventContext) => {
54
+ return [
55
+ getSchemaTpl('className', {
56
+ name: 'innerClassName'
57
+ }),
58
+
59
+ {
60
+ children: (
61
+ <Button
62
+ level="info"
63
+ size="sm"
64
+ className="m-b-sm"
65
+ block
66
+ onClick={() => {
67
+ // this.manager.showInsertPanel('buttons', context.id, '按钮');
68
+ this.manager.showRendererPanel(
69
+ '按钮',
70
+ '请从左侧组件面板中点击添加新的按钮'
71
+ );
72
+ }}
73
+ >
74
+ 添加按钮
75
+ </Button>
76
+ )
77
+ }
78
+ ];
79
+ };
80
+
81
+ buildSubRenderers(
82
+ context: RendererEventContext,
83
+ renderers: Array<SubRendererInfo>
84
+ ): BasicSubRenderInfo | Array<BasicSubRenderInfo> | void {
85
+ if (
86
+ context &&
87
+ context.info &&
88
+ context.info.renderer &&
89
+ (context.info.renderer.name === 'table' ||
90
+ context.info.renderer.name === 'crud')
91
+ ) {
92
+ return super.buildSubRenderers.apply(this, arguments);
93
+ }
94
+ }
95
+ }
96
+
97
+ registerEditorPlugin(OperationPlugin);