import React from 'react' import { TreeNode } from '@designable/core' import { observer } from '@formily/reactive-react' import { useTreeNode, useNodeIdProps } from '../../hooks' import { NodeTitleWidget } from '../NodeTitleWidget' import { NodeActionsWidget, INodeActionsWidgetActionProps, } from '../NodeActionsWidget' import './styles.less' export interface IDroppableWidgetProps { node?: TreeNode actions?: INodeActionsWidgetActionProps[] placeholder?: boolean height?: number style?: React.CSSProperties className?: string hasChildren?: boolean } export const DroppableWidget: React.FC = observer( ({ node, actions, height, placeholder, style, className, hasChildren: hasChildrenProp, ...props }) => { const currentNode = useTreeNode() const nodeId = useNodeIdProps(node) const target = node ?? currentNode const hasChildren = hasChildrenProp ?? target.children?.length > 0 return (
{hasChildren ? ( props.children ) : placeholder ? (
) : ( props.children )} {actions?.length ? ( {actions.map((action, key) => ( ))} ) : null}
) } ) DroppableWidget.defaultProps = { placeholder: true, }