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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (216) 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/VRenderer.d.ts +4 -0
  14. package/dist/component/base/InputComponentName.d.ts +1 -1
  15. package/dist/component/base/SearchCustomRendererPanel.d.ts +15 -0
  16. package/dist/component/base/SearchPanel.d.ts +83 -0
  17. package/dist/component/base/SearchRendererPanel.d.ts +2 -42
  18. package/dist/env.d.ts +1 -1
  19. package/dist/exports.min.js +1 -1
  20. package/dist/index.d.ts +4 -1
  21. package/dist/index.min.js +1 -1
  22. package/dist/manager.d.ts +16 -4
  23. package/dist/plugin/Alert.d.ts +1 -1
  24. package/dist/plugin/Button.d.ts +1 -1
  25. package/dist/plugin/Card.d.ts +1 -0
  26. package/dist/plugin/Cards.d.ts +2 -1
  27. package/dist/plugin/Carousel.d.ts +1 -0
  28. package/dist/plugin/Chart.d.ts +1 -0
  29. package/dist/plugin/Collapse.d.ts +1 -0
  30. package/dist/plugin/Custom.d.ts +3 -0
  31. package/dist/plugin/CustomRegion.d.ts +40 -0
  32. package/dist/plugin/Dialog.d.ts +1 -1
  33. package/dist/plugin/Drawer.d.ts +1 -1
  34. package/dist/plugin/DropDownButton.d.ts +1 -1
  35. package/dist/plugin/Each.d.ts +1 -1
  36. package/dist/plugin/Flex.d.ts +1 -0
  37. package/dist/plugin/Form/Control.d.ts +1 -0
  38. package/dist/plugin/Form/Form.d.ts +19 -3
  39. package/dist/plugin/Form/Formula.d.ts +3 -3
  40. package/dist/plugin/Form/InputURL.d.ts +1 -0
  41. package/dist/plugin/Form/Switch.d.ts +2 -0
  42. package/dist/plugin/Grid.d.ts +1 -0
  43. package/dist/plugin/HBox.d.ts +1 -0
  44. package/dist/plugin/IFrame.d.ts +3 -3
  45. package/dist/plugin/Json.d.ts +1 -0
  46. package/dist/plugin/List.d.ts +2 -1
  47. package/dist/plugin/Mapping.d.ts +1 -0
  48. package/dist/plugin/Markdown.d.ts +1 -0
  49. package/dist/plugin/Nav.d.ts +1 -0
  50. package/dist/plugin/Page.d.ts +1 -1
  51. package/dist/plugin/Panel/Outline.d.ts +8 -0
  52. package/dist/plugin/Progress.d.ts +1 -0
  53. package/dist/plugin/QRCode.d.ts +1 -0
  54. package/dist/plugin/Reset.d.ts +0 -1
  55. package/dist/plugin/Service.d.ts +1 -0
  56. package/dist/plugin/Sparkline.d.ts +1 -0
  57. package/dist/plugin/Status.d.ts +1 -0
  58. package/dist/plugin/Steps.d.ts +1 -0
  59. package/dist/plugin/Submit.d.ts +0 -1
  60. package/dist/plugin/Table.d.ts +1 -1
  61. package/dist/plugin/TableView.d.ts +1 -0
  62. package/dist/plugin/Tasks.d.ts +1 -0
  63. package/dist/plugin/TooltipWrapper.d.ts +1 -0
  64. package/dist/plugin/Video.d.ts +1 -0
  65. package/dist/plugin/WebComponent.d.ts +1 -0
  66. package/dist/plugin/Wizard.d.ts +11 -2
  67. package/dist/plugin/Wrapper.d.ts +1 -0
  68. package/dist/plugin.d.ts +8 -7
  69. package/dist/store/editor.d.ts +47 -11
  70. package/dist/store/node.d.ts +6 -0
  71. package/dist/style.css +1 -1
  72. package/dist/util.d.ts +1 -1
  73. package/package.json +10 -3
  74. package/src/component/schemaTpl.tsx +2157 -0
  75. package/src/plugin/Alert.tsx +87 -0
  76. package/src/plugin/AnchorNav.tsx +233 -0
  77. package/src/plugin/Audio.tsx +154 -0
  78. package/src/plugin/Avatar.tsx +77 -0
  79. package/src/plugin/Breadcrumb.tsx +107 -0
  80. package/src/plugin/Button.tsx +281 -0
  81. package/src/plugin/ButtonGroup.tsx +85 -0
  82. package/src/plugin/ButtonToolbar.tsx +87 -0
  83. package/src/plugin/CRUD.tsx +1835 -0
  84. package/src/plugin/Card.tsx +290 -0
  85. package/src/plugin/Cards.tsx +318 -0
  86. package/src/plugin/Carousel.tsx +377 -0
  87. package/src/plugin/Chart.tsx +218 -0
  88. package/src/plugin/CodeView.tsx +60 -0
  89. package/src/plugin/Collapse.tsx +136 -0
  90. package/src/plugin/CollapseGroup.tsx +167 -0
  91. package/src/plugin/Container.tsx +40 -0
  92. package/src/plugin/Custom.tsx +128 -0
  93. package/src/plugin/CustomRegion.tsx +156 -0
  94. package/src/plugin/Date.tsx +74 -0
  95. package/src/plugin/Datetime.tsx +68 -0
  96. package/src/plugin/Dialog.tsx +176 -0
  97. package/src/plugin/Divider.tsx +36 -0
  98. package/src/plugin/Drawer.tsx +214 -0
  99. package/src/plugin/DropDownButton.tsx +235 -0
  100. package/src/plugin/Each.tsx +150 -0
  101. package/src/plugin/ErrorRenderer.tsx +15 -0
  102. package/src/plugin/Flex.tsx +151 -0
  103. package/src/plugin/Form/ButtonGroupSelect.tsx +75 -0
  104. package/src/plugin/Form/ButtonToolbar.tsx +110 -0
  105. package/src/plugin/Form/ChainedSelect.tsx +70 -0
  106. package/src/plugin/Form/Checkbox.tsx +87 -0
  107. package/src/plugin/Form/Checkboxes.tsx +167 -0
  108. package/src/plugin/Form/CodeEditor.tsx +81 -0
  109. package/src/plugin/Form/Combo.tsx +582 -0
  110. package/src/plugin/Form/ConditionBuilder.tsx +315 -0
  111. package/src/plugin/Form/Control.tsx +139 -0
  112. package/src/plugin/Form/DiffEditor.tsx +111 -0
  113. package/src/plugin/Form/FieldSet.tsx +163 -0
  114. package/src/plugin/Form/Form.tsx +687 -0
  115. package/src/plugin/Form/Formula.tsx +79 -0
  116. package/src/plugin/Form/Group.tsx +295 -0
  117. package/src/plugin/Form/Hidden.tsx +44 -0
  118. package/src/plugin/Form/InputArray.tsx +228 -0
  119. package/src/plugin/Form/InputCity.tsx +93 -0
  120. package/src/plugin/Form/InputColor.tsx +123 -0
  121. package/src/plugin/Form/InputDate.tsx +175 -0
  122. package/src/plugin/Form/InputDateRange.tsx +225 -0
  123. package/src/plugin/Form/InputDateTime.tsx +183 -0
  124. package/src/plugin/Form/InputDateTimeRange.tsx +221 -0
  125. package/src/plugin/Form/InputEmail.tsx +33 -0
  126. package/src/plugin/Form/InputExcel.tsx +85 -0
  127. package/src/plugin/Form/InputFile.tsx +221 -0
  128. package/src/plugin/Form/InputGroup.tsx +96 -0
  129. package/src/plugin/Form/InputImage.tsx +266 -0
  130. package/src/plugin/Form/InputKV.tsx +72 -0
  131. package/src/plugin/Form/InputMonth.tsx +35 -0
  132. package/src/plugin/Form/InputMonthRange.tsx +195 -0
  133. package/src/plugin/Form/InputNumber.tsx +89 -0
  134. package/src/plugin/Form/InputPassword.tsx +33 -0
  135. package/src/plugin/Form/InputQuarter.tsx +35 -0
  136. package/src/plugin/Form/InputQuarterRange.tsx +195 -0
  137. package/src/plugin/Form/InputRange.tsx +121 -0
  138. package/src/plugin/Form/InputRating.tsx +78 -0
  139. package/src/plugin/Form/InputRepeat.tsx +57 -0
  140. package/src/plugin/Form/InputRichText.tsx +186 -0
  141. package/src/plugin/Form/InputSubForm.tsx +189 -0
  142. package/src/plugin/Form/InputTable.tsx +434 -0
  143. package/src/plugin/Form/InputTag.tsx +70 -0
  144. package/src/plugin/Form/InputText.tsx +186 -0
  145. package/src/plugin/Form/InputTime.tsx +85 -0
  146. package/src/plugin/Form/InputTree.tsx +229 -0
  147. package/src/plugin/Form/InputURL.tsx +34 -0
  148. package/src/plugin/Form/InputYear.tsx +35 -0
  149. package/src/plugin/Form/Item.tsx +327 -0
  150. package/src/plugin/Form/ListSelect.tsx +73 -0
  151. package/src/plugin/Form/LocationPicker.tsx +62 -0
  152. package/src/plugin/Form/MatrixCheckboxes.tsx +136 -0
  153. package/src/plugin/Form/NestedSelect.tsx +211 -0
  154. package/src/plugin/Form/Picker.tsx +209 -0
  155. package/src/plugin/Form/Radios.tsx +119 -0
  156. package/src/plugin/Form/Select.tsx +233 -0
  157. package/src/plugin/Form/Static.tsx +322 -0
  158. package/src/plugin/Form/Switch.tsx +107 -0
  159. package/src/plugin/Form/TabsTransfer.tsx +259 -0
  160. package/src/plugin/Form/Textarea.tsx +83 -0
  161. package/src/plugin/Form/Transfer.tsx +368 -0
  162. package/src/plugin/Form/TreeSelect.tsx +263 -0
  163. package/src/plugin/Form/UUID.tsx +48 -0
  164. package/src/plugin/Grid.tsx +798 -0
  165. package/src/plugin/HBox.tsx +727 -0
  166. package/src/plugin/IFrame.tsx +70 -0
  167. package/src/plugin/Image.tsx +314 -0
  168. package/src/plugin/Images.tsx +231 -0
  169. package/src/plugin/Json.tsx +69 -0
  170. package/src/plugin/Link.tsx +93 -0
  171. package/src/plugin/List.tsx +278 -0
  172. package/src/plugin/ListItem.tsx +229 -0
  173. package/src/plugin/Log.tsx +52 -0
  174. package/src/plugin/Mapping.tsx +149 -0
  175. package/src/plugin/Markdown.tsx +47 -0
  176. package/src/plugin/Nav.tsx +184 -0
  177. package/src/plugin/Operation.tsx +95 -0
  178. package/src/plugin/Others/Action.tsx +426 -0
  179. package/src/plugin/Others/BasicToolbar.tsx +585 -0
  180. package/src/plugin/Others/DataDebug.tsx +134 -0
  181. package/src/plugin/Others/TableCell.tsx +480 -0
  182. package/src/plugin/Others/Unknown.tsx +37 -0
  183. package/src/plugin/Page.tsx +306 -0
  184. package/src/plugin/Panel/AvailableRenderers.tsx +41 -0
  185. package/src/plugin/Panel/Code.tsx +44 -0
  186. package/src/plugin/Panel/Name.tsx +26 -0
  187. package/src/plugin/Panel/Outline.tsx +40 -0
  188. package/src/plugin/Panel.tsx +243 -0
  189. package/src/plugin/Plain.tsx +84 -0
  190. package/src/plugin/Progress.tsx +125 -0
  191. package/src/plugin/Property.tsx +139 -0
  192. package/src/plugin/QRCode.tsx +96 -0
  193. package/src/plugin/Reset.tsx +23 -0
  194. package/src/plugin/Service.tsx +162 -0
  195. package/src/plugin/Sparkline.tsx +40 -0
  196. package/src/plugin/Status.tsx +76 -0
  197. package/src/plugin/Steps.tsx +128 -0
  198. package/src/plugin/Submit.tsx +23 -0
  199. package/src/plugin/Table.tsx +428 -0
  200. package/src/plugin/TableView.tsx +709 -0
  201. package/src/plugin/Tabs.tsx +362 -0
  202. package/src/plugin/Tasks.tsx +274 -0
  203. package/src/plugin/Time.tsx +68 -0
  204. package/src/plugin/TooltipWrapper.tsx +193 -0
  205. package/src/plugin/Tpl.tsx +158 -0
  206. package/src/plugin/Video.tsx +158 -0
  207. package/src/plugin/WebComponent.tsx +53 -0
  208. package/src/plugin/Wizard.tsx +740 -0
  209. package/src/plugin/Wrapper.tsx +107 -0
  210. package/src/plugin.ts +1050 -0
  211. package/dist/150a58f3318ca7541ed9.png +0 -0
  212. package/dist/471adb97c322b226e589.png +0 -0
  213. package/dist/4de5f42360bc5946c3c2.png +0 -0
  214. package/dist/4e9968bba3855f088fed.png +0 -0
  215. package/dist/7f09c38ebc687fea847a.png +0 -0
  216. package/dist/c94073576487510314ea.png +0 -0
@@ -0,0 +1,235 @@
1
+ import {Button} from 'amis';
2
+ import React from 'react';
3
+ import {registerEditorPlugin} from '../manager';
4
+ import {
5
+ BaseEventContext,
6
+ BasePlugin,
7
+ BasicToolbarItem,
8
+ ContextMenuEventContext,
9
+ ContextMenuItem
10
+ } from '../plugin';
11
+ import {defaultValue, getSchemaTpl} from '../component/schemaTpl';
12
+ import {diff} from '../util';
13
+
14
+ export class DropDownButtonPlugin extends BasePlugin {
15
+ // 关联渲染器名字
16
+ rendererName = 'dropdown-button';
17
+ $schema = '/schemas/DropdownButtonSchema.json';
18
+
19
+ // 组件名称
20
+ name = '下拉按钮';
21
+ isBaseComponent = true;
22
+ description = '下拉按钮,更多的按钮通过点击后展示开来。';
23
+ tags = ['按钮'];
24
+ icon = 'fa fa-chevron-down';
25
+ docLink = '/amis/zh-CN/components/dropdown-button';
26
+ scaffold = {
27
+ type: 'dropdown-button',
28
+ label: '下拉按钮',
29
+ buttons: [
30
+ {
31
+ type: 'button',
32
+ label: '按钮1',
33
+ actionType: 'dialog',
34
+ dialog: {
35
+ title: '系统提示',
36
+ body: '对你点击了'
37
+ }
38
+ },
39
+
40
+ {
41
+ type: 'button',
42
+ label: '按钮2',
43
+ actionType: 'dialog',
44
+ dialog: {
45
+ title: '系统提示',
46
+ body: '对你点击了'
47
+ }
48
+ }
49
+ ]
50
+ };
51
+ previewSchema = {
52
+ ...this.scaffold
53
+ };
54
+
55
+ panelTitle = '下拉按钮';
56
+ panelBodyCreator = (context: BaseEventContext) =>
57
+ getSchemaTpl('tabs', [
58
+ {
59
+ title: '常规',
60
+ body: [
61
+ {
62
+ children: (
63
+ <Button
64
+ level="info"
65
+ size="sm"
66
+ className="m-b-sm"
67
+ block
68
+ onClick={this.editDetail.bind(this, context.id)}
69
+ >
70
+ 配置下拉按钮集合
71
+ </Button>
72
+ )
73
+ },
74
+ {
75
+ label: '名称',
76
+ type: 'input-text',
77
+ name: 'label'
78
+ },
79
+ {
80
+ name: 'trigger',
81
+ label: '触发方式',
82
+ type: 'button-group-select',
83
+ pipeIn: defaultValue('click'),
84
+ options: [
85
+ {
86
+ label: '点击',
87
+ value: 'click'
88
+ },
89
+ {
90
+ label: '鼠标经过',
91
+ value: 'hover'
92
+ }
93
+ ]
94
+ },
95
+ {
96
+ name: 'closeOnOutside',
97
+ label: '点击外部关闭',
98
+ type: 'switch',
99
+ mode: 'inline',
100
+ className: 'block',
101
+ pipeIn: defaultValue(true)
102
+ },
103
+ {
104
+ name: 'closeOnClick',
105
+ label: '点击内容关闭',
106
+ type: 'switch',
107
+ mode: 'inline',
108
+ className: 'block'
109
+ },
110
+ getSchemaTpl('icon'),
111
+ getSchemaTpl('icon', {name: 'rightIcon', label: '右侧图标'})
112
+ ]
113
+ },
114
+ {
115
+ title: '外观',
116
+ body: [
117
+ getSchemaTpl('size'),
118
+ {
119
+ label: '展示样式',
120
+ type: 'button-group-select',
121
+ size: 'xs',
122
+ name: 'level',
123
+ btnActiveClassName: 'active',
124
+ clearable: false,
125
+ options: [
126
+ {
127
+ label: '默认',
128
+ value: 'default',
129
+ level: 'default'
130
+ },
131
+ {
132
+ label: '无',
133
+ value: 'link',
134
+ level: 'link'
135
+ },
136
+ {
137
+ label: '主色',
138
+ value: 'primary',
139
+ level: 'primary'
140
+ },
141
+ {
142
+ label: '提示',
143
+ value: 'info',
144
+ level: 'info'
145
+ },
146
+ {
147
+ label: '成功',
148
+ value: 'success',
149
+ level: 'success'
150
+ },
151
+ {
152
+ label: '警告',
153
+ value: 'warning',
154
+ level: 'warning'
155
+ },
156
+ {
157
+ label: '严重',
158
+ value: 'danger',
159
+ level: 'danger'
160
+ }
161
+ ]
162
+ },
163
+ getSchemaTpl('className')
164
+ ]
165
+ },
166
+ {
167
+ title: '显隐',
168
+ body: [
169
+ getSchemaTpl('ref'),
170
+ getSchemaTpl('disabled'),
171
+ getSchemaTpl('visible')
172
+ ]
173
+ }
174
+ ]);
175
+
176
+ buildEditorToolbar(
177
+ {id, info}: BaseEventContext,
178
+ toolbars: Array<BasicToolbarItem>
179
+ ) {
180
+ if (info.renderer.name === 'dropdown-button') {
181
+ toolbars.push({
182
+ icon: 'fa fa-expand',
183
+ order: 100,
184
+ tooltip: '配置下拉按钮集合',
185
+ onClick: this.editDetail.bind(this, id)
186
+ });
187
+ }
188
+ }
189
+
190
+ editDetail(id: string) {
191
+ const manager = this.manager;
192
+ const store = manager.store;
193
+ const node = store.getNodeById(id);
194
+ const value = store.getValueOf(id);
195
+
196
+ node &&
197
+ value &&
198
+ this.manager.openSubEditor({
199
+ title: '配置下拉按钮集合',
200
+ value: value.buttons,
201
+ slot: {
202
+ type: 'button-group',
203
+ buttons: '$$',
204
+ block: true
205
+ },
206
+ onChange: newValue => {
207
+ newValue = {...value, buttons: newValue};
208
+ manager.panelChangeValue(newValue, diff(value, newValue));
209
+ }
210
+ });
211
+ }
212
+
213
+ buildEditorContextMenu(
214
+ {id, schema, region, info, selections}: ContextMenuEventContext,
215
+ menus: Array<ContextMenuItem>
216
+ ) {
217
+ if (selections.length || info?.plugin !== this) {
218
+ return;
219
+ }
220
+ if (info.renderer.name === 'dropdown-button') {
221
+ menus.push('|', {
222
+ label: '配置下拉按钮集合',
223
+ onSelect: this.editDetail.bind(this, id)
224
+ });
225
+ }
226
+ }
227
+
228
+ filterProps(props: any) {
229
+ // trigger 为 hover 会影响编辑体验。
230
+ props.trigger = 'click';
231
+ return props;
232
+ }
233
+ }
234
+
235
+ registerEditorPlugin(DropDownButtonPlugin);
@@ -0,0 +1,150 @@
1
+ import {Button} from 'amis';
2
+ import React from 'react';
3
+ import {registerEditorPlugin} from '../manager';
4
+ import {
5
+ BaseEventContext,
6
+ BasePlugin,
7
+ BasicToolbarItem,
8
+ ContextMenuEventContext,
9
+ ContextMenuItem
10
+ } from '../plugin';
11
+ import {defaultValue, getSchemaTpl} from '../component/schemaTpl';
12
+ import {diff, JSONPipeOut} from '../util';
13
+
14
+ export class EachPlugin extends BasePlugin {
15
+ // 关联渲染器名字
16
+ rendererName = 'each';
17
+ $schema = '/schemas/EachSchema.json';
18
+
19
+ // 组件名称
20
+ name = '循环 Each';
21
+ isBaseComponent = true;
22
+ description = '功能渲染器,可以基于现有变量循环输出渲染器。';
23
+ tags = ['功能'];
24
+ icon = 'fa fa-repeat';
25
+ scaffold = {
26
+ type: 'each',
27
+ name: 'arr',
28
+ items: {
29
+ type: 'tpl',
30
+ tpl: '<%= data.index + 1 %>. 内容:<%= data.item %>',
31
+ inline: false
32
+ }
33
+ };
34
+ previewSchema = {
35
+ ...this.scaffold,
36
+ value: ['a', 'b', 'c']
37
+ };
38
+
39
+ panelTitle = '循环';
40
+ panelBodyCreator = (context: BaseEventContext) => {
41
+ return [
42
+ {
43
+ type: 'input-text',
44
+ name: 'name',
45
+ label: '关联字段',
46
+ placeholder: 'varname',
47
+ description:
48
+ '如果所在容器有下发 value 则不需要配置,如果没有请配置变量名,支持多层级如:a.b,表示关联a对象下的b属性。目标变量可以是数组,也可以是对象。'
49
+ },
50
+
51
+ {
52
+ children: (
53
+ <Button
54
+ size="sm"
55
+ level="danger"
56
+ className="m-b"
57
+ block
58
+ onClick={this.editDetail.bind(this, context.id)}
59
+ >
60
+ 配置成员渲染器
61
+ </Button>
62
+ )
63
+ },
64
+
65
+ {
66
+ name: 'placeholder',
67
+ type: 'input-text',
68
+ label: '占位符',
69
+ pipeIn: defaultValue('暂无内容'),
70
+ description:
71
+ '当没有关联变量,或者目标变量不是数组或者对象时显示此占位信息'
72
+ },
73
+
74
+ getSchemaTpl('className')
75
+ ];
76
+ };
77
+
78
+ filterProps(props: any) {
79
+ props = JSONPipeOut(props);
80
+
81
+ // 至少显示一个成员,否则啥都不显示。
82
+ if (!props.value) {
83
+ props.value = [
84
+ {
85
+ item: 'mocked data'
86
+ }
87
+ ];
88
+ }
89
+
90
+ return props;
91
+ }
92
+
93
+ buildEditorToolbar(
94
+ {id, info}: BaseEventContext,
95
+ toolbars: Array<BasicToolbarItem>
96
+ ) {
97
+ if (info.renderer.name === 'each') {
98
+ toolbars.push({
99
+ icon: 'fa fa-expand',
100
+ order: 100,
101
+ tooltip: '配置成员渲染器',
102
+ onClick: this.editDetail.bind(this, id)
103
+ });
104
+ }
105
+ }
106
+
107
+ buildEditorContextMenu(
108
+ {id, schema, region, info, selections}: ContextMenuEventContext,
109
+ menus: Array<ContextMenuItem>
110
+ ) {
111
+ if (selections.length || info?.plugin !== this) {
112
+ return;
113
+ }
114
+ if (info.renderer.name === 'each') {
115
+ menus.push('|', {
116
+ label: '配置成员渲染器',
117
+ onSelect: this.editDetail.bind(this, id)
118
+ });
119
+ }
120
+ }
121
+
122
+ editDetail(id: string) {
123
+ const manager = this.manager;
124
+ const store = manager.store;
125
+ const node = store.getNodeById(id);
126
+ const value = store.getValueOf(id);
127
+
128
+ node &&
129
+ value &&
130
+ this.manager.openSubEditor({
131
+ title: '配置成员渲染器',
132
+ value: value.items,
133
+ slot: {
134
+ type: 'container',
135
+ body: '$$'
136
+ },
137
+ typeMutable: true,
138
+ onChange: newValue => {
139
+ newValue = {...value, items: newValue};
140
+ manager.panelChangeValue(newValue, diff(value, newValue));
141
+ },
142
+ data: {
143
+ item: 'mocked data',
144
+ index: 0
145
+ }
146
+ });
147
+ }
148
+ }
149
+
150
+ registerEditorPlugin(EachPlugin);
@@ -0,0 +1,15 @@
1
+ import {registerEditorPlugin} from '../manager';
2
+ import {BasePlugin} from '../plugin';
3
+
4
+ export class ErrorRendererPlugin extends BasePlugin {
5
+ order = -9999;
6
+
7
+ // 关联渲染器名字
8
+ rendererName = 'error';
9
+
10
+ // 组件名称
11
+ name = 'Error';
12
+ isBaseComponent = true;
13
+ }
14
+
15
+ registerEditorPlugin(ErrorRendererPlugin);
@@ -0,0 +1,151 @@
1
+ /**
2
+ * @file Flex 布局
3
+ */
4
+ import {registerEditorPlugin} from '../manager';
5
+ import {
6
+ BasePlugin,
7
+ PluginEvent,
8
+ RegionConfig,
9
+ RendererJSONSchemaResolveEventContext
10
+ } from '../plugin';
11
+ import {getSchemaTpl} from '../component/schemaTpl';
12
+ import {EditorNodeType} from '../store/node';
13
+
14
+ export class FlexPlugin extends BasePlugin {
15
+ // 关联渲染器名字
16
+ rendererName = 'flex';
17
+ $schema = '/schemas/FlexSchema.json';
18
+ disabledRendererPlugin = true;
19
+
20
+ // 组件名称
21
+ name = 'Flex 布局';
22
+ isBaseComponent = true;
23
+ icon = 'fa fa-columns';
24
+ description = 'flex 布局';
25
+ docLink = '/amis/zh-CN/components/flex';
26
+ tags = ['容器'];
27
+ scaffold = {
28
+ type: 'flex',
29
+ items: [
30
+ {
31
+ type: 'wrapper',
32
+ body: '第一列'
33
+ },
34
+ {
35
+ type: 'wrapper',
36
+ body: '第二列'
37
+ },
38
+ {
39
+ type: 'wrapper',
40
+ body: '第三列'
41
+ }
42
+ ]
43
+ };
44
+ previewSchema = {
45
+ ...this.scaffold
46
+ };
47
+
48
+ panelTitle = 'Flex';
49
+ panelBody = [
50
+ getSchemaTpl('tabs', [
51
+ {
52
+ title: '常规',
53
+ body: [
54
+ {
55
+ name: 'items',
56
+ label: '内容集合',
57
+ type: 'combo',
58
+ scaffold: {
59
+ type: 'wrapper',
60
+ body: '子节点内容'
61
+ },
62
+ minLength: 2,
63
+ multiple: true,
64
+ // draggable: true,
65
+ draggableTip: '',
66
+ items: [
67
+ {
68
+ type: 'tpl',
69
+ tpl:
70
+ '<span class="label label-default">子节点${index | plus}</span>'
71
+ }
72
+ ]
73
+ },
74
+ {
75
+ name: 'justify',
76
+ type: 'select',
77
+ value: 'center',
78
+ label: '子节点水平分布方式',
79
+ options: [
80
+ 'start',
81
+ 'flex-start',
82
+ 'center',
83
+ 'end',
84
+ 'flex-end',
85
+ 'space-around',
86
+ 'space-between',
87
+ 'space-evenly'
88
+ ]
89
+ },
90
+ {
91
+ name: 'alignItems',
92
+ type: 'select',
93
+ value: 'center',
94
+ label: '子节点垂直方向位置',
95
+ options: [
96
+ 'stretch',
97
+ 'start',
98
+ 'flex-start',
99
+ 'flex-end',
100
+ 'end',
101
+ 'center',
102
+ 'baseline'
103
+ ]
104
+ },
105
+ {
106
+ name: 'direction',
107
+ type: 'radios',
108
+ label: '布局方向',
109
+ value: 'column',
110
+ inline: true,
111
+ options: [
112
+ {label: '水平', value: 'row'},
113
+ {label: '垂直', value: 'column'}
114
+ ]
115
+ }
116
+ ]
117
+ },
118
+ {
119
+ title: '外观',
120
+ body: [getSchemaTpl('className'), getSchemaTpl('style')]
121
+ },
122
+ {
123
+ title: '显隐',
124
+ body: [getSchemaTpl('visible')]
125
+ }
126
+ ])
127
+ ];
128
+
129
+ regions: Array<RegionConfig> = [
130
+ {
131
+ key: 'items',
132
+ label: '子节点集合',
133
+ // 复写渲染器里面的 render 方法
134
+ renderMethod: 'render',
135
+ dndMode: 'position-h'
136
+ }
137
+ ];
138
+
139
+ afterResolveJsonSchema(
140
+ event: PluginEvent<RendererJSONSchemaResolveEventContext>
141
+ ) {
142
+ const context = event.context;
143
+ const parent = context.node.parent?.host as EditorNodeType;
144
+
145
+ if (parent?.info?.plugin === this) {
146
+ event.setData('/schemas/FlexColumn.json');
147
+ }
148
+ }
149
+ }
150
+
151
+ registerEditorPlugin(FlexPlugin);
@@ -0,0 +1,75 @@
1
+ import {registerEditorPlugin} from '../../manager';
2
+ import {BasePlugin} from '../../plugin';
3
+ import {getSchemaTpl} from '../../component/schemaTpl';
4
+
5
+ export class ButtonGroupControlPlugin extends BasePlugin {
6
+ // 关联渲染器名字
7
+ rendererName = 'button-group-select';
8
+ $schema = '/schemas/ButtonGroupControlSchema.json';
9
+
10
+ // 组件名称
11
+ name = '按钮点选';
12
+ isBaseComponent = true;
13
+ icon = 'fa fa-object-group';
14
+ description =
15
+ '用来展示多个按钮,视觉上会作为一个整体呈现,同时可以作为表单项选项选择器来用。';
16
+ docLink = '/amis/zh-CN/components/button-group';
17
+ tags = ['按钮'];
18
+ scaffold = {
19
+ type: 'button-group-select',
20
+ name: 'a',
21
+ options: [
22
+ {
23
+ label: '选项1',
24
+ value: 'a'
25
+ },
26
+ {
27
+ label: '选项2',
28
+ value: 'b'
29
+ }
30
+ ]
31
+ };
32
+ previewSchema: any = {
33
+ type: 'form',
34
+ wrapWithPanel: false,
35
+ mode: 'horizontal',
36
+ body: {
37
+ ...this.scaffold,
38
+ value: 'a',
39
+ label: '按钮组',
40
+ description: '按钮组可以当选项用。'
41
+ }
42
+ };
43
+
44
+ panelTitle = '按钮组';
45
+ panelBody = [
46
+ getSchemaTpl('switchDefaultValue', {
47
+ visibleOn: '!this.defaultCheckAll'
48
+ }),
49
+
50
+ {
51
+ type: 'button-group-select',
52
+ name: 'value',
53
+ label: '默认值',
54
+ source: '${options}',
55
+ visibleOn: 'typeof this.value !== "undefined"',
56
+ multiple: true
57
+ },
58
+
59
+ getSchemaTpl('options'),
60
+ getSchemaTpl('source'),
61
+
62
+ getSchemaTpl('multiple'),
63
+
64
+ getSchemaTpl('joinValues', {
65
+ visibleOn: true
66
+ }),
67
+ getSchemaTpl('delimiter', {
68
+ hiddenOn: 'this.joinValues === false'
69
+ }),
70
+ getSchemaTpl('extractValue'),
71
+ getSchemaTpl('autoFill')
72
+ ];
73
+ }
74
+
75
+ registerEditorPlugin(ButtonGroupControlPlugin);