feat:input-group 组件配置面板优化 amis-saas-5352

Change-Id: I01af44ec8781b8a4aecf5e2eaf575c6504e10a6c
This commit is contained in:
zhou999 2022-12-10 19:19:31 +08:00
parent 9ab2335181
commit ba8ee992a7

View File

@ -1,8 +1,13 @@
import React from 'react'; import React from 'react';
import {Button} from 'amis'; import {
import {getSchemaTpl} from 'amis-editor-core'; defaultValue,
import {registerEditorPlugin} from 'amis-editor-core'; getSchemaTpl,
import {BasePlugin} from 'amis-editor-core'; registerEditorPlugin,
BasePlugin,
BaseEventContext,
tipedLabel
} from 'amis-editor-core';
import {ValidatorTag} from '../../validator';
export class InputGroupControlPlugin extends BasePlugin { export class InputGroupControlPlugin extends BasePlugin {
// 关联渲染器名字 // 关联渲染器名字
@ -47,50 +52,57 @@ export class InputGroupControlPlugin extends BasePlugin {
}; };
panelTitle = 'Input 组合'; panelTitle = 'Input 组合';
panelBody = [
[ regions = [{
key: 'body',
label: '内容区',
preferTag: '内容区',
renderMethod: 'render',
matchRegion: (elem: JSX.Element) => !!elem,
}];
notRenderFormZone = true;
panelJustify = true;
panelBodyCreator = (context: BaseEventContext) => {
return getSchemaTpl('tabs', [
{ {
name: 'body', title: '属性',
type: 'combo', body: getSchemaTpl('collapseGroup', [
// label: '子按钮',
multiple: true,
addable: false,
draggable: true,
draggableTip: '可排序、可移除、如要编辑请在预览区选中编辑',
editable: false,
visibleOn: 'this.body && this.body.length',
items: [
{ {
type: 'tpl', title: '基本',
inline: false, body: [
className: 'p-t-xs', getSchemaTpl('label'),
tpl: '<%= data.label %><% if (data.icon) { %><i class="<%= data.icon %>"/><% }%>' getSchemaTpl('labelRemark'),
getSchemaTpl('remark'),
getSchemaTpl('description')
]
},
getSchemaTpl('status', {isFormItem: true}),
getSchemaTpl('validation', {tag: ValidatorTag.MultiSelect})
])
},
{
title: '外观',
body: [
getSchemaTpl('collapseGroup', [
getSchemaTpl('style:formItem', {
renderer: context.info.renderer,
schema: [
getSchemaTpl('switch', {
label: '表单项内联',
name: 'inline',
pipeIn: defaultValue(false)
}),
]
}),
getSchemaTpl('style:classNames')
])
]
} }
] ]);
}, };
{
children: (
<Button
className="m-b"
// TODO需要限制一下 body 的类型,之前是这些 'text', 'url', 'email', 'password', 'select', 'date', 'time', 'date-time', 'date-range', 'formula', 'color', 'city', 'icon', 'plain', 'tpl', 'button', 'submit', 'reset'
onClick={() => {
// this.manager.showInsertPanel('body')
this.manager.showRendererPanel('表单项'); // '请从左侧组件面板中点击添加表单项'
}}
level="danger"
tooltip="插入一个新的元素"
size="sm"
block
>
</Button>
)
},
getSchemaTpl('formItemName', {
required: true
})
]
];
} }
registerEditorPlugin(InputGroupControlPlugin); registerEditorPlugin(InputGroupControlPlugin);