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.
- package/dist/component/Breadcrumb.d.ts +23 -2
- package/dist/component/ClassNameControl.d.ts +1 -1
- package/dist/component/Control/APIControl.d.ts +2 -2
- package/dist/component/Control/OptionControl.d.ts +3 -3
- package/dist/component/Control/PopoverEdit.d.ts +4 -4
- package/dist/component/Control/ValidationControl.d.ts +1 -1
- package/dist/component/Editor.d.ts +20 -1
- package/dist/component/IFramePreview.d.ts +2 -1
- package/dist/component/NodeWrapper.d.ts +1 -1
- package/dist/component/Panel/RenderersPanel.d.ts +1 -2
- package/dist/component/Preview.d.ts +3 -1
- package/dist/component/RegionWrapper.d.ts +4 -0
- package/dist/component/VRenderer.d.ts +4 -0
- package/dist/component/base/InputComponentName.d.ts +1 -1
- 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/env.d.ts +1 -1
- 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 +16 -4
- package/dist/plugin/Alert.d.ts +1 -1
- package/dist/plugin/Button.d.ts +1 -1
- package/dist/plugin/Card.d.ts +1 -0
- package/dist/plugin/Cards.d.ts +2 -1
- 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 +40 -0
- package/dist/plugin/Dialog.d.ts +1 -1
- package/dist/plugin/Drawer.d.ts +1 -1
- package/dist/plugin/DropDownButton.d.ts +1 -1
- package/dist/plugin/Each.d.ts +1 -1
- 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/Formula.d.ts +3 -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/IFrame.d.ts +3 -3
- package/dist/plugin/Json.d.ts +1 -0
- package/dist/plugin/List.d.ts +2 -1
- 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/Page.d.ts +1 -1
- 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/Table.d.ts +1 -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 +8 -7
- package/dist/store/editor.d.ts +47 -11
- package/dist/store/node.d.ts +6 -0
- package/dist/style.css +1 -1
- package/dist/util.d.ts +1 -1
- package/package.json +10 -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 +154 -0
- package/src/plugin/Avatar.tsx +77 -0
- package/src/plugin/Breadcrumb.tsx +107 -0
- package/src/plugin/Button.tsx +281 -0
- package/src/plugin/ButtonGroup.tsx +85 -0
- package/src/plugin/ButtonToolbar.tsx +87 -0
- package/src/plugin/CRUD.tsx +1835 -0
- package/src/plugin/Card.tsx +290 -0
- package/src/plugin/Cards.tsx +318 -0
- package/src/plugin/Carousel.tsx +377 -0
- package/src/plugin/Chart.tsx +218 -0
- package/src/plugin/CodeView.tsx +60 -0
- package/src/plugin/Collapse.tsx +136 -0
- package/src/plugin/CollapseGroup.tsx +167 -0
- package/src/plugin/Container.tsx +40 -0
- package/src/plugin/Custom.tsx +128 -0
- package/src/plugin/CustomRegion.tsx +156 -0
- package/src/plugin/Date.tsx +74 -0
- package/src/plugin/Datetime.tsx +68 -0
- package/src/plugin/Dialog.tsx +176 -0
- package/src/plugin/Divider.tsx +36 -0
- package/src/plugin/Drawer.tsx +214 -0
- package/src/plugin/DropDownButton.tsx +235 -0
- package/src/plugin/Each.tsx +150 -0
- package/src/plugin/ErrorRenderer.tsx +15 -0
- package/src/plugin/Flex.tsx +151 -0
- package/src/plugin/Form/ButtonGroupSelect.tsx +75 -0
- package/src/plugin/Form/ButtonToolbar.tsx +110 -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 +81 -0
- package/src/plugin/Form/Combo.tsx +582 -0
- package/src/plugin/Form/ConditionBuilder.tsx +315 -0
- package/src/plugin/Form/Control.tsx +139 -0
- package/src/plugin/Form/DiffEditor.tsx +111 -0
- package/src/plugin/Form/FieldSet.tsx +163 -0
- package/src/plugin/Form/Form.tsx +687 -0
- package/src/plugin/Form/Formula.tsx +79 -0
- package/src/plugin/Form/Group.tsx +295 -0
- package/src/plugin/Form/Hidden.tsx +44 -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 +221 -0
- package/src/plugin/Form/InputGroup.tsx +96 -0
- package/src/plugin/Form/InputImage.tsx +266 -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 +89 -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 +57 -0
- package/src/plugin/Form/InputRichText.tsx +186 -0
- package/src/plugin/Form/InputSubForm.tsx +189 -0
- package/src/plugin/Form/InputTable.tsx +434 -0
- package/src/plugin/Form/InputTag.tsx +70 -0
- package/src/plugin/Form/InputText.tsx +186 -0
- package/src/plugin/Form/InputTime.tsx +85 -0
- package/src/plugin/Form/InputTree.tsx +229 -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 +73 -0
- package/src/plugin/Form/LocationPicker.tsx +62 -0
- package/src/plugin/Form/MatrixCheckboxes.tsx +136 -0
- package/src/plugin/Form/NestedSelect.tsx +211 -0
- package/src/plugin/Form/Picker.tsx +209 -0
- package/src/plugin/Form/Radios.tsx +119 -0
- package/src/plugin/Form/Select.tsx +233 -0
- package/src/plugin/Form/Static.tsx +322 -0
- package/src/plugin/Form/Switch.tsx +107 -0
- package/src/plugin/Form/TabsTransfer.tsx +259 -0
- package/src/plugin/Form/Textarea.tsx +83 -0
- package/src/plugin/Form/Transfer.tsx +368 -0
- package/src/plugin/Form/TreeSelect.tsx +263 -0
- package/src/plugin/Form/UUID.tsx +48 -0
- package/src/plugin/Grid.tsx +798 -0
- package/src/plugin/HBox.tsx +727 -0
- package/src/plugin/IFrame.tsx +70 -0
- package/src/plugin/Image.tsx +314 -0
- package/src/plugin/Images.tsx +231 -0
- package/src/plugin/Json.tsx +69 -0
- package/src/plugin/Link.tsx +93 -0
- package/src/plugin/List.tsx +278 -0
- package/src/plugin/ListItem.tsx +229 -0
- package/src/plugin/Log.tsx +52 -0
- package/src/plugin/Mapping.tsx +149 -0
- package/src/plugin/Markdown.tsx +47 -0
- package/src/plugin/Nav.tsx +184 -0
- package/src/plugin/Operation.tsx +95 -0
- package/src/plugin/Others/Action.tsx +426 -0
- package/src/plugin/Others/BasicToolbar.tsx +585 -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 +306 -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 +84 -0
- package/src/plugin/Progress.tsx +125 -0
- package/src/plugin/Property.tsx +139 -0
- package/src/plugin/QRCode.tsx +96 -0
- package/src/plugin/Reset.tsx +23 -0
- package/src/plugin/Service.tsx +162 -0
- package/src/plugin/Sparkline.tsx +40 -0
- package/src/plugin/Status.tsx +76 -0
- package/src/plugin/Steps.tsx +128 -0
- package/src/plugin/Submit.tsx +23 -0
- package/src/plugin/Table.tsx +428 -0
- package/src/plugin/TableView.tsx +709 -0
- package/src/plugin/Tabs.tsx +362 -0
- package/src/plugin/Tasks.tsx +274 -0
- package/src/plugin/Time.tsx +68 -0
- package/src/plugin/TooltipWrapper.tsx +193 -0
- package/src/plugin/Tpl.tsx +158 -0
- package/src/plugin/Video.tsx +158 -0
- package/src/plugin/WebComponent.tsx +53 -0
- package/src/plugin/Wizard.tsx +740 -0
- package/src/plugin/Wrapper.tsx +107 -0
- package/src/plugin.ts +1050 -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,377 @@
|
|
1
|
+
import {registerEditorPlugin} from '../manager';
|
2
|
+
import {BaseEventContext, BasePlugin, BasicToolbarItem} from '../plugin';
|
3
|
+
import {defaultValue, getSchemaTpl} from '../component/schemaTpl';
|
4
|
+
import {mockValue} from '../mocker';
|
5
|
+
|
6
|
+
export class CarouselPlugin extends BasePlugin {
|
7
|
+
// 关联渲染器名字
|
8
|
+
rendererName = 'carousel';
|
9
|
+
$schema = '/schemas/CarouselSchema.json';
|
10
|
+
|
11
|
+
// 组件名称
|
12
|
+
name = '轮播图';
|
13
|
+
isBaseComponent = true;
|
14
|
+
description =
|
15
|
+
'用来渲染轮播图,可以配置每一页的内容(不只是图片),可以配置过渡动画。';
|
16
|
+
docLink = '/amis/zh-CN/components/carousel';
|
17
|
+
tags = ['展示'];
|
18
|
+
icon = 'fa fa-images';
|
19
|
+
scaffold = {
|
20
|
+
type: 'carousel',
|
21
|
+
options: [
|
22
|
+
{
|
23
|
+
image: mockValue({type: 'image'})
|
24
|
+
},
|
25
|
+
{
|
26
|
+
html:
|
27
|
+
'<div style="width: 100%; height: 300px; background: #e3e3e3; text-align: center; line-height: 300px;">carousel data</div>'
|
28
|
+
},
|
29
|
+
{
|
30
|
+
image: mockValue({type: 'image'})
|
31
|
+
}
|
32
|
+
]
|
33
|
+
};
|
34
|
+
previewSchema = {
|
35
|
+
...this.scaffold
|
36
|
+
};
|
37
|
+
|
38
|
+
panelTitle = '轮播图';
|
39
|
+
panelBodyCreator = (context: BaseEventContext) => {
|
40
|
+
const isUnderField = /\/field\/\w+$/.test(context.path as string);
|
41
|
+
return [
|
42
|
+
getSchemaTpl('tabs', [
|
43
|
+
{
|
44
|
+
title: '常规',
|
45
|
+
body: [
|
46
|
+
isUnderField
|
47
|
+
? {
|
48
|
+
type: 'tpl',
|
49
|
+
inline: false,
|
50
|
+
className: 'text-info text-sm',
|
51
|
+
tpl: '<p>当前为字段内容节点配置,选择上层还有更多的配置。</p>'
|
52
|
+
}
|
53
|
+
: null,
|
54
|
+
{
|
55
|
+
type: 'formula',
|
56
|
+
name: '__mode',
|
57
|
+
autoSet: false,
|
58
|
+
formula:
|
59
|
+
'!this.name && !this.source && Array.isArray(this.options) ? 2 : 1'
|
60
|
+
},
|
61
|
+
{
|
62
|
+
label: '数据源',
|
63
|
+
name: '__mode',
|
64
|
+
type: 'button-group-select',
|
65
|
+
size: 'xs',
|
66
|
+
mode: 'inline',
|
67
|
+
className: 'w-full',
|
68
|
+
options: [
|
69
|
+
{
|
70
|
+
label: '关联字段',
|
71
|
+
value: 1
|
72
|
+
},
|
73
|
+
{
|
74
|
+
label: '静态设置',
|
75
|
+
value: 2
|
76
|
+
}
|
77
|
+
]
|
78
|
+
},
|
79
|
+
{
|
80
|
+
label: '字段名',
|
81
|
+
name: 'name',
|
82
|
+
type: 'input-text',
|
83
|
+
description: '设置字段名,关联当前数据作用域中的数据。',
|
84
|
+
visibleOn: 'this.__mode == 1'
|
85
|
+
},
|
86
|
+
{
|
87
|
+
type: 'combo',
|
88
|
+
name: 'options',
|
89
|
+
visibleOn: 'this.__mode == 2',
|
90
|
+
label: '轮播选项内容',
|
91
|
+
multiple: true,
|
92
|
+
multiLine: true,
|
93
|
+
addable: true,
|
94
|
+
removable: true,
|
95
|
+
typeSwitchable: false,
|
96
|
+
conditions: [
|
97
|
+
{
|
98
|
+
label: '图片',
|
99
|
+
test: 'this.type === "image"',
|
100
|
+
items: [
|
101
|
+
getSchemaTpl('imageUrl', {
|
102
|
+
name: 'content'
|
103
|
+
}),
|
104
|
+
{
|
105
|
+
type: 'input-text',
|
106
|
+
label: '图片标题',
|
107
|
+
name: 'title',
|
108
|
+
visibleOn: 'this.type == "image"'
|
109
|
+
},
|
110
|
+
getSchemaTpl('className', {
|
111
|
+
label: '图片标题类名',
|
112
|
+
name: 'titleClassName',
|
113
|
+
visibleOn: 'this.type == "image"'
|
114
|
+
}),
|
115
|
+
{
|
116
|
+
type: 'textarea',
|
117
|
+
label: '图片描述',
|
118
|
+
name: 'description',
|
119
|
+
visibleOn: 'this.type == "image"'
|
120
|
+
},
|
121
|
+
getSchemaTpl('className', {
|
122
|
+
label: '图片描述类名',
|
123
|
+
name: 'descriptionClassName',
|
124
|
+
visibleOn: 'this.type == "image"'
|
125
|
+
}),
|
126
|
+
{
|
127
|
+
type: 'input-text',
|
128
|
+
label: '打开外部链接',
|
129
|
+
name: 'href',
|
130
|
+
visibleOn: 'this.type == "image"'
|
131
|
+
}
|
132
|
+
],
|
133
|
+
scaffold: {
|
134
|
+
type: 'input-image',
|
135
|
+
image: ''
|
136
|
+
}
|
137
|
+
},
|
138
|
+
|
139
|
+
{
|
140
|
+
label: 'HTML',
|
141
|
+
test: 'this.type === "html"',
|
142
|
+
items: [
|
143
|
+
getSchemaTpl('richText', {
|
144
|
+
label: '内容',
|
145
|
+
name: 'content'
|
146
|
+
})
|
147
|
+
],
|
148
|
+
scaffold: {
|
149
|
+
type: 'html',
|
150
|
+
content: '<p>html 片段</p>'
|
151
|
+
}
|
152
|
+
}
|
153
|
+
],
|
154
|
+
pipeIn: (value: any) => {
|
155
|
+
return Array.isArray(value) && value.length
|
156
|
+
? value.map(
|
157
|
+
(item: {
|
158
|
+
html?: string;
|
159
|
+
image?: string;
|
160
|
+
title?: string;
|
161
|
+
titleClassName?: string;
|
162
|
+
description?: string;
|
163
|
+
descriptionClassName?: string;
|
164
|
+
}) =>
|
165
|
+
item && item.hasOwnProperty('html')
|
166
|
+
? {
|
167
|
+
type: 'html',
|
168
|
+
content: item.html
|
169
|
+
}
|
170
|
+
: {
|
171
|
+
type: 'image',
|
172
|
+
content: item.image,
|
173
|
+
title: item.title,
|
174
|
+
titleClassName: item.titleClassName,
|
175
|
+
description: item.description,
|
176
|
+
descriptionClassName: item.descriptionClassName
|
177
|
+
}
|
178
|
+
)
|
179
|
+
: [];
|
180
|
+
},
|
181
|
+
pipeOut: (value: any, originValue: any, data: any) => {
|
182
|
+
return Array.isArray(value) && value.length
|
183
|
+
? value.map(
|
184
|
+
(item: {
|
185
|
+
type: string;
|
186
|
+
content: string;
|
187
|
+
title?: string;
|
188
|
+
titleClassName?: string;
|
189
|
+
description?: string;
|
190
|
+
descriptionClassName?: string;
|
191
|
+
}) => {
|
192
|
+
return item.type === 'html'
|
193
|
+
? {
|
194
|
+
html: item.content
|
195
|
+
}
|
196
|
+
: {
|
197
|
+
image: item.content,
|
198
|
+
title: item.title,
|
199
|
+
titleClassName: item.titleClassName,
|
200
|
+
description: item.description,
|
201
|
+
descriptionClassName: item.descriptionClassName
|
202
|
+
};
|
203
|
+
}
|
204
|
+
)
|
205
|
+
: [];
|
206
|
+
}
|
207
|
+
}
|
208
|
+
]
|
209
|
+
},
|
210
|
+
{
|
211
|
+
title: '外观',
|
212
|
+
body: [
|
213
|
+
{
|
214
|
+
name: 'auto',
|
215
|
+
type: 'switch',
|
216
|
+
mode: 'inline',
|
217
|
+
className: 'w-full',
|
218
|
+
label: '自动轮播',
|
219
|
+
pipeIn: defaultValue(true)
|
220
|
+
},
|
221
|
+
{
|
222
|
+
name: 'interval',
|
223
|
+
type: 'input-range',
|
224
|
+
label: '动画间隔',
|
225
|
+
min: 1,
|
226
|
+
max: 100,
|
227
|
+
step: 1,
|
228
|
+
unit: 's',
|
229
|
+
pipeIn: (value: any) => (value ?? 3000) / 1000,
|
230
|
+
pipeOut: (value: any, originValue: any, data: any) => value * 1000
|
231
|
+
},
|
232
|
+
{
|
233
|
+
name: 'duration',
|
234
|
+
type: 'input-range',
|
235
|
+
label: '动画时长',
|
236
|
+
min: 100,
|
237
|
+
max: 2000,
|
238
|
+
step: 10,
|
239
|
+
pipeIn: defaultValue(500),
|
240
|
+
unit: 'ms'
|
241
|
+
},
|
242
|
+
{
|
243
|
+
name: 'animation',
|
244
|
+
label: '动画效果',
|
245
|
+
type: 'button-group-select',
|
246
|
+
mode: 'inline',
|
247
|
+
className: 'w-full',
|
248
|
+
size: 'sm',
|
249
|
+
pipeIn: defaultValue('fade'),
|
250
|
+
options: [
|
251
|
+
{
|
252
|
+
label: 'fade',
|
253
|
+
value: 'fade'
|
254
|
+
},
|
255
|
+
{
|
256
|
+
label: 'slide',
|
257
|
+
value: 'slide'
|
258
|
+
}
|
259
|
+
]
|
260
|
+
},
|
261
|
+
{
|
262
|
+
name: 'controlsTheme',
|
263
|
+
label: '控制按钮主题',
|
264
|
+
type: 'button-group-select',
|
265
|
+
size: 'sm',
|
266
|
+
pipeIn: defaultValue('light'),
|
267
|
+
mode: 'inline',
|
268
|
+
className: 'w-full',
|
269
|
+
options: [
|
270
|
+
{
|
271
|
+
label: 'light',
|
272
|
+
value: 'light'
|
273
|
+
},
|
274
|
+
{
|
275
|
+
label: 'dark',
|
276
|
+
value: 'dark'
|
277
|
+
}
|
278
|
+
]
|
279
|
+
},
|
280
|
+
{
|
281
|
+
name: 'controls',
|
282
|
+
label: '控制显示',
|
283
|
+
type: 'button-group-select',
|
284
|
+
size: 'sm',
|
285
|
+
mode: 'inline',
|
286
|
+
className: 'w-full',
|
287
|
+
pipeIn: defaultValue('dots,arrows'),
|
288
|
+
multiple: true,
|
289
|
+
options: [
|
290
|
+
{
|
291
|
+
label: '底部圆点',
|
292
|
+
value: 'dots'
|
293
|
+
},
|
294
|
+
{
|
295
|
+
label: '左右箭头',
|
296
|
+
value: 'arrows'
|
297
|
+
}
|
298
|
+
]
|
299
|
+
},
|
300
|
+
{
|
301
|
+
name: 'width',
|
302
|
+
type: 'input-text',
|
303
|
+
label: '宽度',
|
304
|
+
validations: 'isNumeric',
|
305
|
+
addOn: {
|
306
|
+
type: 'button',
|
307
|
+
label: 'px'
|
308
|
+
}
|
309
|
+
},
|
310
|
+
{
|
311
|
+
name: 'height',
|
312
|
+
type: 'input-text',
|
313
|
+
label: '高度',
|
314
|
+
validations: 'isNumeric',
|
315
|
+
addOn: {
|
316
|
+
type: 'button',
|
317
|
+
label: 'px'
|
318
|
+
}
|
319
|
+
},
|
320
|
+
getSchemaTpl('className')
|
321
|
+
]
|
322
|
+
},
|
323
|
+
{
|
324
|
+
title: '显隐',
|
325
|
+
body: [getSchemaTpl('ref'), getSchemaTpl('visible')]
|
326
|
+
}
|
327
|
+
])
|
328
|
+
];
|
329
|
+
};
|
330
|
+
|
331
|
+
filterProps(props: any) {
|
332
|
+
// 编辑的时候别自动轮播,影响编辑
|
333
|
+
props.auto = false;
|
334
|
+
return props;
|
335
|
+
}
|
336
|
+
|
337
|
+
/**
|
338
|
+
* 补充切换的 toolbar
|
339
|
+
* @param context
|
340
|
+
* @param toolbars
|
341
|
+
*/
|
342
|
+
buildEditorToolbar(
|
343
|
+
context: BaseEventContext,
|
344
|
+
toolbars: Array<BasicToolbarItem>
|
345
|
+
) {
|
346
|
+
if (
|
347
|
+
context.info.plugin === this &&
|
348
|
+
context.info.renderer.name === 'carousel' &&
|
349
|
+
!context.info.hostId
|
350
|
+
) {
|
351
|
+
const node = context.node;
|
352
|
+
|
353
|
+
toolbars.push({
|
354
|
+
level: 'secondary',
|
355
|
+
icon: 'fa fa-chevron-left',
|
356
|
+
tooltip: '上个卡片',
|
357
|
+
onClick: () => {
|
358
|
+
const control = node.getComponent();
|
359
|
+
control?.prev?.();
|
360
|
+
}
|
361
|
+
});
|
362
|
+
|
363
|
+
toolbars.push({
|
364
|
+
level: 'secondary',
|
365
|
+
icon: 'fa fa-chevron-right',
|
366
|
+
tooltip: '下个卡片',
|
367
|
+
onClick: () => {
|
368
|
+
const control = node.getComponent();
|
369
|
+
|
370
|
+
control?.next?.();
|
371
|
+
}
|
372
|
+
});
|
373
|
+
}
|
374
|
+
}
|
375
|
+
}
|
376
|
+
|
377
|
+
registerEditorPlugin(CarouselPlugin);
|
@@ -0,0 +1,218 @@
|
|
1
|
+
import {Button} 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);
|