2016-09-19 17:52:20 +08:00
|
|
|
import React from 'react';
|
2015-11-26 16:07:11 +08:00
|
|
|
import Button from '../button';
|
2015-12-21 15:29:02 +08:00
|
|
|
import Icon from '../icon';
|
2015-11-26 16:07:11 +08:00
|
|
|
|
|
|
|
function noop() {
|
|
|
|
}
|
|
|
|
|
2016-07-01 20:52:17 +08:00
|
|
|
export interface TransferOperationProps {
|
2016-07-13 11:14:24 +08:00
|
|
|
className?: string;
|
|
|
|
leftArrowText?: string;
|
|
|
|
rightArrowText?: string;
|
2016-10-19 17:51:33 +08:00
|
|
|
moveToLeft?: React.FormEventHandler<any>;
|
|
|
|
moveToRight?: React.FormEventHandler<any>;
|
2016-07-13 11:14:24 +08:00
|
|
|
leftActive?: boolean;
|
|
|
|
rightActive?: boolean;
|
2016-07-01 20:52:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
export default class TransferOperation extends React.Component<TransferOperationProps, any> {
|
2016-03-29 14:01:10 +08:00
|
|
|
static defaultProps = {
|
|
|
|
leftArrowText: '',
|
|
|
|
rightArrowText: '',
|
|
|
|
moveToLeft: noop,
|
|
|
|
moveToRight: noop,
|
2016-07-13 11:14:24 +08:00
|
|
|
};
|
2016-03-29 14:01:10 +08:00
|
|
|
|
2015-11-26 16:07:11 +08:00
|
|
|
render() {
|
2015-12-24 15:23:26 +08:00
|
|
|
const {
|
|
|
|
moveToLeft,
|
|
|
|
moveToRight,
|
|
|
|
leftArrowText,
|
|
|
|
rightArrowText,
|
|
|
|
leftActive,
|
|
|
|
rightActive,
|
2015-12-24 15:31:03 +08:00
|
|
|
className,
|
2015-12-24 15:23:26 +08:00
|
|
|
} = this.props;
|
2015-11-26 16:07:11 +08:00
|
|
|
|
2015-12-24 15:23:26 +08:00
|
|
|
const moveToLeftButton = (
|
2015-12-24 15:52:49 +08:00
|
|
|
<Button type="primary" size="small" disabled={!leftActive} onClick={moveToLeft}>
|
|
|
|
{<span><Icon type="left" />{leftArrowText}</span>}
|
2015-12-24 15:23:26 +08:00
|
|
|
</Button>
|
|
|
|
);
|
|
|
|
const moveToRightButton = (
|
2015-12-24 15:52:49 +08:00
|
|
|
<Button type="primary" size="small" disabled={!rightActive} onClick={moveToRight}>
|
|
|
|
{<span>{rightArrowText}<Icon type="right" /></span>}
|
2015-12-24 15:23:26 +08:00
|
|
|
</Button>
|
|
|
|
);
|
2016-01-07 14:21:29 +08:00
|
|
|
return (
|
|
|
|
<div className={className}>
|
|
|
|
{moveToLeftButton}
|
|
|
|
{moveToRightButton}
|
|
|
|
</div>
|
|
|
|
);
|
2015-11-26 16:07:11 +08:00
|
|
|
}
|
|
|
|
}
|