Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(useTransfer): add useTransfer hooks #2370

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

liangchaofei
Copy link
Contributor

@liangchaofei liangchaofei commented Nov 15, 2023

useTransfer

封装了 Antd Transfer 常用的逻辑。

API

const result: ReturnValue<Item> = useTransfer<Item>(
  dataSource: Item[],
  options: Options = {}
);

参数

参数 说明 类型
dataSource Transfer 组件数据源 Item[]
options 可选配置项,可用于配置默认数据供服务端渲染 Options

返回值

参数 说明 类型
transferProps.dataSource Transfer 组件数据源 Item[]
transferProps.targetKeys 右侧数据项 string[]
transferProps.selectedKeys 选中项 string[]
transferProps.disabled 是否禁用 boolean
transferProps.showSearch 是否可搜索 boolean
transferProps.filterOption Antd Transfer 的搜索使用的筛选属性 any
transferProps.onChange 选项在两栏之间转移时的回调函数 (nextTargetKeys: string[], direction: string, moveKeys: string[]) => void
transferProps.onSelectChange 选中项发生改变时的回调函数 (sourceSelectedKeys: string[], targetSelectedKeys: string[]) => void
noTargetKeys 左侧数据项 string[]
unSelectedKeys 未选中项 string[]
setTargetKeys 设置右侧数据项 (keys: string[]) => void
setSelectedKeys 设置选中项 (keys: string[]) => void
setDisabled 设置是否禁用 (disabled: boolean) => void
setShowSearch 设置是否搜索 (showSearch: boolean) => void
leftAll 将数据全部移入左侧 () => void
rightAll 将数据全部移入右侧 () => void
selectAll 全选 () => void
unSelectAll 全部反选 () => void

Options

参数 说明 类型 默认值
defaultTargetKeys 默认右侧数据项 string[] []
defaultSelectedKeys 默认选中项 string[] []
defaultDisabled 默认是否禁用 boolean false
deafultShowSearch 默认是否搜索 boolean false
onChange 选项在两栏之间转移时的回调函数 (nextTargetKeys: string[], direction: string, moveKeys: string[]) => void -

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


liangchaofei seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@crazylxr
Copy link
Collaborator

这个放到 v4 看看要不要搞

@liangchaofei
Copy link
Contributor Author

这个放到 v4 看看要不要搞

v4现在什么进度?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants