import * as React from 'react';
import { Fragment } from 'react';
import { common } from '@alilc/lowcode-engine';
import { Button } from '@alifd/next';
import {
IPublicModelSettingField,
IPublicTypeSetterType,
IPublicTypeFieldConfig,
} from '@alilc/lowcode-types';
import CustomIcon from './components/custom-icon';
import ListSetter from './components/list-setter';
import './index.less';
const { editorCabin, skeletonCabin } = common;
const { Title } = editorCabin;
const { PopupContext } = skeletonCabin;
const TableSetter: React.FC = React.memo((props: any) => {
return React.createElement(ListSetter, props);
});
export default class RsArraySetter extends React.PureComponent<{
value: any[];
field: IPublicModelSettingField;
itemSetter?: IPublicTypeSetterType;
itemMaxLength?: number;
variableBind?: boolean;
mode?: 'popup' | 'list';
forceInline?: boolean;
multiValue?: boolean;
onRemove?: Function;
}> {
static contextType = PopupContext;
private pipe: any;
render() {
const { mode, forceInline, ...props } = this.props;
const { field, itemSetter } = props;
let columns: IPublicTypeFieldConfig[] | undefined;
const items: IPublicTypeFieldConfig[] = (itemSetter as any)?.props?.config?.items;
if (items && Array.isArray(items)) {
columns = items
.filter((item) => item.isRequired || item.important || (item.setter as any)?.isRequired)
?.slice(0, 4);
}
if (mode === 'popup' || forceInline) {
const title = (
编辑:
);
if (!this.pipe) {
let width = 360;
if (columns) {
if (columns.length === 3) {
width = 480;
} else if (columns.length > 3) {
width = 600;
}
}
// 由于 this.context 类型未知,需要进行类型断言以避免类型错误
this.pipe = (this.context as { create: (config: { width: number }) => any }).create({
width,
});
}
this.pipe.send(, title);
return (
);
} else {
return ;
}
}
}