tdesign-vue
Version:
386 lines (382 loc) • 14.9 kB
JavaScript
/**
* tdesign v1.12.1
* (c) 2025 tdesign
* @license MIT
*/
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import { pick } from 'lodash-es';
import TransferList from './components/transfer-list.js';
import TransferOperations from './components/transfer-operations.js';
import mixins from '../utils/mixins.js';
import getConfigReceiverMixins from '../config-provider/config-receiver.js';
import props from './props.js';
import { TRANSFER_NAME, SOURCE, TARGET, getTransferData, filterTransferData, getDataValues, getTransferListOption } from './utils.js';
import { emitEvent } from '../utils/event.js';
import '../_chunks/dep-323b993c.js';
import '@babel/runtime/helpers/typeof';
import '../pagination/index.js';
import '../pagination/pagination.js';
import 'tdesign-icons-vue';
import '../input-number/index.js';
import '@vue/composition-api';
import '../input-number/input-number.js';
import '../button/index.js';
import '../button/button.js';
import '../loading/index.js';
import '../loading/directive.js';
import '../loading/plugin.js';
import 'vue';
import '../loading/loading.js';
import '../loading/icon/gradient.js';
import '../_common/js/loading/circle-adapter.js';
import '../_common/js/utils/setStyle.js';
import '../_common/js/utils/helper.js';
import '@babel/runtime/helpers/objectWithoutProperties';
import '@babel/runtime/helpers/slicedToArray';
import '../utils/dom.js';
import 'raf';
import '../utils/easing.js';
import '../utils/render-tnode.js';
import '@babel/runtime/helpers/readOnlyError';
import '../utils/transfer-dom.js';
import '../loading/props.js';
import '../config.js';
import '../config-provider/context.js';
import '../_common/js/global-config/default-config.js';
import '../_common/js/global-config/locale/zh_CN.js';
import '../_chunks/dep-c44a474d.js';
import '../_chunks/dep-d639fbd7.js';
import 'dayjs';
import '../_chunks/dep-3c66615e.js';
import '../config-provider/type.js';
import '../_common/js/global-config/t.js';
import '../utils/withInstall.js';
import './style/css.js';
import '../loading/type.js';
import '../button/props.js';
import '../utils/ripple.js';
import '../button/type.js';
import '../input/index.js';
import '../input/input.js';
import '../utils/helper.js';
import '../input/props.js';
import '../_common/js/log/index.js';
import '../_common/js/log/log.js';
import '../input/input-group.js';
import '../utils/map-props.js';
import '../input/type.js';
import '../input-number/props.js';
import '../input-number/useInputNumber.js';
import '../hooks/useCommonClassName.js';
import '../config-provider/useConfig.js';
import '../hooks/useVModel.js';
import '../_common/js/input-number/number.js';
import '../_common/js/input-number/large-number.js';
import '../hooks/useFormDisabled.js';
import '../hooks/useGlobalIcon.js';
import '../hooks/useConfig.js';
import '../input-number/type.js';
import '../select/index.js';
import '../select/select.js';
import '../hooks/useDefaultValue.js';
import '../hooks/tnode.js';
import '../hooks/render-tnode.js';
import '../select/props.js';
import '../popup/index.js';
import '../popup/popup.js';
import '@popperjs/core';
import '../popup/props.js';
import '../popup/container.js';
import '../popup/utils.js';
import '../popup/type.js';
import '../popup/plugin.js';
import '../tag/index.js';
import '../tag/tag.js';
import 'tinycolor2';
import '../tag/props.js';
import '../tag/check-tag.js';
import '../tag/check-tag-props.js';
import '../_common/js/common.js';
import '../hooks/index.js';
import '../hooks/slots.js';
import '../hooks/useDestroyOnClose.js';
import '../hooks/useElementLazyRender.js';
import '../_common/js/utils/observe.js';
import '../hooks/useLazyLoad.js';
import '../hooks/useResizeObserver.js';
import '../hooks/useVirtualScrollNew.js';
import '../hooks/useImagePreviewUrl.js';
import '../_common/js/upload/utils.js';
import '../tag/check-tag-group.js';
import '../tag/check-tag-group-props.js';
import '../tag/type.js';
import '../select-input/index.js';
import '../select-input/select-input.js';
import '../select-input/props.js';
import '../select-input/useSingle.js';
import '../select-input/useMultiple.js';
import '../tag-input/index.js';
import '../tag-input/tag-input.js';
import '../tag-input/props.js';
import '../tag-input/hooks/useTagScroll.js';
import '../tag-input/useTagList.js';
import '../tag-input/hooks/useHover.js';
import '../tag-input/hooks/useDragSorter.js';
import '../tag-input/type.js';
import '../tag-input/interface.js';
import '../select-input/useOverlayInnerStyle.js';
import '../select-input/type.js';
import '../common-components/fake-arrow.js';
import '../select/option.js';
import '../select/option-props.js';
import '../checkbox/index.js';
import '../checkbox/group.js';
import '../checkbox/checkbox.js';
import '../checkbox/props.js';
import '../checkbox/constants.js';
import '../checkbox/store.js';
import '@babel/runtime/helpers/classCallCheck';
import '@babel/runtime/helpers/createClass';
import '../checkbox/hooks/useKeyboardEvent.js';
import '../checkbox/checkbox-group-props.js';
import '../checkbox/type.js';
import '../select/util.js';
import '../select/select-panel.js';
import '../select/optionGroup.js';
import '../select/option-group-props.js';
import '../hooks/useVirtualScroll.js';
import '../select/hooks/useSelectOptions.js';
import '../select/type.js';
import '../input-adornment/index.js';
import '../input-adornment/input-adornment.js';
import '../input-adornment/props.js';
import '../input-adornment/type.js';
import '../pagination/props.js';
import '../pagination/pagination-mini.js';
import '../pagination/pagination-mini-props.js';
import '../pagination/type.js';
import './components/transfer-search.js';
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var _Transfer = mixins(getConfigReceiverMixins("transfer")).extend({
name: TRANSFER_NAME,
components: {
TransferList: TransferList,
TransferOperations: TransferOperations
},
model: {
prop: "value",
event: "change"
},
props: _objectSpread({}, props),
data: function data() {
return {
SOURCE: SOURCE,
TARGET: TARGET,
formDisabled: void 0
};
},
computed: {
tDisabled: function tDisabled() {
return this.formDisabled || this.disabled;
},
isTreeMode: function isTreeMode() {
var treeSlot = this.$scopedSlots.tree;
return typeof treeSlot === "function" || typeof this.tree === "function";
},
leftButtonDisabled: function leftButtonDisabled() {
return this.direction === "right";
},
rightButtonDisabled: function rightButtonDisabled() {
return this.direction === "left";
},
transferData: function transferData() {
return getTransferData(this.data, this.keys, this.isTreeMode);
},
sourceList: function sourceList() {
return filterTransferData(this.transferData, this.value, false, this.isTreeMode);
},
targetList: function targetList() {
return filterTransferData(this.transferData, this.value, true, this.isTreeMode);
},
checkedValue: function checkedValue() {
return _defineProperty(_defineProperty({}, SOURCE, getDataValues(this.sourceList, this.checked, {
isTreeMode: this.isTreeMode
})), TARGET, getDataValues(this.targetList, this.checked, {
isTreeMode: this.isTreeMode
}));
},
hasFooter: function hasFooter() {
return !!this.$scopedSlots.footer || !!this.footer;
},
showPagination: function showPagination() {
return !!this.pagination && !this.$scopedSlots.content;
},
showSearch: function showSearch() {
return !!this.search;
},
footerOption: function footerOption() {
var footer = this.footer || "";
return getTransferListOption(footer);
},
emptyOption: function emptyOption() {
return getTransferListOption(this.empty);
},
searchOption: function searchOption() {
return getTransferListOption(this.search);
},
checkAllOption: function checkAllOption() {
return getTransferListOption(this.showCheckAll);
},
disabledOption: function disabledOption() {
return getTransferListOption(this.tDisabled);
},
titleOption: function titleOption() {
return getTransferListOption(this.title);
},
paginationOption: function paginationOption() {
return getTransferListOption(this.pagination);
}
},
methods: {
transferTo: function transferTo(toDirection) {
var oldTargetValue = JSON.parse(JSON.stringify(this.value));
var newTargetValue;
var checkedValue = toDirection === TARGET ? this.checkedValue[SOURCE] : this.checkedValue[TARGET];
if (toDirection === SOURCE) {
newTargetValue = oldTargetValue.filter(function (v) {
return !checkedValue.includes(v);
});
} else if (this.targetSort === "original") {
var remainValue = this.transferData.reduce(function (acc, data) {
if (oldTargetValue.includes(data.value) && data.disabled) {
return acc.concat(data.value);
}
return acc;
}, []);
newTargetValue = getDataValues(this.transferData, oldTargetValue.concat(checkedValue), {
isTreeMode: this.isTreeMode,
remainValue: remainValue
});
} else if (this.targetSort === "unshift") {
newTargetValue = checkedValue.concat(oldTargetValue);
} else {
newTargetValue = oldTargetValue.concat(checkedValue);
}
this.handleCheckedChange([], toDirection === SOURCE ? TARGET : SOURCE);
var params = {
type: toDirection,
movedValue: checkedValue
};
emitEvent(this, "change", newTargetValue, params);
},
transferToRight: function transferToRight() {
this.transferTo(TARGET);
},
transferToLeft: function transferToLeft() {
this.transferTo(SOURCE);
},
handleCheckedChange: function handleCheckedChange(val, listType) {
var sourceChecked = listType === SOURCE ? val : this.checkedValue[SOURCE];
var targetChecked = listType === TARGET ? val : this.checkedValue[TARGET];
var checked = [].concat(_toConsumableArray(sourceChecked), _toConsumableArray(targetChecked));
var event = {
checked: checked,
sourceChecked: sourceChecked,
targetChecked: targetChecked,
type: listType
};
this.$emit("update:checked", checked);
emitEvent(this, "checked-change", event);
},
filterMethod: function filterMethod(transferList, targetValueList, needMatch) {
return transferList.filter(function (item) {
var isMatch = targetValueList.indexOf(item.value) > -1;
return needMatch ? isMatch : !isMatch;
});
},
handleScroll: function handleScroll(e, listType) {
var target = e.target;
var bottomDistance = target.scrollHeight - target.scrollTop - target.clientHeight;
var event = {
e: e,
bottomDistance: bottomDistance,
type: listType
};
emitEvent(this, "scroll", event);
},
handleSearch: function handleSearch(e) {
emitEvent(this, "search", e);
},
handlePageChange: function handlePageChange(pageInfo, listType) {
emitEvent(this, "page-change", pageInfo, {
type: listType
});
},
handleDataChange: function handleDataChange(data) {
this.$emit("change", data, null);
},
renderTransferList: function renderTransferList(listType) {
var _this = this;
var h = this.$createElement;
var scopedSlots = pick(this.$scopedSlots, ["title", "empty", "footer", "operation", "transferItem", "default"]);
return h("transfer-list", {
"attrs": {
"checkboxProps": this.checkboxProps,
"transferItem": this.transferItem,
"list-type": listType,
"title": this.titleOption[listType],
"data-source": listType === SOURCE ? this.sourceList : this.targetList,
"checked-value": this.checkedValue[listType],
"disabled": this.disabledOption[listType],
"search": this.searchOption[listType],
"pagination": this.paginationOption[listType],
"check-all": this.checkAllOption[listType],
"footer": this.footerOption[listType],
"empty": this.emptyOption[listType],
"t": this.t,
"global": this.global,
"isTreeMode": this.isTreeMode,
"currentValue": this.value,
"draggable": this.targetDraggable && listType === TARGET
},
"on": {
"checkedChange": function checkedChange(val) {
return _this.handleCheckedChange(val, listType);
},
"scroll": function scroll($event) {
return _this.handleScroll($event, listType);
},
"search": this.handleSearch,
"pageChange": function pageChange(pageInfo) {
return _this.handlePageChange(pageInfo, listType);
},
"dataChange": this.handleDataChange
},
"scopedSlots": scopedSlots
});
}
},
render: function render() {
var h = arguments[0];
return h("div", {
"class": [this.componentName, this.showSearch ? "".concat(this.componentName, "__search") : "", this.hasFooter ? "".concat(this.componentName, "__footer") : "", this.showPagination ? "".concat(this.componentName, "__pagination") : "", this.isTreeMode ? "".concat(this.componentName, "--with-tree") : ""]
}, [this.renderTransferList(SOURCE), h("transfer-operations", {
"attrs": {
"left-disabled": this.disabledOption[TARGET] || this.leftButtonDisabled || this.checkedValue[TARGET].length === 0,
"right-disabled": this.disabledOption[SOURCE] || this.rightButtonDisabled || this.checkedValue[SOURCE].length === 0,
"operation": this.operation
},
"on": {
"moveToRight": this.transferToRight,
"moveToLeft": this.transferToLeft
},
"scopedSlots": {
operation: this.$scopedSlots.operation
}
}), this.renderTransferList(TARGET)]);
}
});
export { _Transfer as default };
//# sourceMappingURL=transfer.js.map