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.
- 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 +4 -0
- 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/Form.d.ts +19 -3
- package/dist/plugin/Form/InputURL.d.ts +1 -0
- package/dist/plugin/Form/Switch.d.ts +2 -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/Wizard.d.ts +11 -2
- 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 +2157 -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 +1835 -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 +327 -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 +233 -0
- package/src/plugin/Form/Static.tsx +335 -0
- package/src/plugin/Form/Switch.tsx +118 -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,386 @@
|
|
1
|
+
import {Button, SchemaObject} from 'amis';
|
2
|
+
import React from 'react';
|
3
|
+
import {registerEditorPlugin} from '../manager';
|
4
|
+
import {
|
5
|
+
BaseEventContext,
|
6
|
+
BasePlugin,
|
7
|
+
BasicToolbarItem,
|
8
|
+
PluginEvent,
|
9
|
+
PreventClickEventContext,
|
10
|
+
RegionConfig,
|
11
|
+
RendererInfo
|
12
|
+
} from '../plugin';
|
13
|
+
import {defaultValue, getSchemaTpl} from '../component/schemaTpl';
|
14
|
+
import {mockValue} from '../mocker';
|
15
|
+
|
16
|
+
export class CarouselPlugin extends BasePlugin {
|
17
|
+
// 关联渲染器名字
|
18
|
+
rendererName = 'carousel';
|
19
|
+
$schema = '/schemas/CarouselSchema.json';
|
20
|
+
|
21
|
+
// 组件名称
|
22
|
+
name = '轮播图';
|
23
|
+
isBaseComponent = true;
|
24
|
+
description =
|
25
|
+
'用来渲染轮播图,可以配置每一页的内容(不只是图片),可以配置过渡动画。';
|
26
|
+
docLink = '/amis/zh-CN/components/carousel';
|
27
|
+
tags = ['展示'];
|
28
|
+
icon = 'fa fa-images';
|
29
|
+
scaffold = {
|
30
|
+
type: 'carousel',
|
31
|
+
options: [
|
32
|
+
{
|
33
|
+
image: mockValue({type: 'image'})
|
34
|
+
},
|
35
|
+
{
|
36
|
+
html: '<div style="width: 100%; height: 300px; background: #e3e3e3; text-align: center; line-height: 300px;">carousel data</div>'
|
37
|
+
},
|
38
|
+
{
|
39
|
+
image: mockValue({type: 'image'})
|
40
|
+
}
|
41
|
+
]
|
42
|
+
};
|
43
|
+
previewSchema = {
|
44
|
+
...this.scaffold
|
45
|
+
};
|
46
|
+
|
47
|
+
panelTitle = '轮播图';
|
48
|
+
panelBodyCreator = (context: BaseEventContext) => {
|
49
|
+
const isUnderField = /\/field\/\w+$/.test(context.path as string);
|
50
|
+
return [
|
51
|
+
getSchemaTpl('tabs', [
|
52
|
+
{
|
53
|
+
title: '常规',
|
54
|
+
body: [
|
55
|
+
isUnderField
|
56
|
+
? {
|
57
|
+
type: 'tpl',
|
58
|
+
inline: false,
|
59
|
+
className: 'text-info text-sm',
|
60
|
+
tpl: '<p>当前为字段内容节点配置,选择上层还有更多的配置。</p>'
|
61
|
+
}
|
62
|
+
: null,
|
63
|
+
{
|
64
|
+
type: 'formula',
|
65
|
+
name: '__mode',
|
66
|
+
autoSet: false,
|
67
|
+
formula:
|
68
|
+
'!this.name && !this.source && Array.isArray(this.options) ? 2 : 1'
|
69
|
+
},
|
70
|
+
{
|
71
|
+
label: '数据源',
|
72
|
+
name: '__mode',
|
73
|
+
type: 'button-group-select',
|
74
|
+
size: 'xs',
|
75
|
+
mode: 'inline',
|
76
|
+
className: 'w-full',
|
77
|
+
options: [
|
78
|
+
{
|
79
|
+
label: '关联字段',
|
80
|
+
value: 1
|
81
|
+
},
|
82
|
+
{
|
83
|
+
label: '静态设置',
|
84
|
+
value: 2
|
85
|
+
}
|
86
|
+
]
|
87
|
+
},
|
88
|
+
{
|
89
|
+
label: '字段名',
|
90
|
+
name: 'name',
|
91
|
+
type: 'input-text',
|
92
|
+
description: '设置字段名,关联当前数据作用域中的数据。',
|
93
|
+
visibleOn: 'this.__mode == 1'
|
94
|
+
},
|
95
|
+
{
|
96
|
+
type: 'combo',
|
97
|
+
name: 'options',
|
98
|
+
visibleOn: 'this.__mode == 2',
|
99
|
+
label: '轮播选项内容',
|
100
|
+
multiple: true,
|
101
|
+
multiLine: true,
|
102
|
+
addable: true,
|
103
|
+
removable: true,
|
104
|
+
typeSwitchable: false,
|
105
|
+
conditions: [
|
106
|
+
{
|
107
|
+
label: '图片',
|
108
|
+
test: 'this.type === "image"',
|
109
|
+
items: [
|
110
|
+
getSchemaTpl('imageUrl', {
|
111
|
+
name: 'content'
|
112
|
+
}),
|
113
|
+
{
|
114
|
+
type: 'input-text',
|
115
|
+
label: '图片标题',
|
116
|
+
name: 'title',
|
117
|
+
visibleOn: 'this.type == "image"'
|
118
|
+
},
|
119
|
+
getSchemaTpl('className', {
|
120
|
+
label: '图片标题类名',
|
121
|
+
name: 'titleClassName',
|
122
|
+
visibleOn: 'this.type == "image"'
|
123
|
+
}),
|
124
|
+
{
|
125
|
+
type: 'textarea',
|
126
|
+
label: '图片描述',
|
127
|
+
name: 'description',
|
128
|
+
visibleOn: 'this.type == "image"'
|
129
|
+
},
|
130
|
+
getSchemaTpl('className', {
|
131
|
+
label: '图片描述类名',
|
132
|
+
name: 'descriptionClassName',
|
133
|
+
visibleOn: 'this.type == "image"'
|
134
|
+
}),
|
135
|
+
{
|
136
|
+
type: 'input-text',
|
137
|
+
label: '打开外部链接',
|
138
|
+
name: 'href',
|
139
|
+
visibleOn: 'this.type == "image"'
|
140
|
+
}
|
141
|
+
],
|
142
|
+
scaffold: {
|
143
|
+
type: 'input-image',
|
144
|
+
image: ''
|
145
|
+
}
|
146
|
+
},
|
147
|
+
|
148
|
+
{
|
149
|
+
label: 'HTML',
|
150
|
+
test: 'this.type === "html"',
|
151
|
+
items: [
|
152
|
+
getSchemaTpl('richText', {
|
153
|
+
label: '内容',
|
154
|
+
name: 'content'
|
155
|
+
})
|
156
|
+
],
|
157
|
+
scaffold: {
|
158
|
+
type: 'html',
|
159
|
+
content: '<p>html 片段</p>'
|
160
|
+
}
|
161
|
+
}
|
162
|
+
],
|
163
|
+
pipeIn: (value: any) => {
|
164
|
+
return Array.isArray(value) && value.length
|
165
|
+
? value.map(
|
166
|
+
(item: {
|
167
|
+
html?: string;
|
168
|
+
image?: string;
|
169
|
+
title?: string;
|
170
|
+
titleClassName?: string;
|
171
|
+
description?: string;
|
172
|
+
descriptionClassName?: string;
|
173
|
+
}) =>
|
174
|
+
item && item.hasOwnProperty('html')
|
175
|
+
? {
|
176
|
+
type: 'html',
|
177
|
+
content: item.html
|
178
|
+
}
|
179
|
+
: {
|
180
|
+
type: 'image',
|
181
|
+
content: item.image,
|
182
|
+
title: item.title,
|
183
|
+
titleClassName: item.titleClassName,
|
184
|
+
description: item.description,
|
185
|
+
descriptionClassName: item.descriptionClassName
|
186
|
+
}
|
187
|
+
)
|
188
|
+
: [];
|
189
|
+
},
|
190
|
+
pipeOut: (value: any, originValue: any, data: any) => {
|
191
|
+
return Array.isArray(value) && value.length
|
192
|
+
? value.map(
|
193
|
+
(item: {
|
194
|
+
type: string;
|
195
|
+
content: string;
|
196
|
+
title?: string;
|
197
|
+
titleClassName?: string;
|
198
|
+
description?: string;
|
199
|
+
descriptionClassName?: string;
|
200
|
+
}) => {
|
201
|
+
return item.type === 'html'
|
202
|
+
? {
|
203
|
+
html: item.content
|
204
|
+
}
|
205
|
+
: {
|
206
|
+
image: item.content,
|
207
|
+
title: item.title,
|
208
|
+
titleClassName: item.titleClassName,
|
209
|
+
description: item.description,
|
210
|
+
descriptionClassName: item.descriptionClassName
|
211
|
+
};
|
212
|
+
}
|
213
|
+
)
|
214
|
+
: [];
|
215
|
+
}
|
216
|
+
}
|
217
|
+
]
|
218
|
+
},
|
219
|
+
{
|
220
|
+
title: '外观',
|
221
|
+
body: [
|
222
|
+
{
|
223
|
+
name: 'auto',
|
224
|
+
type: 'switch',
|
225
|
+
mode: 'inline',
|
226
|
+
className: 'w-full',
|
227
|
+
label: '自动轮播',
|
228
|
+
pipeIn: defaultValue(true)
|
229
|
+
},
|
230
|
+
{
|
231
|
+
name: 'interval',
|
232
|
+
type: 'input-range',
|
233
|
+
label: '动画间隔',
|
234
|
+
min: 1,
|
235
|
+
max: 100,
|
236
|
+
step: 1,
|
237
|
+
unit: 's',
|
238
|
+
pipeIn: (value: any) => (value ?? 3000) / 1000,
|
239
|
+
pipeOut: (value: any, originValue: any, data: any) => value * 1000
|
240
|
+
},
|
241
|
+
{
|
242
|
+
name: 'duration',
|
243
|
+
type: 'input-range',
|
244
|
+
label: '动画时长',
|
245
|
+
min: 100,
|
246
|
+
max: 2000,
|
247
|
+
step: 10,
|
248
|
+
pipeIn: defaultValue(500),
|
249
|
+
unit: 'ms'
|
250
|
+
},
|
251
|
+
{
|
252
|
+
name: 'animation',
|
253
|
+
label: '动画效果',
|
254
|
+
type: 'button-group-select',
|
255
|
+
mode: 'inline',
|
256
|
+
className: 'w-full',
|
257
|
+
size: 'sm',
|
258
|
+
pipeIn: defaultValue('fade'),
|
259
|
+
options: [
|
260
|
+
{
|
261
|
+
label: 'fade',
|
262
|
+
value: 'fade'
|
263
|
+
},
|
264
|
+
{
|
265
|
+
label: 'slide',
|
266
|
+
value: 'slide'
|
267
|
+
}
|
268
|
+
]
|
269
|
+
},
|
270
|
+
{
|
271
|
+
name: 'controlsTheme',
|
272
|
+
label: '控制按钮主题',
|
273
|
+
type: 'button-group-select',
|
274
|
+
size: 'sm',
|
275
|
+
pipeIn: defaultValue('light'),
|
276
|
+
mode: 'inline',
|
277
|
+
className: 'w-full',
|
278
|
+
options: [
|
279
|
+
{
|
280
|
+
label: 'light',
|
281
|
+
value: 'light'
|
282
|
+
},
|
283
|
+
{
|
284
|
+
label: 'dark',
|
285
|
+
value: 'dark'
|
286
|
+
}
|
287
|
+
]
|
288
|
+
},
|
289
|
+
{
|
290
|
+
name: 'controls',
|
291
|
+
label: '控制显示',
|
292
|
+
type: 'button-group-select',
|
293
|
+
size: 'sm',
|
294
|
+
mode: 'inline',
|
295
|
+
className: 'w-full',
|
296
|
+
pipeIn: defaultValue('dots,arrows'),
|
297
|
+
multiple: true,
|
298
|
+
options: [
|
299
|
+
{
|
300
|
+
label: '底部圆点',
|
301
|
+
value: 'dots'
|
302
|
+
},
|
303
|
+
{
|
304
|
+
label: '左右箭头',
|
305
|
+
value: 'arrows'
|
306
|
+
}
|
307
|
+
]
|
308
|
+
},
|
309
|
+
{
|
310
|
+
name: 'width',
|
311
|
+
type: 'input-text',
|
312
|
+
label: '宽度',
|
313
|
+
validations: 'isNumeric',
|
314
|
+
addOn: {
|
315
|
+
type: 'button',
|
316
|
+
label: 'px'
|
317
|
+
}
|
318
|
+
},
|
319
|
+
{
|
320
|
+
name: 'height',
|
321
|
+
type: 'input-text',
|
322
|
+
label: '高度',
|
323
|
+
validations: 'isNumeric',
|
324
|
+
addOn: {
|
325
|
+
type: 'button',
|
326
|
+
label: 'px'
|
327
|
+
}
|
328
|
+
},
|
329
|
+
getSchemaTpl('className')
|
330
|
+
]
|
331
|
+
},
|
332
|
+
{
|
333
|
+
title: '显隐',
|
334
|
+
body: [getSchemaTpl('ref'), getSchemaTpl('visible')]
|
335
|
+
}
|
336
|
+
])
|
337
|
+
];
|
338
|
+
};
|
339
|
+
|
340
|
+
filterProps(props: any) {
|
341
|
+
// 编辑的时候别自动轮播,影响编辑
|
342
|
+
props.auto = false;
|
343
|
+
return props;
|
344
|
+
}
|
345
|
+
|
346
|
+
/**
|
347
|
+
* 补充切换的 toolbar
|
348
|
+
* @param context
|
349
|
+
* @param toolbars
|
350
|
+
*/
|
351
|
+
buildEditorToolbar(
|
352
|
+
context: BaseEventContext,
|
353
|
+
toolbars: Array<BasicToolbarItem>
|
354
|
+
) {
|
355
|
+
if (
|
356
|
+
context.info.plugin === this &&
|
357
|
+
context.info.renderer.name === 'carousel' &&
|
358
|
+
!context.info.hostId
|
359
|
+
) {
|
360
|
+
const node = context.node;
|
361
|
+
|
362
|
+
toolbars.push({
|
363
|
+
level: 'secondary',
|
364
|
+
icon: 'fa fa-chevron-left',
|
365
|
+
tooltip: '上个卡片',
|
366
|
+
onClick: () => {
|
367
|
+
const control = node.getComponent();
|
368
|
+
control?.prev?.();
|
369
|
+
}
|
370
|
+
});
|
371
|
+
|
372
|
+
toolbars.push({
|
373
|
+
level: 'secondary',
|
374
|
+
icon: 'fa fa-chevron-right',
|
375
|
+
tooltip: '下个卡片',
|
376
|
+
onClick: () => {
|
377
|
+
const control = node.getComponent();
|
378
|
+
|
379
|
+
control?.next?.();
|
380
|
+
}
|
381
|
+
});
|
382
|
+
}
|
383
|
+
}
|
384
|
+
}
|
385
|
+
|
386
|
+
registerEditorPlugin(CarouselPlugin);
|
@@ -0,0 +1,218 @@
|
|
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 {diff} from '../util';
|
12
|
+
import AMisCodeEditor from '../component/Panel/AMisCodeEditor';
|
13
|
+
|
14
|
+
const ChartConfigEditor = ({value, onChange}: any) => {
|
15
|
+
return (
|
16
|
+
<div className="ae-JsonEditor">
|
17
|
+
<AMisCodeEditor value={value} onChange={onChange} />
|
18
|
+
</div>
|
19
|
+
);
|
20
|
+
};
|
21
|
+
|
22
|
+
export class ChartPlugin extends BasePlugin {
|
23
|
+
// 关联渲染器名字
|
24
|
+
rendererName = 'chart';
|
25
|
+
$schema = '/schemas/ChartSchema.json';
|
26
|
+
|
27
|
+
// 组件名称
|
28
|
+
name = '图表';
|
29
|
+
isBaseComponent = true;
|
30
|
+
description =
|
31
|
+
'用来渲染图表,基于 echarts 图表库,理论上 echarts 所有图表类型都支持。';
|
32
|
+
docLink = '/amis/zh-CN/components/chart';
|
33
|
+
tags = ['展示'];
|
34
|
+
icon = 'fa fa-pie-chart';
|
35
|
+
scaffold = {
|
36
|
+
type: 'chart',
|
37
|
+
config: {
|
38
|
+
xAxis: {
|
39
|
+
type: 'category',
|
40
|
+
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
|
41
|
+
},
|
42
|
+
yAxis: {
|
43
|
+
type: 'value'
|
44
|
+
},
|
45
|
+
series: [
|
46
|
+
{
|
47
|
+
data: [820, 932, 901, 934, 1290, 1330, 1320],
|
48
|
+
type: 'line'
|
49
|
+
}
|
50
|
+
]
|
51
|
+
},
|
52
|
+
replaceChartOption: true
|
53
|
+
};
|
54
|
+
previewSchema = {
|
55
|
+
...this.scaffold
|
56
|
+
};
|
57
|
+
|
58
|
+
panelTitle = '图表';
|
59
|
+
panelBodyCreator = (context: BaseEventContext) => {
|
60
|
+
return [
|
61
|
+
getSchemaTpl('tabs', [
|
62
|
+
{
|
63
|
+
title: '常规',
|
64
|
+
body: [
|
65
|
+
getSchemaTpl('api', {
|
66
|
+
label: '接口拉取',
|
67
|
+
description:
|
68
|
+
'接口可以返回配置,或者数据,建议返回数据可映射到 Echarts 配置中'
|
69
|
+
}),
|
70
|
+
{
|
71
|
+
label: '初始是否拉取',
|
72
|
+
type: 'switch',
|
73
|
+
name: 'initFetch',
|
74
|
+
visibleOn: 'data.api',
|
75
|
+
pipeIn: defaultValue(true),
|
76
|
+
mode: 'inline',
|
77
|
+
className: 'block'
|
78
|
+
},
|
79
|
+
{
|
80
|
+
name: 'interval',
|
81
|
+
label: '定时刷新间隔',
|
82
|
+
type: 'input-number',
|
83
|
+
step: 500,
|
84
|
+
visibleOn: 'data.api',
|
85
|
+
description: '设置后将自动定时刷新,最小3000, 单位 ms'
|
86
|
+
},
|
87
|
+
{
|
88
|
+
name: 'config',
|
89
|
+
asFormItem: true,
|
90
|
+
component: ChartConfigEditor,
|
91
|
+
// type: 'json-editor',
|
92
|
+
label: 'Echarts 配置',
|
93
|
+
description: '支持数据映射,可将接口返回的数据填充进来'
|
94
|
+
// size: 'lg'
|
95
|
+
// pipeOut: (value: any) => {
|
96
|
+
// try {
|
97
|
+
// return value ? JSON.parse(value) : null;
|
98
|
+
// } catch (e) {}
|
99
|
+
// return null;
|
100
|
+
// }
|
101
|
+
},
|
102
|
+
{
|
103
|
+
name: 'clickAction',
|
104
|
+
asFormItem: true,
|
105
|
+
children: ({onChange, value}: any) => (
|
106
|
+
<div className="m-b">
|
107
|
+
<Button
|
108
|
+
size="sm"
|
109
|
+
level={value ? 'danger' : 'info'}
|
110
|
+
onClick={this.editDrillDown.bind(this, context.id)}
|
111
|
+
>
|
112
|
+
配置 DrillDown
|
113
|
+
</Button>
|
114
|
+
|
115
|
+
{value ? (
|
116
|
+
<Button
|
117
|
+
size="sm"
|
118
|
+
level="link"
|
119
|
+
className="m-l"
|
120
|
+
onClick={() => onChange('')}
|
121
|
+
>
|
122
|
+
删除 DrillDown
|
123
|
+
</Button>
|
124
|
+
) : null}
|
125
|
+
</div>
|
126
|
+
)
|
127
|
+
},
|
128
|
+
{
|
129
|
+
name: 'dataFilter',
|
130
|
+
type: 'js-editor',
|
131
|
+
allowFullscreen: true,
|
132
|
+
label: '数据加工',
|
133
|
+
size: 'lg',
|
134
|
+
description: `
|
135
|
+
如果后端没有直接返回 Echart 配置,可以自己写一段函数来包装。
|
136
|
+
<p>签名:(config, echarts, data) => config</p>
|
137
|
+
<p>参数说明</p>
|
138
|
+
<ul>
|
139
|
+
<li><code>config</code> 原始数据</li>
|
140
|
+
<li><code>echarts</code> echarts 对象</li>
|
141
|
+
<li><code>data</code> 如果配置了数据接口,接口返回的数据通过此变量传入</li>
|
142
|
+
</ul>
|
143
|
+
<p>示例</p>
|
144
|
+
<pre>debugger; // 可以浏览器中断点调试\n\n// 查看原始数据\nconsole.log(config)\n\n// 返回新的结果 \nreturn {}</pre>
|
145
|
+
`
|
146
|
+
},
|
147
|
+
{
|
148
|
+
label: 'Chart 配置完全替换?',
|
149
|
+
labelRemark: {
|
150
|
+
trigger: 'click',
|
151
|
+
className: 'm-l-xs',
|
152
|
+
rootClose: true,
|
153
|
+
content:
|
154
|
+
'默认为追加模式,新的配置会跟旧的配置合并,如果勾选将直接完全覆盖。',
|
155
|
+
placement: 'left'
|
156
|
+
},
|
157
|
+
name: 'replaceChartOption',
|
158
|
+
type: 'switch',
|
159
|
+
mode: 'inline',
|
160
|
+
className: 'block'
|
161
|
+
}
|
162
|
+
]
|
163
|
+
},
|
164
|
+
{
|
165
|
+
title: '外观',
|
166
|
+
body: [getSchemaTpl('className')]
|
167
|
+
},
|
168
|
+
{
|
169
|
+
title: '显隐',
|
170
|
+
body: [getSchemaTpl('visible')]
|
171
|
+
},
|
172
|
+
{
|
173
|
+
title: '其他',
|
174
|
+
body: [getSchemaTpl('name')]
|
175
|
+
}
|
176
|
+
])
|
177
|
+
];
|
178
|
+
};
|
179
|
+
|
180
|
+
editDrillDown(id: string) {
|
181
|
+
const manager = this.manager;
|
182
|
+
const store = manager.store;
|
183
|
+
const node = store.getNodeById(id);
|
184
|
+
const value = store.getValueOf(id);
|
185
|
+
|
186
|
+
const dialog = (value.clickAction && value.clickAction.dialog) || {
|
187
|
+
title: '标题',
|
188
|
+
body: ['<p>内容 <code>${value|json}</code></p>']
|
189
|
+
};
|
190
|
+
|
191
|
+
node &&
|
192
|
+
value &&
|
193
|
+
this.manager.openSubEditor({
|
194
|
+
title: '配置 DrillDown 详情',
|
195
|
+
value: {
|
196
|
+
type: 'container',
|
197
|
+
...dialog
|
198
|
+
},
|
199
|
+
slot: {
|
200
|
+
type: 'container',
|
201
|
+
body: '$$'
|
202
|
+
},
|
203
|
+
typeMutable: false,
|
204
|
+
onChange: newValue => {
|
205
|
+
newValue = {
|
206
|
+
...value,
|
207
|
+
clickAction: {
|
208
|
+
actionType: 'dialog',
|
209
|
+
dialog: newValue
|
210
|
+
}
|
211
|
+
};
|
212
|
+
manager.panelChangeValue(newValue, diff(value, newValue));
|
213
|
+
}
|
214
|
+
});
|
215
|
+
}
|
216
|
+
}
|
217
|
+
|
218
|
+
registerEditorPlugin(ChartPlugin);
|
@@ -0,0 +1,60 @@
|
|
1
|
+
/**
|
2
|
+
* @file 代码高亮显示
|
3
|
+
*/
|
4
|
+
import {registerEditorPlugin} from '../manager';
|
5
|
+
import {BaseEventContext, BasePlugin} from '../plugin';
|
6
|
+
import {getSchemaTpl} from '../component/schemaTpl';
|
7
|
+
|
8
|
+
export class CodeViewPlugin extends BasePlugin {
|
9
|
+
// 关联渲染器名字
|
10
|
+
rendererName = 'code';
|
11
|
+
$schema = '/schemas/CodeSchema.json';
|
12
|
+
|
13
|
+
// 组件名称
|
14
|
+
name = '代码高亮';
|
15
|
+
isBaseComponent = true;
|
16
|
+
icon = 'fa fa-code';
|
17
|
+
description = '代码高亮';
|
18
|
+
docLink = '/amis/zh-CN/components/code';
|
19
|
+
tags = ['展示'];
|
20
|
+
scaffold = {
|
21
|
+
type: 'code',
|
22
|
+
language: 'html',
|
23
|
+
value: '<div>html</div>'
|
24
|
+
};
|
25
|
+
previewSchema: any = {
|
26
|
+
...this.scaffold
|
27
|
+
};
|
28
|
+
|
29
|
+
panelTitle = '代码高亮';
|
30
|
+
panelBody = [
|
31
|
+
getSchemaTpl('tabs', [
|
32
|
+
{
|
33
|
+
title: '常规',
|
34
|
+
body: [
|
35
|
+
{
|
36
|
+
type: 'input-text',
|
37
|
+
label: '名称',
|
38
|
+
name: 'name'
|
39
|
+
},
|
40
|
+
{
|
41
|
+
type: 'editor',
|
42
|
+
label: '固定值',
|
43
|
+
allowFullscreen: true,
|
44
|
+
name: 'value'
|
45
|
+
}
|
46
|
+
]
|
47
|
+
},
|
48
|
+
{
|
49
|
+
title: '外观',
|
50
|
+
body: [getSchemaTpl('className')]
|
51
|
+
},
|
52
|
+
{
|
53
|
+
title: '显隐',
|
54
|
+
body: [getSchemaTpl('ref'), getSchemaTpl('visible')]
|
55
|
+
}
|
56
|
+
])
|
57
|
+
];
|
58
|
+
}
|
59
|
+
|
60
|
+
registerEditorPlugin(CodeViewPlugin);
|