From f54e822930f5180263af017d01ac99dfd2bb28fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=86=E7=A6=BB?= Date: Wed, 4 Jan 2017 18:41:28 +0800 Subject: [PATCH] feat: Transfer on search change (#4464) * add `onSearchChange(direction: 'left'|'right') => void ` of Transfer * typo --- components/transfer/index.en-US.md | 2 ++ components/transfer/index.tsx | 4 ++++ components/transfer/index.zh-CN.md | 1 + 3 files changed, 7 insertions(+) diff --git a/components/transfer/index.en-US.md b/components/transfer/index.en-US.md index 9544e0ec0..05969f39c 100644 --- a/components/transfer/index.en-US.md +++ b/components/transfer/index.en-US.md @@ -33,6 +33,8 @@ One or more elements can be selected from either column, one click on the proper | notFoundContent | Text to display when a column is empty. | React.ReactNode | 'The list is empty' | | footer | A function used for rendering the footer. | (props): React.ReactNode | | | lazy | property of [react-lazy-load](https://github.com/loktar00/react-lazy-load) for lazy rendering items | Object | `{ height: 32, offset: 32 }` | +| onSearchChange | A callback function which is executed when search field are changed | (direction: 'left' | 'right', event: Event): void | - | + ## Warning diff --git a/components/transfer/index.tsx b/components/transfer/index.tsx index 4f77b0488..2f184e371 100644 --- a/components/transfer/index.tsx +++ b/components/transfer/index.tsx @@ -36,6 +36,7 @@ export interface TransferProps { footer?: (props: TransferListProps) => React.ReactNode; body?: (props: TransferListProps) => React.ReactNode; rowKey?: (record: TransferItem) => string; + onSearchChange?: (direction: 'left' | 'right', e: Event) => void; lazy?: {}; } @@ -216,6 +217,9 @@ export default class Transfer extends React.Component { // add filter [`${direction}Filter`]: e.target.value, }); + if (this.props.onSearchChange) { + this.props.onSearchChange(direction, e); + } } handleLeftFilter = (e) => this.handleFilter('left', e) diff --git a/components/transfer/index.zh-CN.md b/components/transfer/index.zh-CN.md index 4c9be7581..b625afe5b 100644 --- a/components/transfer/index.zh-CN.md +++ b/components/transfer/index.zh-CN.md @@ -35,6 +35,7 @@ title: Transfer | notFoundContent | 当列表为空时显示的内容 | React.ReactNode | '列表为空' | | footer | 底部渲染函数 | (props): React.ReactNode | | | lazy | Transfer 使用了 [react-lazy-load](https://github.com/loktar00/react-lazy-load) 优化性能,这里可以设置相关参数 | Object | `{ height: 32, offset: 32 }` | +| onSearchChange | 搜索框内容时改变时的回调函数 | (direction: 'left' | 'right', event: Event): void | - | ## 注意