chore: 调整状态容器组件配置

This commit is contained in:
zhangtao07 2023-11-06 20:04:48 +08:00
parent 0c41e8b14a
commit 8a3ccc736e
3 changed files with 22 additions and 5 deletions

View File

@ -321,6 +321,7 @@ export class SwitchContainerPlugin extends LayoutBasePlugin {
name: 'items',
label: '状态列表',
addTip: '新增组件状态',
minLength: 1,
items: [
{
type: 'input-text',
@ -356,6 +357,10 @@ export class SwitchContainerPlugin extends LayoutBasePlugin {
title: '外观',
className: 'p-none',
body: getSchemaTpl('collapseGroup', [
getSchemaTpl('theme:base', {
collapsed: false,
extra: []
}),
{
title: '布局',
body: [
@ -460,7 +465,15 @@ export class SwitchContainerPlugin extends LayoutBasePlugin {
getSchemaTpl('layout:stickyPosition')
]
},
...getSchemaTpl('theme:common', {exclude: ['layout']})
{
title: '自定义样式',
body: [
{
type: 'theme-cssCode',
label: false
}
]
}
])
},
{

View File

@ -7,7 +7,7 @@ import {findDOMNode} from 'react-dom';
import cx from 'classnames';
import get from 'lodash/get';
import Sortable from 'sortablejs';
import {FormItem, Button, Icon, render as amisRender} from 'amis';
import {FormItem, Button, Icon, render as amisRender, toast} from 'amis';
import {autobind} from 'amis-editor-core';
import type {Option} from 'amis';
import {createObject, FormControlProps} from 'amis-core';
@ -30,7 +30,6 @@ export type SourceType = 'custom' | 'api' | 'apicenter' | 'variable';
export interface OptionControlState {
items: Array<PlainObject>;
api: SchemaApi;
labelField: string;
valueField: string;
}
@ -50,7 +49,6 @@ export default class ListItemControl extends React.Component<
this.state = {
items: this.transformOptions(props),
api: props.data.source,
labelField: props.data.labelField || 'title',
valueField: props.data.valueField
};
@ -173,6 +171,12 @@ export default class ListItemControl extends React.Component<
*/
handleDelete(index: number) {
const items = this.state.items.concat();
const minLength = this.props.minLength;
if (minLength > 0 && items.length <= minLength) {
toast.warning(`列表项数目不能少于${minLength}`);
return;
}
items.splice(index, 1);
this.setState({items}, () => this.onChange());

View File

@ -80,7 +80,7 @@ export default class SwitchContainer extends React.Component<
componentDidUpdate(preProps: SwitchContainerProps) {
const items = this.props.items || [];
if (this.state.activeIndex >= 0 && !items[this.state.activeIndex]) {
if (this.state.activeIndex > 0 && !items[this.state.activeIndex]) {
this.setState({
activeIndex: 0
});