ant-design-vue/components/transfer/operation.tsx

60 lines
1.3 KiB
Vue
Raw Normal View History

2020-10-20 16:45:49 +08:00
import { CSSProperties, FunctionalComponent } from 'vue';
2020-03-28 15:52:26 +08:00
import LeftOutlined from '@ant-design/icons-vue/LeftOutlined';
import RightOutlined from '@ant-design/icons-vue/RightOutlined';
2019-01-12 11:33:27 +08:00
import Button from '../button';
2018-04-07 00:20:45 +08:00
2019-01-12 11:33:27 +08:00
function noop() {}
2018-04-07 00:20:45 +08:00
2020-10-20 16:45:49 +08:00
export interface TransferOperationProps {
class?: any;
leftArrowText?: string;
rightArrowText?: string;
moveToLeft?: (e: MouseEvent) => void;
moveToRight?: (e: MouseEvent) => void;
leftActive?: boolean;
rightActive?: boolean;
style?: CSSProperties | string;
disabled?: boolean;
}
const Operation: FunctionalComponent<TransferOperationProps> = props => {
2020-07-19 22:40:35 +08:00
const {
disabled,
moveToLeft = noop,
moveToRight = noop,
leftArrowText = '',
rightArrowText = '',
leftActive,
rightActive,
class: className,
style,
2020-10-20 16:45:49 +08:00
} = props;
2018-04-07 00:20:45 +08:00
2020-07-19 22:40:35 +08:00
return (
<div class={className} style={style}>
2020-08-05 17:17:07 +08:00
<Button
type="primary"
size="small"
disabled={disabled || !rightActive}
onClick={moveToRight}
icon={<RightOutlined />}
>
2020-07-19 22:40:35 +08:00
{rightArrowText}
</Button>
2020-08-05 17:17:07 +08:00
<Button
type="primary"
size="small"
disabled={disabled || !leftActive}
onClick={moveToLeft}
icon={<LeftOutlined />}
>
2020-07-19 22:40:35 +08:00
{leftArrowText}
</Button>
</div>
);
2019-01-12 11:33:27 +08:00
};
2020-10-20 16:45:49 +08:00
2020-07-19 22:40:35 +08:00
Operation.inheritAttrs = false;
export default Operation;