-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ feat(sortable-tree): 新增 sortableRule 函数规则,控制拖动排序 (#46)
* ✨ feat(sortabletree): 新增 sortableRule 函数规则,控制拖动排序 * 🔧 chore(types): 修正类型 * 🔧 chore(sortable-tree): fix returnType ReactElement -> ReactNode --------- Co-authored-by: kangxinlin.kxl <kangxinlin.kxl@antgroup.com>
- Loading branch information
Showing
9 changed files
with
1,135 additions
and
58 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 |
---|---|---|
|
@@ -12,3 +12,4 @@ docs-dist | |
server | ||
.husky/prepare-commit-msg | ||
coverage | ||
.vscode |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* title: 自定义可拖动规则 | ||
* description: 通过函数规则自定义是否可拖动 | ||
*/ | ||
import { SortableTree } from '@ant-design/pro-editor'; | ||
|
||
import { message } from 'antd'; | ||
import { initialData } from './data'; | ||
|
||
export default () => ( | ||
<div style={{ width: 340 }}> | ||
<SortableTree | ||
defaultTreeData={initialData} | ||
sortableRule={(data) => { | ||
// 只允许平级拖动 | ||
const { activeNode, projected } = data; | ||
const sortable = activeNode?.depth === projected?.depth; | ||
|
||
if (!sortable) message.warning('只允许同级拖动排序'); | ||
|
||
return sortable; | ||
}} | ||
/> | ||
</div> | ||
); |
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
Oops, something went wrong.