Skip to content

Commit

Permalink
feat: add hasChildren parameter for DroppableWidget (#219)
Browse files Browse the repository at this point in the history
  • Loading branch information
zjffun authored Feb 16, 2022
1 parent 3b3f5c3 commit d04cf3a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion formily/antd/src/components/ArrayCards/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export const ArrayCards: DnFC<CardProps> = observer((props) => {
<TreeNodeWidget key={node.id} node={node} />
))
) : (
<DroppableWidget />
<DroppableWidget hasChildren={false} />
)}
</div>
</Card>
Expand Down
14 changes: 12 additions & 2 deletions packages/react/src/widgets/DroppableWidget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,24 @@ export interface IDroppableWidgetProps {
height?: number
style?: React.CSSProperties
className?: string
hasChildren?: boolean
}

export const DroppableWidget: React.FC<IDroppableWidgetProps> = observer(
({ node, actions, height, placeholder, style, className, ...props }) => {
({
node,
actions,
height,
placeholder,
style,
className,
hasChildren: hasChildrenProp,
...props
}) => {
const currentNode = useTreeNode()
const nodeId = useNodeIdProps(node)
const target = node ?? currentNode
const hasChildren = target.children?.length > 0
const hasChildren = hasChildrenProp ?? target.children?.length > 0
return (
<div {...nodeId} className={className} style={style}>
{hasChildren ? (
Expand Down

0 comments on commit d04cf3a

Please sign in to comment.