tdesign-vue-next
Version:
TDesign Component for vue-next
151 lines (147 loc) • 5.19 kB
JavaScript
/**
* tdesign v1.11.5
* (c) 2025 tdesign
* @license MIT
*/
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
import { defineComponent, createVNode, h } from 'vue';
import { ChevronRightIcon, ChevronLeftIcon } from 'tdesign-icons-vue-next';
import { Button } from '../../button/index.js';
import { usePrefixClass } from '../../hooks/useConfig.js';
import { useGlobalIcon } from '../../hooks/useGlobalIcon.js';
import props from '../props.js';
import { isArray, isString, isFunction } from 'lodash-es';
import '../../button/button.js';
import '@babel/runtime/helpers/toConsumableArray';
import '@babel/runtime/helpers/defineProperty';
import '../../loading/index.js';
import '../../loading/directive.js';
import '../../loading/plugin.js';
import '../../loading/loading.js';
import '../../loading/icon/gradient.js';
import '../../_chunks/dep-d60f6309.js';
import '../../_chunks/dep-56c3d46e.js';
import '@babel/runtime/helpers/objectWithoutProperties';
import '../../utils/dom.js';
import '../../_chunks/dep-caecb55d.js';
import '../../_chunks/dep-7c56a7f5.js';
import '../../utils/render-tnode.js';
import '../../hooks/useTeleport.js';
import '../../loading/props.js';
import '../../config-provider/hooks/useConfig.js';
import '../../config-provider/utils/context.js';
import '../../_chunks/dep-c75b9b8e.js';
import '@babel/runtime/helpers/typeof';
import 'dayjs';
import '../../utils/withInstall.js';
import '../../button/props.js';
import '../../hooks/useRipple.js';
import '../../hooks/useKeepAnimation.js';
import '../../hooks/useDisabled.js';
var TransferOperations = defineComponent({
name: "TTransferOperations",
props: {
leftDisabled: {
type: Boolean,
required: true
},
rightDisabled: {
type: Boolean,
required: true
},
operation: props.operation
},
emits: ["moveToRight", "moveToLeft"],
setup: function setup(props2, _ref) {
var slots = _ref.slots,
emit = _ref.emit;
var classPrefix = usePrefixClass();
var _useGlobalIcon = useGlobalIcon({
ChevronRightIcon: ChevronRightIcon,
ChevronLeftIcon: ChevronLeftIcon
}),
ChevronRightIcon$1 = _useGlobalIcon.ChevronRightIcon,
ChevronLeftIcon$1 = _useGlobalIcon.ChevronLeftIcon;
var moveToRight = function moveToRight() {
emit("moveToRight");
};
var moveToLeft = function moveToLeft() {
emit("moveToLeft");
};
var getIconRight = function getIconRight() {
return createVNode(ChevronRightIcon$1, null, null);
};
var getIconLeft = function getIconLeft() {
return createVNode(ChevronLeftIcon$1, null, null);
};
var getIcon = function getIcon(direction) {
if (isFunction(props2.operation)) {
return null;
}
if (direction === "right" && props2.operation && isFunction(props2.operation[0])) {
return null;
}
if (direction === "left" && props2.operation && isFunction(props2.operation[1])) {
return null;
}
if (slots.operation) {
return null;
}
return direction === "left" ? getIconLeft : getIconRight;
};
var renderButton = function renderButton(h2, direction) {
if (isFunction(slots.operation)) {
return slots.operation({
direction: direction
});
}
if (isFunction(props2.operation)) {
var renderContent2 = props2.operation;
return renderContent2(h2, {
direction: direction
});
}
var renderContent;
if (isArray(props2.operation)) {
var _props2$operation = _slicedToArray(props2.operation, 2),
left = _props2$operation[0],
right = _props2$operation[1];
renderContent = direction === "right" ? right : left;
} else {
renderContent = "";
}
return renderContent;
};
return function () {
return createVNode("div", {
"class": "".concat(classPrefix.value, "-transfer__operations")
}, [createVNode(Button, {
"variant": "outline",
"size": "small",
"shape": isArray(props2.operation) && isString(props2.operation[1]) ? "rectangle" : "square",
"key": props2.rightDisabled ? "right-outline" : "right-base",
"disabled": props2.rightDisabled,
"onClick": moveToRight,
"icon": getIcon("right")
}, {
"default": function _default() {
return [slots.operation || isArray(props2.operation) && props2.operation[1] ? renderButton(h, "right") : null];
}
}), createVNode(Button, {
"variant": "outline",
"size": "small",
"shape": isArray(props2.operation) && isString(props2.operation[0]) ? "rectangle" : "square",
"key": props2.rightDisabled ? "left-outline" : "left-base",
"disabled": props2.leftDisabled,
"onClick": moveToLeft,
"icon": getIcon("left")
}, {
"default": function _default() {
return [slots.operation || isArray(props2.operation) && props2.operation[0] ? renderButton(h, "left") : null];
}
})]);
};
}
});
export { TransferOperations as default };
//# sourceMappingURL=transfer-operations.js.map