xdesign-vue-next
Version:
XDesign Component for vue-next
165 lines (161 loc) • 5.71 kB
JavaScript
/**
* xdesign v1.0.6
* (c) 2023 xdesign
* @license MIT
*/
import { _ as __unplugin_components_2 } from '../../_chunks/dep-9beabfae.js';
import { _ as __unplugin_components_3 } from '../../_chunks/dep-17236cae.js';
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
import { defineComponent, createVNode, isVNode, h } from 'vue';
import { Button } from '../../button/index.js';
import { usePrefixClass } from '../../hooks/useConfig.js';
import props from '../props.js';
import isFunction from 'lodash/isFunction';
import isString from 'lodash/isString';
import isArray from 'lodash/isArray';
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 '../../_common/js/loading/circle-adapter.js';
import '../../_common/js/utils/set-style.js';
import '../../_common/js/utils/helper.js';
import '@babel/runtime/helpers/objectWithoutProperties';
import 'lodash/isNull';
import 'lodash/isUndefined';
import 'lodash/isNumber';
import '../../utils/dom.js';
import '../../_chunks/dep-3a1cce9f.js';
import '../../utils/easing.js';
import '../../utils/render-tnode.js';
import 'lodash/isEmpty';
import 'lodash/isObject';
import 'lodash/camelCase';
import 'lodash/kebabCase';
import '../../loading/props.js';
import '../../hooks/useTeleport.js';
import '../../config-provider/useConfig.js';
import 'lodash/cloneDeep';
import '../../config-provider/context.js';
import 'lodash/mergeWith';
import 'lodash/merge';
import '../../_common/js/global-config/default-config.js';
import '../../_common/js/global-config/locale/en_US.js';
import '../../utils/withInstall.js';
import '../../button/props.js';
import '../../hooks/useRipple.js';
import '../../hooks/useKeepAnimation.js';
import '../../utils/set-style.js';
import '../../hooks/tnode.js';
import '../../hooks/useDisabled.js';
import 'lodash/isBoolean';
function _isSlot(s) {
return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !isVNode(s);
}
var TransferOperations = defineComponent({
name: "XTransferOperations",
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 moveToRight = function moveToRight() {
emit("moveToRight");
};
var moveToLeft = function moveToLeft() {
emit("moveToLeft");
};
var getIconRight = function getIconRight() {
return createVNode(__unplugin_components_3, null, null);
};
var getIconLeft = function getIconLeft() {
return createVNode(__unplugin_components_2, 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 () {
var _slot, _slot2;
var _props2$operation2, _props2$operation3;
return createVNode("div", {
"class": "".concat(classPrefix.value, "-transfer__operations")
}, [createVNode(Button, {
"variant": "outline",
"size": "small",
"shape": isString((_props2$operation2 = props2.operation) === null || _props2$operation2 === void 0 ? void 0 : _props2$operation2[1]) ? "rectangle" : "square",
"key": props2.rightDisabled ? "right-outline" : "right-base",
"disabled": props2.rightDisabled,
"onClick": moveToRight,
"icon": getIcon("right")
}, _isSlot(_slot = renderButton(h, "right")) ? _slot : {
"default": function _default() {
return [_slot];
}
}), createVNode(Button, {
"variant": "outline",
"size": "small",
"shape": isString((_props2$operation3 = props2.operation) === null || _props2$operation3 === void 0 ? void 0 : _props2$operation3[0]) ? "rectangle" : "square",
"key": props2.rightDisabled ? "left-outline" : "left-base",
"disabled": props2.leftDisabled,
"onClick": moveToLeft,
"icon": getIcon("left")
}, _isSlot(_slot2 = renderButton(h, "left")) ? _slot2 : {
"default": function _default() {
return [_slot2];
}
})]);
};
}
});
export { TransferOperations as default };
//# sourceMappingURL=transfer-operations.js.map