tdesign-vue
Version:
146 lines (142 loc) • 5.1 kB
JavaScript
/**
* tdesign v1.12.1
* (c) 2025 tdesign
* @license MIT
*/
import '../adapt.js';
import { getTNode } from '../util.js';
import { usePrefixClass } from '../../hooks/useConfig.js';
import { useGlobalIcon } from '../../hooks/useGlobalIcon.js';
import { CaretRightSmallIcon } from 'tdesign-icons-vue';
import { Loading } from '../../loading/index.js';
import '@vue/composition-api';
import 'vue';
import '../../utils/withInstall.js';
import '@babel/runtime/helpers/defineProperty';
import 'lodash-es';
import '../../hooks/useVModel.js';
import '../../hooks/useDefaultValue.js';
import '../../checkbox/index.js';
import '../../checkbox/group.js';
import '../../_chunks/dep-323b993c.js';
import '@babel/runtime/helpers/typeof';
import '@babel/runtime/helpers/toConsumableArray';
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/useDestroyOnClose.js';
import '../../hooks/useElementLazyRender.js';
import '../../_common/js/utils/observe.js';
import '../../hooks/useFormDisabled.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 '../../_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 '../../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';
function useRenderIcon(state) {
var classPrefix = usePrefixClass().value;
var componentName = usePrefixClass("tree").value;
var getFolderIcon = function getFolderIcon(h) {
var _useGlobalIcon = useGlobalIcon({
CaretRightSmallIcon: CaretRightSmallIcon
}),
CaretRightSmallIcon$1 = _useGlobalIcon.CaretRightSmallIcon;
return h(CaretRightSmallIcon$1);
};
var handleMousedown = function handleMousedown(evt) {
evt.preventDefault();
};
var renderIcon = function renderIcon(h) {
var node = state.node,
treeScope = state.treeScope;
var scopedSlots = treeScope.scopedSlots;
var treeProps = (treeScope === null || treeScope === void 0 ? void 0 : treeScope.treeProps) || {};
var icon = treeProps.icon;
var isDefaultIcon = false;
var iconNode = null;
if (icon === true) {
if (scopedSlots !== null && scopedSlots !== void 0 && scopedSlots.icon) {
iconNode = scopedSlots.icon({
node: node === null || node === void 0 ? void 0 : node.getModel()
});
} else if (!node.vmIsLeaf) {
isDefaultIcon = true;
iconNode = getFolderIcon(h);
if (node.loading && node.expanded) {
iconNode = h(Loading);
}
} else {
iconNode = "";
}
} else if (icon) {
iconNode = getTNode(icon, {
createElement: h,
node: node
});
}
var wrapIconNode = h("span", {
"class": ["".concat(componentName, "__icon"), "".concat(classPrefix, "-folder-icon"), isDefaultIcon ? "".concat(componentName, "__icon--default") : ""],
"attrs": {
"trigger": "expand",
"ignore": "active"
},
"on": {
"mousedown": handleMousedown
}
}, [iconNode]);
return wrapIconNode;
};
return {
renderIcon: renderIcon
};
}
export { useRenderIcon as default };
//# sourceMappingURL=useRenderIcon.js.map