amis-editor 4.1.0-beta.4 → 4.2.0-beta.3
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/ScaffoldModal.d.ts +1 -1
- 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/component/base/ShortcutKey.d.ts +23 -0
- package/dist/env.d.ts +1 -1
- package/dist/exports.min.js +1 -1
- package/dist/index.d.ts +5 -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 +58 -22
- package/dist/store/node.d.ts +6 -0
- package/dist/style.css +1 -1
- package/dist/util.d.ts +1 -1
- package/package.json +9 -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,119 @@
|
|
1
|
+
import {defaultValue, getSchemaTpl} from '../../component/schemaTpl';
|
2
|
+
import {registerEditorPlugin} from '../../manager';
|
3
|
+
import {BasePlugin} from '../../plugin';
|
4
|
+
import flatten = require('lodash/flatten');
|
5
|
+
|
6
|
+
export class RadiosControlPlugin extends BasePlugin {
|
7
|
+
// 关联渲染器名字
|
8
|
+
rendererName = 'radios';
|
9
|
+
$schema = '/schemas/RadiosControlSchema.json';
|
10
|
+
|
11
|
+
order = -460;
|
12
|
+
|
13
|
+
// 组件名称
|
14
|
+
name = '单选框';
|
15
|
+
isBaseComponent = true;
|
16
|
+
icon = 'fa fa-dot-circle-o';
|
17
|
+
description = `通过<code>options</code>配置选项,可通过<code>source</code>拉取选项`;
|
18
|
+
docLink = '/amis/zh-CN/components/form/radios';
|
19
|
+
tags = ['表单项'];
|
20
|
+
scaffold = {
|
21
|
+
type: 'radios',
|
22
|
+
label: '单选框',
|
23
|
+
name: 'radios',
|
24
|
+
options: [
|
25
|
+
{
|
26
|
+
label: '选项A',
|
27
|
+
value: 'A'
|
28
|
+
},
|
29
|
+
|
30
|
+
{
|
31
|
+
label: '选项B',
|
32
|
+
value: 'B'
|
33
|
+
}
|
34
|
+
]
|
35
|
+
};
|
36
|
+
previewSchema: any = {
|
37
|
+
type: 'form',
|
38
|
+
className: 'text-left',
|
39
|
+
mode: 'horizontal',
|
40
|
+
wrapWithPanel: false,
|
41
|
+
body: [
|
42
|
+
{
|
43
|
+
...this.scaffold,
|
44
|
+
value: 'A'
|
45
|
+
}
|
46
|
+
]
|
47
|
+
};
|
48
|
+
|
49
|
+
panelTitle = '单选框';
|
50
|
+
panelBody = [
|
51
|
+
getSchemaTpl('tabs', [
|
52
|
+
{
|
53
|
+
title: '常规',
|
54
|
+
body: [
|
55
|
+
getSchemaTpl('switchDefaultValue'),
|
56
|
+
{
|
57
|
+
type: 'radios',
|
58
|
+
name: 'value',
|
59
|
+
label: '默认值',
|
60
|
+
source: '${options}',
|
61
|
+
visibleOn: 'typeof this.value !== "undefined"',
|
62
|
+
multiple: true
|
63
|
+
},
|
64
|
+
{
|
65
|
+
label: '是否默认选择第一个',
|
66
|
+
name: 'selectFirst',
|
67
|
+
type: 'switch',
|
68
|
+
mode: 'inline',
|
69
|
+
className: 'w-full'
|
70
|
+
},
|
71
|
+
getSchemaTpl('fieldSet', {
|
72
|
+
title: '选项',
|
73
|
+
body: [
|
74
|
+
getSchemaTpl('options'),
|
75
|
+
getSchemaTpl('source'),
|
76
|
+
|
77
|
+
getSchemaTpl('joinValues', {
|
78
|
+
visibleOn: true
|
79
|
+
}),
|
80
|
+
|
81
|
+
getSchemaTpl('extractValue'),
|
82
|
+
getSchemaTpl('autoFill')
|
83
|
+
]
|
84
|
+
})
|
85
|
+
]
|
86
|
+
},
|
87
|
+
{
|
88
|
+
title: '外观',
|
89
|
+
body: [
|
90
|
+
{
|
91
|
+
label: '选项在一行显示',
|
92
|
+
name: 'inline',
|
93
|
+
type: 'switch',
|
94
|
+
visibleOn: 'data.mode != "inline"',
|
95
|
+
mode: 'inline',
|
96
|
+
className: 'w-full',
|
97
|
+
pipeIn: defaultValue(true)
|
98
|
+
},
|
99
|
+
{
|
100
|
+
label: '每行显示多少列',
|
101
|
+
name: 'columnsCount',
|
102
|
+
hiddenOn:
|
103
|
+
'typeof data.inline === "undefined" || data.inline === true',
|
104
|
+
type: 'input-range',
|
105
|
+
min: 1,
|
106
|
+
max: 6,
|
107
|
+
pipeIn: defaultValue(1)
|
108
|
+
},
|
109
|
+
getSchemaTpl('className', {
|
110
|
+
label: '单个 Radio 的 CSS 类名',
|
111
|
+
name: 'itemClassName'
|
112
|
+
})
|
113
|
+
]
|
114
|
+
}
|
115
|
+
])
|
116
|
+
];
|
117
|
+
}
|
118
|
+
|
119
|
+
registerEditorPlugin(RadiosControlPlugin);
|
@@ -0,0 +1,233 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import {Button} from 'amis';
|
3
|
+
import {defaultValue, getSchemaTpl} from '../../component/schemaTpl';
|
4
|
+
import {registerEditorPlugin} from '../../manager';
|
5
|
+
import {
|
6
|
+
BasePlugin,
|
7
|
+
BasicSubRenderInfo,
|
8
|
+
RendererEventContext,
|
9
|
+
SubRendererInfo
|
10
|
+
} from '../../plugin';
|
11
|
+
import isArray from 'lodash/isArray';
|
12
|
+
|
13
|
+
export class SelectControlPlugin extends BasePlugin {
|
14
|
+
// 关联渲染器名字
|
15
|
+
rendererName = 'select';
|
16
|
+
$schema = '/schemas/SelectControlSchema.json';
|
17
|
+
|
18
|
+
order = -480;
|
19
|
+
|
20
|
+
// 组件名称
|
21
|
+
name = '下拉框';
|
22
|
+
isBaseComponent = true;
|
23
|
+
icon = 'fa fa-th-list';
|
24
|
+
description = `支持多选,输入提示,可使用<code>source</code>获取选项`;
|
25
|
+
docLink = '/amis/zh-CN/components/form/select';
|
26
|
+
tags = ['表单项'];
|
27
|
+
scaffold = {
|
28
|
+
type: 'select',
|
29
|
+
label: '选项',
|
30
|
+
name: 'select',
|
31
|
+
options: [
|
32
|
+
{
|
33
|
+
label: '选项A',
|
34
|
+
value: 'A'
|
35
|
+
},
|
36
|
+
|
37
|
+
{
|
38
|
+
label: '选项B',
|
39
|
+
value: 'B'
|
40
|
+
}
|
41
|
+
]
|
42
|
+
};
|
43
|
+
previewSchema: any = {
|
44
|
+
type: 'form',
|
45
|
+
className: 'text-left',
|
46
|
+
mode: 'horizontal',
|
47
|
+
wrapWithPanel: false,
|
48
|
+
body: [
|
49
|
+
{
|
50
|
+
...this.scaffold
|
51
|
+
}
|
52
|
+
]
|
53
|
+
};
|
54
|
+
|
55
|
+
panelTitle = '下拉框';
|
56
|
+
panelBody = [
|
57
|
+
getSchemaTpl('switchDefaultValue'),
|
58
|
+
|
59
|
+
{
|
60
|
+
type: 'select',
|
61
|
+
name: 'value',
|
62
|
+
label: '默认值',
|
63
|
+
source: '${options}',
|
64
|
+
visibleOn: '!data.multiple && typeof this.value !== "undefined"'
|
65
|
+
},
|
66
|
+
|
67
|
+
{
|
68
|
+
type: 'select',
|
69
|
+
name: 'value',
|
70
|
+
label: '默认值',
|
71
|
+
source: '${options}',
|
72
|
+
multiple: true,
|
73
|
+
visibleOn: ' data.multiple && typeof this.value !== "undefined"'
|
74
|
+
},
|
75
|
+
|
76
|
+
getSchemaTpl('clearable'),
|
77
|
+
{
|
78
|
+
label: '可检索',
|
79
|
+
name: 'searchable',
|
80
|
+
type: 'switch',
|
81
|
+
mode: 'inline',
|
82
|
+
className: 'w-full'
|
83
|
+
},
|
84
|
+
|
85
|
+
{
|
86
|
+
label: '是否默认选择第一个',
|
87
|
+
name: 'selectFirst',
|
88
|
+
type: 'switch',
|
89
|
+
mode: 'inline',
|
90
|
+
className: 'w-full'
|
91
|
+
},
|
92
|
+
|
93
|
+
getSchemaTpl('fieldSet', {
|
94
|
+
title: '选项',
|
95
|
+
body: [
|
96
|
+
getSchemaTpl('multiple'),
|
97
|
+
{
|
98
|
+
label: '选中内容以单行模式显示',
|
99
|
+
name: 'valuesNoWrap',
|
100
|
+
type: 'switch',
|
101
|
+
mode: 'inline',
|
102
|
+
className: 'w-full',
|
103
|
+
visibleOn: 'this.multiple'
|
104
|
+
},
|
105
|
+
{
|
106
|
+
label: '可全选',
|
107
|
+
name: 'checkAll',
|
108
|
+
type: 'switch',
|
109
|
+
mode: 'inline',
|
110
|
+
value: false,
|
111
|
+
className: 'w-full',
|
112
|
+
onChange: (value: any, origin: any, item: any, form: any) => {
|
113
|
+
// 开启 “可全选” 时,需关联开启多选模式
|
114
|
+
value && form.setValueByName('multiple', true);
|
115
|
+
}
|
116
|
+
},
|
117
|
+
{
|
118
|
+
label: '自定义菜单模板',
|
119
|
+
name: 'menuTpl',
|
120
|
+
type: 'input-text'
|
121
|
+
},
|
122
|
+
{
|
123
|
+
label: '默认全选',
|
124
|
+
name: 'defaultCheckAll',
|
125
|
+
type: 'switch',
|
126
|
+
value: false,
|
127
|
+
visibleOn: 'this.checkAll',
|
128
|
+
mode: 'inline',
|
129
|
+
className: 'w-full'
|
130
|
+
},
|
131
|
+
{
|
132
|
+
type: 'input-text',
|
133
|
+
name: 'checkAllLabel',
|
134
|
+
label: '默认为 "全选" 的文字',
|
135
|
+
visibleOn: 'this.checkAll',
|
136
|
+
value: '全选'
|
137
|
+
},
|
138
|
+
getSchemaTpl('options'),
|
139
|
+
getSchemaTpl('source'),
|
140
|
+
getSchemaTpl('api', {
|
141
|
+
name: 'autoComplete',
|
142
|
+
label: '自动完成接口',
|
143
|
+
description:
|
144
|
+
'每次输入新内容后,将调用接口,根据接口返回更新选项。当前用户输入值在 <code>\\${term}</code> 中。'
|
145
|
+
}),
|
146
|
+
getSchemaTpl('joinValues'),
|
147
|
+
getSchemaTpl('delimiter'),
|
148
|
+
getSchemaTpl('extractValue'),
|
149
|
+
getSchemaTpl('autoFill'),
|
150
|
+
|
151
|
+
getSchemaTpl('creatable'),
|
152
|
+
getSchemaTpl('createBtnLabel', {
|
153
|
+
visibleOn: 'data.creatable'
|
154
|
+
}),
|
155
|
+
getSchemaTpl('api', {
|
156
|
+
label: '新增选项接口',
|
157
|
+
name: 'addApi',
|
158
|
+
visibleOn: 'data.creatable'
|
159
|
+
}),
|
160
|
+
{
|
161
|
+
name: 'addControls',
|
162
|
+
visibleOn: 'data.creatable',
|
163
|
+
pipeIn: defaultValue([
|
164
|
+
{
|
165
|
+
type: 'input-text',
|
166
|
+
name: 'label',
|
167
|
+
label: false,
|
168
|
+
placeholder: '请输入名称'
|
169
|
+
}
|
170
|
+
]),
|
171
|
+
asFormItem: true,
|
172
|
+
children: (params: any) => ( // params: {value, onChange, data}
|
173
|
+
<Button
|
174
|
+
size="sm"
|
175
|
+
level="danger"
|
176
|
+
className="m-b"
|
177
|
+
onClick={() => {
|
178
|
+
let defaultValue = {
|
179
|
+
type: 'dialog',
|
180
|
+
body: [
|
181
|
+
{
|
182
|
+
type: 'input-text',
|
183
|
+
name: 'label',
|
184
|
+
label: false,
|
185
|
+
placeholder: '请输入名称'
|
186
|
+
}
|
187
|
+
]
|
188
|
+
};
|
189
|
+
if (params.value && params.value.body && isArray(params.value.body)) {
|
190
|
+
defaultValue.body = params.value.body;
|
191
|
+
} else if (params.value && isArray(params.value)) {
|
192
|
+
defaultValue.body = params.value;
|
193
|
+
}
|
194
|
+
this.manager.openSubEditor({
|
195
|
+
title: '配置新建选项表单项',
|
196
|
+
value: defaultValue,
|
197
|
+
onChange: (curValue: any) => {
|
198
|
+
if (curValue && curValue.body && isArray(curValue.body)) {
|
199
|
+
/**
|
200
|
+
* 备注: 需要确保 addControls 为数组类型 才会生效。
|
201
|
+
* 详细使用说明:https://aisuda.bce.baidu.com/amis/zh-CN/components/form/options#%E8%87%AA%E5%AE%9A%E4%B9%89%E6%96%B0%E5%A2%9E%E8%A1%A8%E5%8D%95%E9%A1%B9-addcontrols
|
202
|
+
*/
|
203
|
+
return params.onChange(curValue.body, 'addControls');
|
204
|
+
} else {
|
205
|
+
return params.onChange([], 'addControls');
|
206
|
+
}
|
207
|
+
}
|
208
|
+
});
|
209
|
+
}}
|
210
|
+
block
|
211
|
+
>
|
212
|
+
配置新建选项表单项
|
213
|
+
</Button>
|
214
|
+
)
|
215
|
+
},
|
216
|
+
|
217
|
+
getSchemaTpl('editable'),
|
218
|
+
getSchemaTpl('api', {
|
219
|
+
label: '编辑选项接口',
|
220
|
+
name: 'editApi'
|
221
|
+
}),
|
222
|
+
|
223
|
+
getSchemaTpl('removable'),
|
224
|
+
getSchemaTpl('api', {
|
225
|
+
label: '删除选项接口',
|
226
|
+
name: 'deleteApi'
|
227
|
+
})
|
228
|
+
]
|
229
|
+
})
|
230
|
+
];
|
231
|
+
}
|
232
|
+
|
233
|
+
registerEditorPlugin(SelectControlPlugin);
|
@@ -0,0 +1,322 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import {Button} from 'amis';
|
3
|
+
import {defaultValue, getSchemaTpl} from '../../component/schemaTpl';
|
4
|
+
import {registerEditorPlugin} from '../../manager';
|
5
|
+
import {BaseEventContext, BasePlugin} from '../../plugin';
|
6
|
+
import {EditorNodeType} from '../../store/node';
|
7
|
+
import {mockValue} from '../../mocker';
|
8
|
+
|
9
|
+
export class StaticControlPlugin extends BasePlugin {
|
10
|
+
// 关联渲染器名字
|
11
|
+
rendererName = 'static';
|
12
|
+
$schema = '/schemas/StaticControlSchema.json';
|
13
|
+
|
14
|
+
order = -390;
|
15
|
+
|
16
|
+
// 组件名称
|
17
|
+
name = '静态展示框';
|
18
|
+
isBaseComponent = true;
|
19
|
+
icon = 'fa fa-info';
|
20
|
+
description = `纯用来展示数据,可用来展示<code>json、date、image、progress</code>等数据`;
|
21
|
+
docLink = '/amis/zh-CN/components/form/static';
|
22
|
+
tags = ['表单项'];
|
23
|
+
scaffold = {
|
24
|
+
type: 'static',
|
25
|
+
label: '描述'
|
26
|
+
};
|
27
|
+
previewSchema: any = {
|
28
|
+
type: 'form',
|
29
|
+
className: 'text-left',
|
30
|
+
mode: 'horizontal',
|
31
|
+
wrapWithPanel: false,
|
32
|
+
body: [
|
33
|
+
{
|
34
|
+
...this.scaffold,
|
35
|
+
value: '静态值'
|
36
|
+
}
|
37
|
+
]
|
38
|
+
};
|
39
|
+
multifactor = true;
|
40
|
+
|
41
|
+
panelTitle = '静态展示';
|
42
|
+
panelBodyCreator = (context: BaseEventContext) => {
|
43
|
+
return [
|
44
|
+
/*{
|
45
|
+
children: (
|
46
|
+
<Button
|
47
|
+
size="sm"
|
48
|
+
level="info"
|
49
|
+
className="m-b"
|
50
|
+
block
|
51
|
+
onClick={this.exchangeRenderer.bind(this, context.id)}
|
52
|
+
>
|
53
|
+
更改渲染器类型
|
54
|
+
</Button>
|
55
|
+
)
|
56
|
+
},*/
|
57
|
+
getSchemaTpl('switchDefaultValue'),
|
58
|
+
|
59
|
+
{
|
60
|
+
type: 'input-text',
|
61
|
+
name: 'value',
|
62
|
+
label: '默认值',
|
63
|
+
visibleOn: 'typeof this.value !== "undefined"'
|
64
|
+
},
|
65
|
+
|
66
|
+
{
|
67
|
+
name: 'quickEdit',
|
68
|
+
label: '启用快速编辑',
|
69
|
+
type: 'switch',
|
70
|
+
pipeIn: (value: any) => !!value,
|
71
|
+
mode: 'inline',
|
72
|
+
className: 'w-full'
|
73
|
+
},
|
74
|
+
|
75
|
+
{
|
76
|
+
visibleOn: 'data.quickEdit',
|
77
|
+
name: 'quickEdit.mode',
|
78
|
+
type: 'button-group-select',
|
79
|
+
value: 'popOver',
|
80
|
+
label: '快速编辑模式',
|
81
|
+
size: 'xs',
|
82
|
+
mode: 'inline',
|
83
|
+
className: 'w-full',
|
84
|
+
options: [
|
85
|
+
{
|
86
|
+
label: '下拉',
|
87
|
+
value: 'popOver'
|
88
|
+
},
|
89
|
+
{
|
90
|
+
label: '内嵌',
|
91
|
+
value: 'inline'
|
92
|
+
}
|
93
|
+
]
|
94
|
+
},
|
95
|
+
|
96
|
+
{
|
97
|
+
visibleOn: 'data.quickEdit',
|
98
|
+
name: 'quickEdit.saveImmediately',
|
99
|
+
label: '是否立即保存',
|
100
|
+
type: 'switch',
|
101
|
+
mode: 'inline',
|
102
|
+
className: 'w-full',
|
103
|
+
description: '开启后修改即提交,而不是标记修改批量提交。',
|
104
|
+
descriptionClassName: 'help-block m-b-none',
|
105
|
+
pipeIn: (value: any) => !!value
|
106
|
+
},
|
107
|
+
|
108
|
+
getSchemaTpl('api', {
|
109
|
+
label: '立即保存接口',
|
110
|
+
description:
|
111
|
+
'是否单独给立即保存配置接口,如果不配置,则默认使用quickSaveItemApi。',
|
112
|
+
name: 'quickEdit.saveImmediately.api',
|
113
|
+
visibleOn: 'this.quickEdit && this.quickEdit.saveImmediately'
|
114
|
+
}),
|
115
|
+
|
116
|
+
{
|
117
|
+
visibleOn: 'data.quickEdit',
|
118
|
+
name: 'quickEdit',
|
119
|
+
asFormItem: true,
|
120
|
+
children: ({value, onChange, data}: any) => {
|
121
|
+
if (value === true) {
|
122
|
+
value = {};
|
123
|
+
}
|
124
|
+
|
125
|
+
const originMode = value.mode;
|
126
|
+
|
127
|
+
value = {
|
128
|
+
type: 'input-text',
|
129
|
+
name: data.name,
|
130
|
+
...value
|
131
|
+
};
|
132
|
+
delete value.mode;
|
133
|
+
|
134
|
+
// todo 多个快速编辑表单模式看来只能代码模式编辑了。
|
135
|
+
|
136
|
+
return (
|
137
|
+
<Button
|
138
|
+
level="info"
|
139
|
+
className="m-b"
|
140
|
+
size="sm"
|
141
|
+
block
|
142
|
+
onClick={() => {
|
143
|
+
this.manager.openSubEditor({
|
144
|
+
title: '配置快速编辑类型',
|
145
|
+
value: value,
|
146
|
+
slot: {
|
147
|
+
type: 'form',
|
148
|
+
mode: 'normal',
|
149
|
+
body: ['$$'],
|
150
|
+
wrapWithPanel: false
|
151
|
+
},
|
152
|
+
onChange: value =>
|
153
|
+
onChange(
|
154
|
+
{
|
155
|
+
...value,
|
156
|
+
mode: originMode
|
157
|
+
},
|
158
|
+
'quickEdit'
|
159
|
+
)
|
160
|
+
});
|
161
|
+
}}
|
162
|
+
>
|
163
|
+
配置快速编辑
|
164
|
+
</Button>
|
165
|
+
);
|
166
|
+
}
|
167
|
+
},
|
168
|
+
|
169
|
+
{
|
170
|
+
name: 'popOver',
|
171
|
+
label: '启用查看更多展示',
|
172
|
+
type: 'switch',
|
173
|
+
pipeIn: (value: any) => !!value,
|
174
|
+
mode: 'inline',
|
175
|
+
className: 'w-full'
|
176
|
+
},
|
177
|
+
|
178
|
+
{
|
179
|
+
name: 'popOver.mode',
|
180
|
+
label: '查看更多弹出模式',
|
181
|
+
type: 'select',
|
182
|
+
visibleOn: 'data.popOver',
|
183
|
+
pipeIn: defaultValue('popOver'),
|
184
|
+
options: [
|
185
|
+
{
|
186
|
+
label: '默认',
|
187
|
+
value: 'popOver'
|
188
|
+
},
|
189
|
+
|
190
|
+
{
|
191
|
+
label: '弹框',
|
192
|
+
value: 'dialog'
|
193
|
+
},
|
194
|
+
|
195
|
+
{
|
196
|
+
label: '抽出式弹框',
|
197
|
+
value: 'drawer'
|
198
|
+
}
|
199
|
+
]
|
200
|
+
},
|
201
|
+
|
202
|
+
{
|
203
|
+
name: 'popOver.position',
|
204
|
+
label: '查看更多弹出模式',
|
205
|
+
type: 'select',
|
206
|
+
visibleOn: 'data.popOver && data.popOver.mode === "popOver"',
|
207
|
+
pipeIn: defaultValue('center'),
|
208
|
+
options: [
|
209
|
+
{
|
210
|
+
label: '目标中部',
|
211
|
+
value: 'center'
|
212
|
+
},
|
213
|
+
|
214
|
+
{
|
215
|
+
label: '目标左上角',
|
216
|
+
value: 'left-top'
|
217
|
+
},
|
218
|
+
|
219
|
+
{
|
220
|
+
label: '目标右上角',
|
221
|
+
value: 'right-top'
|
222
|
+
},
|
223
|
+
|
224
|
+
{
|
225
|
+
label: '目标左下角',
|
226
|
+
value: 'left-bottom'
|
227
|
+
},
|
228
|
+
|
229
|
+
{
|
230
|
+
label: '目标右下角',
|
231
|
+
value: 'right-bottom'
|
232
|
+
},
|
233
|
+
|
234
|
+
{
|
235
|
+
label: '页面左上角',
|
236
|
+
value: 'fixed-left-top'
|
237
|
+
},
|
238
|
+
|
239
|
+
{
|
240
|
+
label: '页面右上角',
|
241
|
+
value: 'fixed-right-top'
|
242
|
+
},
|
243
|
+
|
244
|
+
{
|
245
|
+
label: '页面左下角',
|
246
|
+
value: 'fixed-left-bottom'
|
247
|
+
},
|
248
|
+
|
249
|
+
{
|
250
|
+
label: '页面右下角',
|
251
|
+
value: 'fixed-right-bottom'
|
252
|
+
}
|
253
|
+
]
|
254
|
+
},
|
255
|
+
|
256
|
+
{
|
257
|
+
visibleOn: 'data.popOver',
|
258
|
+
name: 'popOver',
|
259
|
+
asFormItem: true,
|
260
|
+
children: ({value, onChange}: any) => {
|
261
|
+
value = {
|
262
|
+
type: 'panel',
|
263
|
+
title: '查看详情',
|
264
|
+
body: '内容详情',
|
265
|
+
...value
|
266
|
+
};
|
267
|
+
|
268
|
+
return (
|
269
|
+
<Button
|
270
|
+
level="info"
|
271
|
+
className="m-b"
|
272
|
+
size="sm"
|
273
|
+
block
|
274
|
+
onClick={() => {
|
275
|
+
this.manager.openSubEditor({
|
276
|
+
title: '配置查看更多展示内容',
|
277
|
+
value: value,
|
278
|
+
onChange: value => onChange(value, 'quickEdit')
|
279
|
+
});
|
280
|
+
}}
|
281
|
+
>
|
282
|
+
查看更多内容配置
|
283
|
+
</Button>
|
284
|
+
);
|
285
|
+
}
|
286
|
+
},
|
287
|
+
|
288
|
+
getSchemaTpl('borderMode'),
|
289
|
+
{
|
290
|
+
name: 'copyable',
|
291
|
+
label: '启用内容复制功能',
|
292
|
+
type: 'switch',
|
293
|
+
pipeIn: (value: any) => !!value,
|
294
|
+
mode: 'inline',
|
295
|
+
className: 'w-full'
|
296
|
+
},
|
297
|
+
|
298
|
+
{
|
299
|
+
visibleOn: 'data.copyable',
|
300
|
+
name: 'copyable.content',
|
301
|
+
type: 'textarea',
|
302
|
+
label: '复制内容模板',
|
303
|
+
description: '默认为当前字段值,可定制。'
|
304
|
+
}
|
305
|
+
];
|
306
|
+
};
|
307
|
+
|
308
|
+
filterProps(props: any, node: EditorNodeType) {
|
309
|
+
props.$$id = node.id;
|
310
|
+
|
311
|
+
if (typeof props.value === 'undefined') {
|
312
|
+
props.value = mockValue(props);
|
313
|
+
}
|
314
|
+
return props;
|
315
|
+
}
|
316
|
+
|
317
|
+
/*exchangeRenderer(id: string) {
|
318
|
+
this.manager.showReplacePanel(id, '展示');
|
319
|
+
}*/
|
320
|
+
}
|
321
|
+
|
322
|
+
registerEditorPlugin(StaticControlPlugin);
|