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,68 @@
|
|
1
|
+
import {registerEditorPlugin} from '../manager';
|
2
|
+
import {BaseEventContext} from '../plugin';
|
3
|
+
import {defaultValue, getSchemaTpl} from '../component/schemaTpl';
|
4
|
+
import {DatePlugin} from './Date';
|
5
|
+
|
6
|
+
export class DatetimePlugin extends DatePlugin {
|
7
|
+
// 关联渲染器名字
|
8
|
+
rendererName = 'datetime';
|
9
|
+
|
10
|
+
scaffold = {
|
11
|
+
type: 'datetime',
|
12
|
+
value: Math.round(Date.now() / 1000)
|
13
|
+
};
|
14
|
+
|
15
|
+
name = '日期时间展示';
|
16
|
+
isBaseComponent = true;
|
17
|
+
previewSchema = {
|
18
|
+
...this.scaffold,
|
19
|
+
format: 'YYYY-MM-DD HH:mm:ss',
|
20
|
+
value: Math.round(Date.now() / 1000)
|
21
|
+
};
|
22
|
+
panelBodyCreator = (context: BaseEventContext) => {
|
23
|
+
return [
|
24
|
+
getSchemaTpl('tabs', [
|
25
|
+
{
|
26
|
+
title: '常规',
|
27
|
+
body: [
|
28
|
+
{
|
29
|
+
type: 'input-datetime',
|
30
|
+
name: 'value',
|
31
|
+
label: '日期时间数值'
|
32
|
+
},
|
33
|
+
{
|
34
|
+
type: 'input-text',
|
35
|
+
name: 'format',
|
36
|
+
label: '显示日期时间格式',
|
37
|
+
description: '请参考 moment 中的格式用法。',
|
38
|
+
pipeIn: defaultValue('YYYY-MM-DD HH:mm:ss')
|
39
|
+
},
|
40
|
+
{
|
41
|
+
type: 'input-text',
|
42
|
+
name: 'valueFormat',
|
43
|
+
label: '数据日期格式',
|
44
|
+
description: '请参考 moment 中的格式用法。',
|
45
|
+
pipeIn: defaultValue('X')
|
46
|
+
},
|
47
|
+
{
|
48
|
+
name: 'placeholder',
|
49
|
+
type: 'input-text',
|
50
|
+
pipeIn: defaultValue('-'),
|
51
|
+
label: '占位符'
|
52
|
+
}
|
53
|
+
]
|
54
|
+
},
|
55
|
+
{
|
56
|
+
title: '外观',
|
57
|
+
body: [getSchemaTpl('className')]
|
58
|
+
},
|
59
|
+
{
|
60
|
+
title: '显隐',
|
61
|
+
body: [getSchemaTpl('ref'), getSchemaTpl('visible')]
|
62
|
+
}
|
63
|
+
])
|
64
|
+
];
|
65
|
+
};
|
66
|
+
}
|
67
|
+
|
68
|
+
registerEditorPlugin(DatetimePlugin);
|
@@ -0,0 +1,176 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import {registerEditorPlugin} from '../manager';
|
3
|
+
import {BasePlugin, RegionConfig, RendererInfo} from '../plugin';
|
4
|
+
import {defaultValue, getSchemaTpl} from '../component/schemaTpl';
|
5
|
+
import {isObject, noop} from '../util';
|
6
|
+
|
7
|
+
export class DialogPlugin extends BasePlugin {
|
8
|
+
// 关联渲染器名字
|
9
|
+
rendererName = 'dialog';
|
10
|
+
$schema = '/schemas/DialogSchema.json';
|
11
|
+
|
12
|
+
// 组件名称
|
13
|
+
name = '弹框';
|
14
|
+
isBaseComponent = true;
|
15
|
+
wrapperProps = {
|
16
|
+
wrapperComponent: InlineModal,
|
17
|
+
onClose: noop,
|
18
|
+
show: true
|
19
|
+
};
|
20
|
+
|
21
|
+
regions: Array<RegionConfig> = [
|
22
|
+
{
|
23
|
+
key: 'body',
|
24
|
+
label: '内容区',
|
25
|
+
renderMethod: 'renderBody',
|
26
|
+
renderMethodOverride: (regions, insertRegion) =>
|
27
|
+
function (this: any, ...args: any[]) {
|
28
|
+
const info: RendererInfo = this.props.$$editor;
|
29
|
+
const dom = this.super(...args);
|
30
|
+
|
31
|
+
if (info && args[1] === 'body') {
|
32
|
+
return insertRegion(this, dom, regions, info, info.plugin.manager);
|
33
|
+
}
|
34
|
+
|
35
|
+
return dom;
|
36
|
+
}
|
37
|
+
},
|
38
|
+
{
|
39
|
+
key: 'actions',
|
40
|
+
label: '按钮组',
|
41
|
+
renderMethod: 'renderFooter',
|
42
|
+
wrapperResolve: dom => dom
|
43
|
+
}
|
44
|
+
];
|
45
|
+
|
46
|
+
panelTitle = '弹框';
|
47
|
+
panelBody = [
|
48
|
+
getSchemaTpl('tabs', [
|
49
|
+
{
|
50
|
+
title: '常规',
|
51
|
+
body: [
|
52
|
+
{
|
53
|
+
label: '标题',
|
54
|
+
type: 'input-text',
|
55
|
+
name: 'title'
|
56
|
+
},
|
57
|
+
|
58
|
+
{
|
59
|
+
type: 'switch',
|
60
|
+
label: '数据映射',
|
61
|
+
name: 'data',
|
62
|
+
mode: 'inline',
|
63
|
+
className: 'block m-b-xs',
|
64
|
+
pipeIn: (value: any) => !!value,
|
65
|
+
pipeOut: (value: any) => (value ? {'&': '$$'} : null)
|
66
|
+
},
|
67
|
+
|
68
|
+
{
|
69
|
+
type: 'tpl',
|
70
|
+
visibleOn: '!this.data',
|
71
|
+
tpl:
|
72
|
+
'<p class="text-sm text-muted">当没开启数据映射时,弹框中默认会拥有触发打开弹框按钮所在环境的所有数据。</p>'
|
73
|
+
},
|
74
|
+
|
75
|
+
{
|
76
|
+
type: 'input-kv',
|
77
|
+
syncDefaultValue: false,
|
78
|
+
name: 'data',
|
79
|
+
visibleOn: 'this.data',
|
80
|
+
descriptionClassName: 'help-block text-xs m-b-none',
|
81
|
+
description:
|
82
|
+
'<p>当开启数据映射时,弹框中的数据只会包含设置的部分,请绑定数据。如:<code>{"a": "\\${a}", "b": 2}</code></p><p>如果希望在默认的基础上定制,请先添加一个 Key 为 `&` Value 为 `\\$$` 作为第一行。</p><div>当值为 <code>__undefined</code>时,表示删除对应的字段,可以结合<code>{"&": "\\$$"}</code>来达到黑名单效果。</div>',
|
83
|
+
messages: {
|
84
|
+
validateFailed: '数据映射中存在错误,请仔细检查'
|
85
|
+
}
|
86
|
+
},
|
87
|
+
|
88
|
+
{
|
89
|
+
label: '按 Esc 关闭弹框',
|
90
|
+
type: 'switch',
|
91
|
+
name: 'closeOnEsc',
|
92
|
+
mode: 'inline',
|
93
|
+
className: 'block',
|
94
|
+
value: false
|
95
|
+
},
|
96
|
+
|
97
|
+
{
|
98
|
+
label: '点击弹框外区域关闭弹框',
|
99
|
+
type: 'switch',
|
100
|
+
name: 'closeOnOutside',
|
101
|
+
mode: 'inline',
|
102
|
+
className: 'block',
|
103
|
+
value: false
|
104
|
+
}
|
105
|
+
]
|
106
|
+
},
|
107
|
+
{
|
108
|
+
title: '外观',
|
109
|
+
body: [
|
110
|
+
{
|
111
|
+
label: '尺寸',
|
112
|
+
type: 'button-group-select',
|
113
|
+
name: 'size',
|
114
|
+
size: 'sm',
|
115
|
+
className: 'block',
|
116
|
+
pipeIn: defaultValue(''),
|
117
|
+
options: [
|
118
|
+
{
|
119
|
+
label: '小',
|
120
|
+
value: 'sm'
|
121
|
+
},
|
122
|
+
{
|
123
|
+
label: '默认',
|
124
|
+
value: ''
|
125
|
+
},
|
126
|
+
{
|
127
|
+
label: '中',
|
128
|
+
value: 'md'
|
129
|
+
},
|
130
|
+
{
|
131
|
+
label: '大',
|
132
|
+
value: 'lg'
|
133
|
+
},
|
134
|
+
{
|
135
|
+
label: '超大',
|
136
|
+
value: 'xl'
|
137
|
+
}
|
138
|
+
]
|
139
|
+
},
|
140
|
+
|
141
|
+
{
|
142
|
+
label: '是否显示关闭按钮',
|
143
|
+
type: 'switch',
|
144
|
+
name: 'showCloseButton',
|
145
|
+
mode: 'inline',
|
146
|
+
className: 'block',
|
147
|
+
value: true
|
148
|
+
},
|
149
|
+
|
150
|
+
getSchemaTpl('className', {
|
151
|
+
name: 'headerClassName',
|
152
|
+
label: '顶部 CSS 类名'
|
153
|
+
}),
|
154
|
+
|
155
|
+
getSchemaTpl('className', {
|
156
|
+
name: 'bodyClassName',
|
157
|
+
label: '内容 CSS 类名'
|
158
|
+
})
|
159
|
+
]
|
160
|
+
}
|
161
|
+
])
|
162
|
+
];
|
163
|
+
|
164
|
+
buildSubRenderers() {}
|
165
|
+
}
|
166
|
+
|
167
|
+
registerEditorPlugin(DialogPlugin);
|
168
|
+
|
169
|
+
export class InlineModal extends React.Component<any, any> {
|
170
|
+
componentDidMount() {}
|
171
|
+
|
172
|
+
render() {
|
173
|
+
const {children} = this.props;
|
174
|
+
return <div className="ae-InlineModel">{children}</div>;
|
175
|
+
}
|
176
|
+
}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
import {registerEditorPlugin} from '../manager';
|
2
|
+
import {BasePlugin} from '../plugin';
|
3
|
+
import {getSchemaTpl} from '../component/schemaTpl';
|
4
|
+
|
5
|
+
export class DividerPlugin extends BasePlugin {
|
6
|
+
// 关联渲染器名字
|
7
|
+
rendererName = 'divider';
|
8
|
+
$schema = '/schemas/DividerSchema.json';
|
9
|
+
|
10
|
+
// 组件名称
|
11
|
+
name = '分隔线';
|
12
|
+
isBaseComponent = true;
|
13
|
+
icon = 'fa fa-minus';
|
14
|
+
description = '用来展示一个分割线,可用来做视觉上的隔离。';
|
15
|
+
scaffold = {
|
16
|
+
type: 'divider'
|
17
|
+
};
|
18
|
+
previewSchema: any = {
|
19
|
+
type: 'divider',
|
20
|
+
className: 'm-t-none m-b-none'
|
21
|
+
};
|
22
|
+
|
23
|
+
panelTitle = '分隔线';
|
24
|
+
panelBody = getSchemaTpl('tabs', [
|
25
|
+
{
|
26
|
+
title: '外观',
|
27
|
+
body: [getSchemaTpl('className')]
|
28
|
+
},
|
29
|
+
{
|
30
|
+
title: '显隐',
|
31
|
+
body: [getSchemaTpl('ref'), getSchemaTpl('visible')]
|
32
|
+
}
|
33
|
+
]);
|
34
|
+
}
|
35
|
+
|
36
|
+
registerEditorPlugin(DividerPlugin);
|
@@ -0,0 +1,214 @@
|
|
1
|
+
import {registerEditorPlugin} from '../manager';
|
2
|
+
import {BasePlugin, RegionConfig, RendererInfo} from '../plugin';
|
3
|
+
import {defaultValue, getSchemaTpl} from '../component/schemaTpl';
|
4
|
+
import {noop} from '../util';
|
5
|
+
import {InlineModal} from './Dialog';
|
6
|
+
|
7
|
+
export class DrawerPlugin extends BasePlugin {
|
8
|
+
// 关联渲染器名字
|
9
|
+
rendererName = 'drawer';
|
10
|
+
$schema = '/schemas/DrawerSchema.json';
|
11
|
+
|
12
|
+
// 组件名称
|
13
|
+
name = '抽屉式弹框';
|
14
|
+
isBaseComponent = true;
|
15
|
+
wrapperProps = {
|
16
|
+
wrapperComponent: InlineModal,
|
17
|
+
onClose: noop,
|
18
|
+
resizable: false,
|
19
|
+
show: true
|
20
|
+
};
|
21
|
+
|
22
|
+
regions: Array<RegionConfig> = [
|
23
|
+
{
|
24
|
+
key: 'body',
|
25
|
+
label: '内容区',
|
26
|
+
renderMethod: 'renderBody',
|
27
|
+
renderMethodOverride: (regions, insertRegion) =>
|
28
|
+
function (this: any, ...args: any[]) {
|
29
|
+
const info: RendererInfo = this.props.$$editor;
|
30
|
+
const dom = this.super(...args);
|
31
|
+
|
32
|
+
if (info && args[1] === 'body') {
|
33
|
+
return insertRegion(this, dom, regions, info, info.plugin.manager);
|
34
|
+
}
|
35
|
+
|
36
|
+
return dom;
|
37
|
+
}
|
38
|
+
},
|
39
|
+
{
|
40
|
+
key: 'actions',
|
41
|
+
label: '按钮组',
|
42
|
+
renderMethod: 'renderFooter',
|
43
|
+
wrapperResolve: dom => dom
|
44
|
+
}
|
45
|
+
];
|
46
|
+
|
47
|
+
panelTitle = '弹框';
|
48
|
+
panelBody = [
|
49
|
+
getSchemaTpl('tabs', [
|
50
|
+
{
|
51
|
+
title: '常规',
|
52
|
+
body: [
|
53
|
+
{
|
54
|
+
label: '标题',
|
55
|
+
type: 'input-text',
|
56
|
+
name: 'title'
|
57
|
+
},
|
58
|
+
|
59
|
+
// {
|
60
|
+
// children: (
|
61
|
+
// <Button
|
62
|
+
// size="sm"
|
63
|
+
// className="m-b-sm"
|
64
|
+
// level="info"
|
65
|
+
// block
|
66
|
+
// onClick={() => this.manager.showInsertPanel('body')}
|
67
|
+
// >
|
68
|
+
// 新增内容
|
69
|
+
// </Button>
|
70
|
+
// )
|
71
|
+
// },
|
72
|
+
|
73
|
+
{
|
74
|
+
type: 'divider'
|
75
|
+
},
|
76
|
+
|
77
|
+
{
|
78
|
+
label: '位置',
|
79
|
+
type: 'button-group-select',
|
80
|
+
name: 'position',
|
81
|
+
value: 'right',
|
82
|
+
size: 'sm',
|
83
|
+
mode: 'inline',
|
84
|
+
className: 'block',
|
85
|
+
options: [
|
86
|
+
{
|
87
|
+
label: '左',
|
88
|
+
value: 'left'
|
89
|
+
},
|
90
|
+
{
|
91
|
+
label: '上',
|
92
|
+
value: 'top'
|
93
|
+
},
|
94
|
+
{
|
95
|
+
label: '右',
|
96
|
+
value: 'right'
|
97
|
+
},
|
98
|
+
{
|
99
|
+
label: '下',
|
100
|
+
value: 'bottom'
|
101
|
+
}
|
102
|
+
],
|
103
|
+
description: '定义弹框从什么位置呼出'
|
104
|
+
},
|
105
|
+
|
106
|
+
{
|
107
|
+
type: 'switch',
|
108
|
+
label: '数据映射',
|
109
|
+
name: 'data',
|
110
|
+
mode: 'inline',
|
111
|
+
className: 'w-full m-b-xs',
|
112
|
+
pipeIn: (value: any) => !!value,
|
113
|
+
pipeOut: (value: any) => (value ? {'&': '$$'} : null)
|
114
|
+
},
|
115
|
+
|
116
|
+
{
|
117
|
+
type: 'tpl',
|
118
|
+
visibleOn: '!this.data',
|
119
|
+
tpl:
|
120
|
+
'<p class="text-sm text-muted">当没开启数据映射时,弹框中默认会拥有触发打开弹框按钮所在环境的所有数据。</p>'
|
121
|
+
},
|
122
|
+
|
123
|
+
{
|
124
|
+
type: 'input-kv',
|
125
|
+
syncDefaultValue: false,
|
126
|
+
name: 'data',
|
127
|
+
visibleOn: 'this.data',
|
128
|
+
descriptionClassName: 'help-block text-xs m-b-none',
|
129
|
+
description:
|
130
|
+
'<p>当开启数据映射时,弹框中的数据只会包含设置的部分,请绑定数据。如:<code>{"a": "\\${a}", "b": 2}</code></p><p>如果希望在默认的基础上定制,请先添加一个 Key 为 `&` Value 为 `\\$$` 作为第一行。</p><div>当值为 <code>__undefined</code>时,表示删除对应的字段,可以结合<code>{"&": "\\$$"}</code>来达到黑名单效果。</div>'
|
131
|
+
},
|
132
|
+
|
133
|
+
{
|
134
|
+
type: 'switch',
|
135
|
+
name: 'closeOnOutside',
|
136
|
+
label: '点击外部关闭弹框',
|
137
|
+
mode: 'inline',
|
138
|
+
className: 'block'
|
139
|
+
},
|
140
|
+
|
141
|
+
{
|
142
|
+
label: '按 Esc 可关闭?',
|
143
|
+
type: 'switch',
|
144
|
+
name: 'closeOnEsc',
|
145
|
+
mode: 'inline',
|
146
|
+
className: 'block'
|
147
|
+
}
|
148
|
+
]
|
149
|
+
},
|
150
|
+
{
|
151
|
+
title: '外观',
|
152
|
+
body: [
|
153
|
+
{
|
154
|
+
label: '尺寸',
|
155
|
+
type: 'button-group-select',
|
156
|
+
name: 'size',
|
157
|
+
size: 'sm',
|
158
|
+
mode: 'inline',
|
159
|
+
className: 'block',
|
160
|
+
options: [
|
161
|
+
{
|
162
|
+
label: '超小',
|
163
|
+
value: 'xs'
|
164
|
+
},
|
165
|
+
{
|
166
|
+
label: '小',
|
167
|
+
value: 'sm'
|
168
|
+
},
|
169
|
+
{
|
170
|
+
label: '中',
|
171
|
+
value: 'md'
|
172
|
+
},
|
173
|
+
{
|
174
|
+
label: '大',
|
175
|
+
value: 'lg'
|
176
|
+
},
|
177
|
+
{
|
178
|
+
label: '超大',
|
179
|
+
value: 'xl'
|
180
|
+
}
|
181
|
+
]
|
182
|
+
},
|
183
|
+
{
|
184
|
+
type: 'switch',
|
185
|
+
name: 'overlay',
|
186
|
+
label: '是否显示蒙层',
|
187
|
+
mode: 'inline',
|
188
|
+
className: 'block',
|
189
|
+
pipeIn: defaultValue(true)
|
190
|
+
},
|
191
|
+
|
192
|
+
{
|
193
|
+
type: 'switch',
|
194
|
+
name: 'resizable',
|
195
|
+
label: '可拉拽',
|
196
|
+
mode: 'inline',
|
197
|
+
className: 'block',
|
198
|
+
pipeIn: defaultValue(false),
|
199
|
+
description: '定义弹框是否可拉拽调整大小'
|
200
|
+
},
|
201
|
+
getSchemaTpl('className'),
|
202
|
+
getSchemaTpl('className', {
|
203
|
+
label: 'bodyClassName 类名',
|
204
|
+
name: 'bodyClassName'
|
205
|
+
})
|
206
|
+
]
|
207
|
+
}
|
208
|
+
])
|
209
|
+
];
|
210
|
+
|
211
|
+
buildSubRenderers() {}
|
212
|
+
}
|
213
|
+
|
214
|
+
registerEditorPlugin(DrawerPlugin);
|