2020-03-02 12:09:38 +08:00
|
|
|
import LeftOutlined from '@ant-design/icons/LeftOutlined';
|
|
|
|
import RightOutlined from '@ant-design/icons/RightOutlined';
|
2023-05-06 15:49:37 +08:00
|
|
|
import * as React from 'react';
|
2015-11-26 16:07:11 +08:00
|
|
|
import Button from '../button';
|
2022-05-07 14:31:54 +08:00
|
|
|
import type { DirectionType } from '../config-provider';
|
2015-11-26 16:07:11 +08:00
|
|
|
|
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;
|
2022-12-15 17:48:29 +08:00
|
|
|
moveToLeft?: React.MouseEventHandler<HTMLButtonElement | HTMLAnchorElement>;
|
|
|
|
moveToRight?: React.MouseEventHandler<HTMLButtonElement | HTMLAnchorElement>;
|
2016-07-13 11:14:24 +08:00
|
|
|
leftActive?: boolean;
|
|
|
|
rightActive?: boolean;
|
2018-05-28 23:07:43 +08:00
|
|
|
style?: React.CSSProperties;
|
2018-09-15 15:18:59 +08:00
|
|
|
disabled?: boolean;
|
2020-11-04 14:12:45 +08:00
|
|
|
direction?: DirectionType;
|
2020-05-13 19:15:40 +08:00
|
|
|
oneWay?: boolean;
|
2016-07-01 20:52:17 +08:00
|
|
|
}
|
|
|
|
|
2023-01-04 15:09:03 +08:00
|
|
|
const Operation: React.FC<TransferOperationProps> = (props) => {
|
|
|
|
const {
|
|
|
|
disabled,
|
|
|
|
moveToLeft,
|
|
|
|
moveToRight,
|
|
|
|
leftArrowText = '',
|
|
|
|
rightArrowText = '',
|
|
|
|
leftActive,
|
|
|
|
rightActive,
|
|
|
|
className,
|
|
|
|
style,
|
|
|
|
direction,
|
|
|
|
oneWay,
|
|
|
|
} = props;
|
|
|
|
return (
|
|
|
|
<div className={className} style={style}>
|
2020-05-13 19:15:40 +08:00
|
|
|
<Button
|
|
|
|
type="primary"
|
|
|
|
size="small"
|
2023-01-04 15:09:03 +08:00
|
|
|
disabled={disabled || !rightActive}
|
|
|
|
onClick={moveToRight}
|
|
|
|
icon={direction !== 'rtl' ? <RightOutlined /> : <LeftOutlined />}
|
2020-05-13 19:15:40 +08:00
|
|
|
>
|
2023-01-04 15:09:03 +08:00
|
|
|
{rightArrowText}
|
2020-05-13 19:15:40 +08:00
|
|
|
</Button>
|
2023-01-04 15:09:03 +08:00
|
|
|
{!oneWay && (
|
|
|
|
<Button
|
|
|
|
type="primary"
|
|
|
|
size="small"
|
|
|
|
disabled={disabled || !leftActive}
|
|
|
|
onClick={moveToLeft}
|
|
|
|
icon={direction !== 'rtl' ? <LeftOutlined /> : <RightOutlined />}
|
|
|
|
>
|
|
|
|
{leftArrowText}
|
|
|
|
</Button>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
if (process.env.NODE_ENV !== 'production') {
|
|
|
|
Operation.displayName = 'Operation';
|
|
|
|
}
|
2019-08-05 18:38:10 +08:00
|
|
|
|
|
|
|
export default Operation;
|