diff --git a/components/transfer/demo/basic.md b/components/transfer/demo/basic.md index bfc737f0fb..f01d4750f4 100644 --- a/components/transfer/demo/basic.md +++ b/components/transfer/demo/basic.md @@ -7,23 +7,9 @@ --- ````jsx -import { Transfer, Button, Menu, Dropdown, Icon } from 'antd'; +import { Transfer, Button } from 'antd'; const container = document.getElementById('components-transfer-demo-basic'); -const menu = - - 编辑 - -; - -function makeDropdown(item) { - return - - ; -} - const App = React.createClass({ getInitialState() { return { @@ -51,7 +37,7 @@ const App = React.createClass({ }, render() { return
- +
; } diff --git a/components/transfer/index.jsx b/components/transfer/index.jsx index 32538796de..708797c82b 100644 --- a/components/transfer/index.jsx +++ b/components/transfer/index.jsx @@ -24,7 +24,6 @@ class Transfer extends Component { } moveTo(direction) { - // TODO: 将新移动的元素置顶: 存index至state中 const { filterKey } = this.props; let { dataSource } = this.state; if ( direction === 'right' ) { @@ -89,11 +88,11 @@ class Transfer extends Component { const filterText = e.target.value; if ( direction === 'left') { this.setState({ - 'leftFilter': filterText + 'leftFilter': filterText, }); } else { this.setState({ - 'rightFilter': filterText + 'rightFilter': filterText, }); } } @@ -117,7 +116,7 @@ class Transfer extends Component { } render() { - const { prefixCls, leftConfig, rightConfig, filterKey, extraRender } = this.props; + const { prefixCls, leftConfig, rightConfig, filterKey, showSearch, header, body, footer } = this.props; const { dataSource, leftFilter, rightFilter } = this.state; let leftDataSource = []; @@ -142,7 +141,12 @@ class Transfer extends Component { handleFilter={this.handleFilter.bind(this, 'left')} handleSelect={this.handleSelect.bind(this)} handleSelectAll={this.handleSelectAll.bind(this, 'left')} - extraRender={extraRender}/> + position={'left'} + showSearch={showSearch} + header={header} + body={body} + footer={footer} + /> + position={'right'} + showSearch={showSearch} + header={header} + body={body} + footer={footer} + /> ; } } @@ -175,9 +184,9 @@ Transfer.defaultProps = { }, showSearch: false, searchPlaceholder: '请输入搜索内容', - extraRender: noop, - footer: ()=> { - }, + header: noop, + footer: noop, + body: noop, }; Transfer.propTypes = { diff --git a/components/transfer/list.jsx b/components/transfer/list.jsx index 6183e2fa66..c4b7adf7e2 100644 --- a/components/transfer/list.jsx +++ b/components/transfer/list.jsx @@ -69,36 +69,41 @@ class TransferList extends Component { } render() { - const { prefixCls, config, footer, extraRender, dataSource, filter } = this.props; + const { prefixCls, config, header, footer, dataSource, filter, customLayout } = this.props; let globalCheckStatus = this.getGlobalCheckStatus(); + const headerDom = header({...this.props, globalCheckStatus}); + const footerDom = footer({...this.props, globalCheckStatus}); + const layout = customLayout({...this.props, globalCheckStatus}); + return (
-
+ { headerDom ?
+ { headerDom } +
:
{this.renderCheckbox({ prefixCls: 'ant-tree', checked: globalCheckStatus === 'all', checkPart: globalCheckStatus === 'part', checkable: })} {dataSource.length} 条{config.title} -
+
}
- -
    - {dataSource.map((item)=> { - return
  • - -
    - {extraRender(item)} -
    -
  • ;})} -
+ { layout ? layout :
+ +
    + {dataSource.map((item)=> { + return
  • + +
  • ;})} +
+
}
- { footer ?
- { footer } + { footerDom ?
+ { footerDom }
: null }
); } @@ -107,15 +112,20 @@ class TransferList extends Component { TransferList.defaultProps = { prefixCls: 'ant-transfer-list', dataSource: [], + defaultDataSource: [], + handleFilter: noop, + handleSelect: noop, onChange: noop, - footer: [], - extraRender: noop, + //advanced + header: noop, + footer: noop, + customLayout: noop, }; TransferList.propTypes = { prefixCls: PropTypes.string, dataSource: PropTypes.array, - footer: PropTypes.array, + footer: PropTypes.func, searchPlaceholder: PropTypes.string, handleFilter: PropTypes.func, handleSelect: PropTypes.func,