import { Component } from 'react';
import classNames from 'classnames';
import { observer, Title } from '@alilc/lowcode-editor-core';
import { ExclusiveGroup } from '@alilc/lowcode-designer';
import TreeNode from '../tree-node';
import TreeNodeView from './tree-node';
import { intlNode } from '../locale';
@observer
export default class TreeBranches extends Component<{
treeNode: TreeNode;
isModal?: boolean;
}> {
render() {
const { treeNode, isModal } = this.props;
const { expanded } = treeNode;
if (!expanded) {
return null;
}
return (
{
!isModal &&
}
);
}
}
@observer
class TreeNodeChildren extends Component<{
treeNode: TreeNode;
isModal?: boolean;
}> {
render() {
const { treeNode, isModal } = this.props;
const children: any = [];
let groupContents: any[] = [];
let currentGrp: ExclusiveGroup;
const endGroup = () => {
if (groupContents.length > 0) {
children.push(
,
);
groupContents = [];
}
};
const { dropDetail } = treeNode;
const dropIndex = dropDetail?.index;
const insertion = (
);
treeNode.children?.forEach((child, index) => {
const childIsModal = child.node.componentMeta.isModal || false;
if (isModal != childIsModal) {
return;
}
const { conditionGroup } = child.node;
if (conditionGroup !== currentGrp) {
endGroup();
}
if (conditionGroup) {
currentGrp = conditionGroup;
if (index === dropIndex) {
if (groupContents.length > 0) {
groupContents.push(insertion);
} else {
children.push(insertion);
}
}
groupContents.push();
} else {
if (index === dropIndex) {
children.push(insertion);
}
children.push();
}
});
endGroup();
const length = treeNode.children?.length || 0;
if (dropIndex != null && dropIndex >= length) {
children.push(insertion);
}
return {children}
;
}
}
@observer
class TreeNodeSlots extends Component<{
treeNode: TreeNode;
}> {
render() {
const { treeNode } = this.props;
if (!treeNode.hasSlots()) {
return null;
}
return (
{treeNode.slots.map(tnode => (
))}
);
}
}