tdesign-vue
Version:
321 lines (317 loc) • 12.6 kB
JavaScript
/**
* tdesign v1.12.1
* (c) 2025 tdesign
* @license MIT
*/
import { h as helper } from '../_chunks/dep-323b993c.js';
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import { defineComponent, computed } from '@vue/composition-api';
import { isArray, isFunction, get } from 'lodash-es';
import { Tree } from '../tree/index.js';
import props from './props.js';
import { SelectInput } from '../select-input/index.js';
import FakeArrow from '../common-components/fake-arrow.js';
import { useTNodeJSX, useTNodeDefault } from '../hooks/tnode.js';
import useTreeSelect from './useTreeSelect.js';
import '../tree/tree.js';
import '../tree/adapt.js';
import 'vue';
import '../utils/withInstall.js';
import '../hooks/useVModel.js';
import '../hooks/useDefaultValue.js';
import 'tdesign-icons-vue';
import '../checkbox/index.js';
import '../checkbox/group.js';
import '@babel/runtime/helpers/typeof';
import '@babel/runtime/helpers/slicedToArray';
import '../utils/helper.js';
import '@babel/runtime/helpers/objectWithoutProperties';
import '../checkbox/checkbox.js';
import '../checkbox/props.js';
import '../hooks/index.js';
import '../utils/render-tnode.js';
import '@babel/runtime/helpers/readOnlyError';
import '../hooks/slots.js';
import '../hooks/useCommonClassName.js';
import '../config-provider/useConfig.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 '../hooks/useConfig.js';
import '../hooks/useDestroyOnClose.js';
import '../hooks/useElementLazyRender.js';
import '../_common/js/utils/observe.js';
import '../hooks/useFormDisabled.js';
import '../hooks/useGlobalIcon.js';
import '../hooks/useLazyLoad.js';
import '../hooks/useResizeObserver.js';
import '../hooks/useVirtualScrollNew.js';
import '../hooks/useImagePreviewUrl.js';
import '../_common/js/upload/utils.js';
import '../_common/js/log/log.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 '../_common/js/common.js';
import '../checkbox/checkbox-group-props.js';
import './style/index.js';
import '../checkbox/type.js';
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/setStyle.js';
import '../_common/js/utils/helper.js';
import '../config-provider/config-receiver.js';
import '../utils/mixins.js';
import '../utils/dom.js';
import 'raf';
import '../utils/easing.js';
import '../utils/transfer-dom.js';
import '../loading/props.js';
import '../config.js';
import '../loading/type.js';
import '../_common/js/tree/tree-node.js';
import '@babel/runtime/helpers/asyncToGenerator';
import '@babel/runtime/regenerator';
import '../_common/js/tree/tree-node-model.js';
import '../_common/js/log/index.js';
import '../tree/props.js';
import '../tree/hooks/useTreeStore.js';
import '../_common/js/tree/tree-store.js';
import 'mitt';
import '../tree/hooks/useTreeStyles.js';
import '../tree/hooks/useTreeState.js';
import '../tree/hooks/useTreeAction.js';
import '../tree/util.js';
import '../tree/hooks/useTreeScroll.js';
import '../tree/hooks/useTreeNodes.js';
import '../tree/tree-item.js';
import '../tree/hooks/useItemState.js';
import '../tree/hooks/useTreeItem.js';
import '../tree/hooks/useItemEvents.js';
import '../tree/hooks/useRenderIcon.js';
import '../tree/hooks/useRenderLabel.js';
import '../tree/hooks/useRenderLine.js';
import '../tree/hooks/useRenderOperations.js';
import '../tree/hooks/useDraggable.js';
import '../tree/hooks/useTreeEvents.js';
import '../tree/hooks/useDragHandle.js';
import '../tree/tree-types.js';
import '../tree/type.js';
import '../select-input/select-input.js';
import '../popup/index.js';
import '../popup/popup.js';
import '@popperjs/core';
import '../popup/props.js';
import '../popup/container.js';
import '../utils/event.js';
import '../popup/utils.js';
import '../utils/map-props.js';
import '../popup/type.js';
import '../popup/plugin.js';
import '../select-input/props.js';
import '../select-input/useSingle.js';
import '../input/index.js';
import '../input/input.js';
import '../input/props.js';
import '../input/input-group.js';
import '../input/type.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/index.js';
import '../tag/tag.js';
import 'tinycolor2';
import '../tag/props.js';
import '../tag/check-tag.js';
import '../tag/check-tag-props.js';
import '../tag/check-tag-group.js';
import '../tag/check-tag-group-props.js';
import '../tag/type.js';
import '../tag-input/hooks/useHover.js';
import '../tag-input/hooks/useDragSorter.js';
import '../hooks/render-tnode.js';
import '../tag-input/type.js';
import '../tag-input/interface.js';
import '../select-input/useOverlayInnerStyle.js';
import '../select-input/type.js';
import './utils.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 _TreeSelect = defineComponent({
name: "TTreeSelect",
props: _objectSpread({}, props),
setup: function setup(props2, context) {
var renderTNodeJSX = useTNodeJSX();
var renderDefaultTNode = useTNodeDefault();
var treeSelectInfo = useTreeSelect(props2, context);
var dropdownInnerSize = treeSelectInfo.dropdownInnerSize,
treeSelectValue = treeSelectInfo.treeSelectValue;
var multiLimitDisabled = computed(function () {
return props2.multiple && !!props2.max && isArray(treeSelectValue.value) && props2.max <= treeSelectValue.value.length;
});
return _objectSpread(_objectSpread({}, treeSelectInfo), {}, {
dropdownInnerSize: dropdownInnerSize,
multiLimitDisabled: multiLimitDisabled,
renderTNodeJSX: renderTNodeJSX,
renderDefaultTNode: renderDefaultTNode
});
},
methods: {
renderSuffixIcon: function renderSuffixIcon() {
var h = this.$createElement;
return h(FakeArrow, {
"attrs": {
"isActive": this.innerVisible,
"disabled": this.disabled,
"overlayClassName": _defineProperty(_defineProperty({}, "".concat(this.classPrefix, "-fake-arrow--highlight"), this.innerVisible), "".concat(this.classPrefix, "-fake-arrow--disable"), this.disabled)
}
});
},
renderLabel: function renderLabel() {
var h = this.$createElement;
var label = this.renderTNodeJSX("label");
var prefixIcon = this.renderTNodeJSX("prefixIcon");
if (label && prefixIcon) {
return h("div", [label, prefixIcon]);
}
return label || prefixIcon;
},
getTreePanel: function getTreePanel() {
var _this$treeProps,
_this = this;
var h = this.$createElement;
return h("div", {
"class": ["".concat(this.classPrefix, "-select__dropdown-inner"), "".concat(this.classPrefix, "-select__dropdown-inner--size-").concat(this.dropdownInnerSize)]
}, [this.renderTNodeJSX("panelTopContent"), this.loading && !this.tDisabled ? h("p", {
"class": ["".concat(this.classPrefix, "-select__loading-tips"), "".concat(this.classPrefix, "-select__right-icon-polyfill")]
}, [this.renderDefaultTNode("loadingText", {
defaultNode: h("div", {
"class": "".concat(this.classPrefix, "-select__empty")
}, [this.global.loadingText])
})]) : null, !this.loading ? h(Tree, helper([{
"ref": "treeRef",
"key": !((_this$treeProps = this.treeProps) !== null && _this$treeProps !== void 0 && _this$treeProps.load) && this.treeKey
}, {
"props": _objectSpread({
keys: this.tKeys,
value: _toConsumableArray(this.multipleChecked),
actived: this.singleActivated,
hover: true,
data: this.data,
activable: !this.multiple,
checkable: this.multiple,
disabled: this.tDisabled || this.multiLimitDisabled,
size: this.size,
filter: this.filterByText,
icon: !this.filterByText,
activeMultiple: this.multiple,
onExpand: this.treeNodeExpand,
onLoad: this.treeNodeLoad,
onChange: this.treeNodeChange,
onActive: this.treeNodeActive,
expandOnClickNode: false,
empty: function empty() {
return _this.renderDefaultTNode("empty", {
defaultNode: h("div", {
"class": "".concat(_this.classPrefix, "-select__empty")
}, [_this.global.empty])
});
}
}, this.treeProps)
}])) : null, this.renderTNodeJSX("panelBottomContent")]);
}
},
render: function render() {
var _this2 = this;
var h = arguments[0];
var slots = this.$scopedSlots;
return h(SelectInput, {
"scopedSlots": {
tips: slots.tips,
suffix: slots.suffix,
collapsedItems: slots.collapsedItems
},
"class": "".concat(this.classPrefix, "-tree-select"),
"props": _objectSpread({}, _objectSpread({
keys: this.tKeys,
value: this.nodeInfo,
inputValue: this.innerInputValue,
popupVisible: this.innerVisible,
disabled: this.tDisabled,
multiple: this.multiple,
loading: this.loading,
clearable: this.clearable,
autofocus: this.autofocus,
autoWidth: this.autoWidth,
borderless: this.borderless,
readonly: this.readonly,
placeholder: this.inputPlaceholder,
status: this.status,
tips: this.tips,
suffix: this.suffix,
allowInput: Boolean(this.filterable || isFunction(this.filter) || this.$listeners.search || this.onSearch),
minCollapsedNum: this.minCollapsedNum,
collapsedItems: this.collapsedItems,
popupProps: _objectSpread({
overlayClassName: this.popupClass
}, this.popupProps),
inputProps: _objectSpread({
size: this.size
}, this.inputProps),
tagInputProps: {
size: this.size
},
tagProps: _objectSpread({
maxWidth: 300
}, this.tagProps),
label: this.renderLabel,
suffixIcon: this.renderSuffixIcon,
onClear: this.clear,
onBlur: this.onInnerBlur,
onFocus: this.onInnerFocus,
onInputChange: this.inputChange,
onTagChange: this.tagChange,
onEnter: this.onInnerEnter,
onPopupVisibleChange: this.onInnerPopupVisibleChange,
valueDisplay: function valueDisplay() {
return _this2.renderTNodeJSX("valueDisplay", {
params: _this2.multiple ? {
value: _this2.nodeInfo,
onClose: function onClose(index) {
var value = _this2.nodeInfo.map(function (node) {
return get(node, _this2.tKeys.value);
});
_this2.tagChange(value, {
trigger: "tag-remove",
index: index,
item: value[index]
});
}
} : {
value: _this2.nodeInfo || _defineProperty(_defineProperty({}, _this2.tKeys.label, ""), _this2.tKeys.value, void 0)
}
});
},
panel: this.getTreePanel
}, this.selectInputProps))
});
}
});
export { _TreeSelect as default };
//# sourceMappingURL=tree-select.js.map