feat: Transfer on search change (#4464)

*  add `onSearchChange(direction: 'left'|'right') => void ` of Transfer

* typo
This commit is contained in:
陆离 2017-01-04 18:41:28 +08:00 committed by afc163
parent df18edda79
commit f54e822930
3 changed files with 7 additions and 0 deletions

View File

@ -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

View File

@ -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<TransferProps, any> {
// add filter
[`${direction}Filter`]: e.target.value,
});
if (this.props.onSearchChange) {
this.props.onSearchChange(direction, e);
}
}
handleLeftFilter = (e) => this.handleFilter('left', e)

View File

@ -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 | - |
## 注意