-
-
Notifications
You must be signed in to change notification settings - Fork 676
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(react): support normalize DroppableWidget
- Loading branch information
Showing
27 changed files
with
132 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,18 @@ | ||
import React from 'react' | ||
import { observer } from '@formily/reactive-react' | ||
import { useNodeIdProps, useTreeNode, useDesigner } from '@designable/react' | ||
import { Droppable } from '../Droppable' | ||
import { DroppableWidget } from '@designable/react' | ||
import './styles.less' | ||
|
||
export const Container: React.FC = observer((props) => { | ||
const node = useTreeNode() | ||
const nodeId = useNodeIdProps() | ||
if (node.children.length === 0) return <Droppable {...nodeId} /> | ||
return <div {...nodeId}>{props.children}</div> | ||
return <DroppableWidget>{props.children}</DroppableWidget> | ||
}) | ||
|
||
export const withContainer = (Target: React.JSXElementConstructor<any>) => { | ||
return ({ ...props }: any) => { | ||
const designer = useDesigner() | ||
delete props[designer.props.nodeIdAttrName] | ||
return (props: any) => { | ||
return ( | ||
<Container> | ||
<DroppableWidget> | ||
<Target {...props} /> | ||
</Container> | ||
</DroppableWidget> | ||
) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
@import '~antd/lib/style/themes/default.less'; | ||
|
||
.dn-array-cards { | ||
background-color: @background-color-light; | ||
background-color: @component-background; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
@import '~antd/lib/style/themes/default.less'; | ||
|
||
.dn-array-table { | ||
background-color: @background-color-light; | ||
background-color: @component-background; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,21 @@ | ||
import React from 'react' | ||
import { observer } from '@formily/reactive-react' | ||
import { useNodeIdProps, useTreeNode, useDesigner } from '@designable/react' | ||
import { Droppable } from '../Droppable' | ||
import { useNodeIdProps, useTreeNode, DroppableWidget } from '@designable/react' | ||
import './styles.less' | ||
|
||
export const Container: React.FC = observer((props) => { | ||
const node = useTreeNode() | ||
const nodeId = useNodeIdProps() | ||
if (node.children.length === 0) return <Droppable {...nodeId} /> | ||
if (node.children.length === 0) return <DroppableWidget {...nodeId} /> | ||
return <div {...nodeId}>{props.children}</div> | ||
}) | ||
|
||
export const withContainer = (Target: React.JSXElementConstructor<any>) => { | ||
return ({ ...props }: any) => { | ||
const designer = useDesigner() | ||
// 原始 props 可能被冻结了,delete 会报错 | ||
delete props[designer.props.nodeIdAttrName] | ||
return (props: any) => { | ||
return ( | ||
<Container> | ||
<DroppableWidget> | ||
<Target {...props} /> | ||
</Container> | ||
</DroppableWidget> | ||
) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
@import '~antd/lib/style/themes/default.less'; | ||
|
||
.dn-array-cards { | ||
background-color: @background-color-light; | ||
background-color: @component-background; | ||
} |
Oops, something went wrong.