|
@ -71,8 +71,14 @@ export default class TransferList extends React.Component { |
|
|
return PureRenderMixin.shouldComponentUpdate.apply(this, args); |
|
|
return PureRenderMixin.shouldComponentUpdate.apply(this, args); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
handleSelectAll = () => { |
|
|
getCheckStatus(filteredDataSource) { |
|
|
this.props.handleSelectAll(); |
|
|
const { checkedKeys } = this.props; |
|
|
|
|
|
if (checkedKeys.length === 0) { |
|
|
|
|
|
return 'none'; |
|
|
|
|
|
} else if (filteredDataSource.every(item => checkedKeys.indexOf(item.key) >= 0)) { |
|
|
|
|
|
return 'all'; |
|
|
|
|
|
} |
|
|
|
|
|
return 'part'; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
handleSelect = (selectedItem) => { |
|
|
handleSelect = (selectedItem) => { |
|
@ -89,24 +95,23 @@ export default class TransferList extends React.Component { |
|
|
this.props.handleClear(); |
|
|
this.props.handleClear(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
renderCheckbox(props) { |
|
|
renderCheckbox({ prefixCls, filteredDataSource, checked, checkPart, disabled, checkable }) { |
|
|
const { prefixCls } = props; |
|
|
const checkAll = (!checkPart) && checked; |
|
|
|
|
|
|
|
|
const checkboxCls = classNames({ |
|
|
const checkboxCls = classNames({ |
|
|
[`${prefixCls}-checkbox`]: true, |
|
|
[`${prefixCls}-checkbox`]: true, |
|
|
[`${prefixCls}-checkbox-indeterminate`]: props.checkPart, |
|
|
[`${prefixCls}-checkbox-indeterminate`]: checkPart, |
|
|
[`${prefixCls}-checkbox-checked`]: (!props.checkPart) && props.checked, |
|
|
[`${prefixCls}-checkbox-checked`]: checkAll, |
|
|
[`${prefixCls}-checkbox-disabled`]: !!props.disabled, |
|
|
[`${prefixCls}-checkbox-disabled`]: disabled, |
|
|
}); |
|
|
}); |
|
|
let customEle = null; |
|
|
|
|
|
if (typeof props.checkable !== 'boolean') { |
|
|
|
|
|
customEle = props.checkable; |
|
|
|
|
|
} |
|
|
|
|
|
return ( |
|
|
return ( |
|
|
<span ref="checkbox" |
|
|
<span |
|
|
|
|
|
ref="checkbox" |
|
|
className={checkboxCls} |
|
|
className={checkboxCls} |
|
|
onClick={(!props.disabled) && this.handleSelectAll} |
|
|
onClick={() => this.props.handleSelectAll(filteredDataSource, checkAll)} |
|
|
> |
|
|
> |
|
|
{customEle} |
|
|
{(typeof checkable !== 'boolean') ? checkable : null} |
|
|
</span> |
|
|
</span> |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
@ -117,7 +122,7 @@ export default class TransferList extends React.Component { |
|
|
|
|
|
|
|
|
render() { |
|
|
render() { |
|
|
const { prefixCls, dataSource, titleText, filter, checkedKeys, |
|
|
const { prefixCls, dataSource, titleText, filter, checkedKeys, |
|
|
checkStatus, body, footer, showSearch, render, style } = this.props; |
|
|
body, footer, showSearch, render, style } = this.props; |
|
|
|
|
|
|
|
|
let { searchPlaceholder, notFoundContent } = this.props; |
|
|
let { searchPlaceholder, notFoundContent } = this.props; |
|
|
|
|
|
|
|
@ -130,7 +135,9 @@ export default class TransferList extends React.Component { |
|
|
[`${prefixCls}-with-footer`]: !!footerDom, |
|
|
[`${prefixCls}-with-footer`]: !!footerDom, |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
const showItems = dataSource.map((item) => { |
|
|
const filteredDataSource = []; |
|
|
|
|
|
|
|
|
|
|
|
const showItems = dataSource.map(item => { |
|
|
const renderResult = render(item); |
|
|
const renderResult = render(item); |
|
|
let renderedText; |
|
|
let renderedText; |
|
|
let renderedEl; |
|
|
let renderedEl; |
|
@ -147,6 +154,8 @@ export default class TransferList extends React.Component { |
|
|
return null; |
|
|
return null; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
filteredDataSource.push(item); |
|
|
|
|
|
|
|
|
return ( |
|
|
return ( |
|
|
<li onClick={() => this.handleSelect(item)} key={item.key} title={renderedText}> |
|
|
<li onClick={() => this.handleSelect(item)} key={item.key} title={renderedText}> |
|
|
<Checkbox checked={checkedKeys.some(key => key === item.key)} /> |
|
|
<Checkbox checked={checkedKeys.some(key => key === item.key)} /> |
|
@ -167,6 +176,8 @@ export default class TransferList extends React.Component { |
|
|
|| this.context.antLocale.Transfer.notFoundContent; |
|
|
|| this.context.antLocale.Transfer.notFoundContent; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const checkStatus = this.getCheckStatus(filteredDataSource); |
|
|
|
|
|
|
|
|
return ( |
|
|
return ( |
|
|
<div className={listCls} style={style}> |
|
|
<div className={listCls} style={style}> |
|
|
<div className={`${prefixCls}-header`}> |
|
|
<div className={`${prefixCls}-header`}> |
|
@ -175,6 +186,7 @@ export default class TransferList extends React.Component { |
|
|
checked: checkStatus === 'all', |
|
|
checked: checkStatus === 'all', |
|
|
checkPart: checkStatus === 'part', |
|
|
checkPart: checkStatus === 'part', |
|
|
checkable: <span className={'ant-transfer-checkbox-inner'}></span>, |
|
|
checkable: <span className={'ant-transfer-checkbox-inner'}></span>, |
|
|
|
|
|
filteredDataSource, |
|
|
})} |
|
|
})} |
|
|
<span className={`${prefixCls}-header-selected`}> |
|
|
<span className={`${prefixCls}-header-selected`}> |
|
|
<span> |
|
|
<span> |
|
|