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