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

60 lines
1.3 KiB
Vue
Raw Normal View History

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