Skip to content

Commit

Permalink
feat(react): support placeholder to DroppableWidget
Browse files Browse the repository at this point in the history
  • Loading branch information
janryWang committed Oct 23, 2021
1 parent 827f6ec commit 19e61ad
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/react/src/widgets/DroppableWidget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,21 @@ import './styles.less'
export interface IDroppableWidgetProps {
node?: TreeNode
actions?: INodeActionsWidgetActionProps[]
placeholder?: boolean
height?: number
style?: React.CSSProperties
className?: string
}

export const DroppableWidget: React.FC<IDroppableWidgetProps> = observer(
({ node, actions, height, style, className, ...props }) => {
({ node, actions, height, placeholder, style, className, ...props }) => {
const currentNode = useTreeNode()
const nodeId = useNodeIdProps(node)
const target = node ?? currentNode
const hasChildren = target.children?.length > 0
return (
<div {...nodeId} className={className} style={style}>
{hasChildren ? (
{hasChildren && !placeholder ? (
props.children
) : (
<div style={{ height }} className="dn-droppable-placeholder">
Expand All @@ -43,3 +44,7 @@ export const DroppableWidget: React.FC<IDroppableWidgetProps> = observer(
)
}
)

DroppableWidget.defaultProps = {
placeholder: true,
}

0 comments on commit 19e61ad

Please sign in to comment.