You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

0 lines
32 KiB

1 month ago
  1. {"ast":null,"code":"import { defineComponent, inject, ref, getCurrentInstance, provide, watch, nextTick, resolveComponent, withDirectives, openBlock, createElementBlock, normalizeClass, withModifiers, createElementVNode, normalizeStyle, createBlock, withCtx, resolveDynamicComponent, createCommentVNode, createVNode, Fragment, renderList, vShow } from 'vue';\nimport { ElCollapseTransition } from '../../collapse-transition/index.mjs';\nimport { ElCheckbox } from '../../checkbox/index.mjs';\nimport { ElIcon } from '../../icon/index.mjs';\nimport { Loading, CaretRight } from '@element-plus/icons-vue';\nimport NodeContent from './tree-node-content.mjs';\nimport { getNodeKey, handleCurrentChange } from './model/util.mjs';\nimport { useNodeExpandEventBroadcast } from './model/useNodeExpandEventBroadcast.mjs';\nimport { dragEventsKey } from './model/useDragNode.mjs';\nimport Node from './model/node.mjs';\nimport _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';\nimport { useNamespace } from '../../../hooks/use-namespace/index.mjs';\nimport { debugWarn } from '../../../utils/error.mjs';\nimport { isFunction, isString } from '@vue/shared';\nconst _sfc_main = defineComponent({\n name: \"ElTreeNode\",\n components: {\n ElCollapseTransition,\n ElCheckbox,\n NodeContent,\n ElIcon,\n Loading\n },\n props: {\n node: {\n type: Node,\n default: () => ({})\n },\n props: {\n type: Object,\n default: () => ({})\n },\n accordion: Boolean,\n renderContent: Function,\n renderAfterExpand: Boolean,\n showCheckbox: {\n type: Boolean,\n default: false\n }\n },\n emits: [\"node-expand\"],\n setup(props, ctx) {\n const ns = useNamespace(\"tree\");\n const {\n broadcastExpanded\n } = useNodeExpandEventBroadcast(props);\n const tree = inject(\"RootTree\");\n const expanded = ref(false);\n const childNodeRendered = ref(false);\n const oldChecked = ref(null);\n const oldIndeterminate = ref(null);\n const node$ = ref(null);\n const dragEvents = inject(dragEventsKey);\n const instance = getCurrentInstance();\n provide(\"NodeInstance\", instance);\n if (!tree) {\n debugWarn(\"Tree\", \"Can not find node's tree.\");\n }\n if (props.node.expanded) {\n expanded.value = true;\n childNodeRendered.value = true;\n }\n const childrenKey = tree.props.props[\"children\"] || \"children\";\n watch(() => {\n const children = props.node.data[childrenKey];\n return children && [...children];\n }, () => {\n props.node.updateChildren();\n });\n watch(() => props.node.indeterminate, val => {\n handleSelectChange(props.node.checked, val);\n });\n watch(() => props.node.checked, val => {\n handleSelectChange(val, props.node.indeterminate);\n });\n watch(() => props.node.childNodes.length, () => props.node.reInitChecked());\n watch(() => props.node.expanded, val => {\n nextTick(() => expanded.value = val);\n if (val) {\n childNodeRendered.value = true;\n }\n });\n const getNodeKey$1 = node => {\n return getNodeKey(tree.props.nodeKey, node.data);\n };\n const getNodeClass = node => {\n const nodeClassFunc = props.props.class;\n if (!nodeClassFunc) {\n return {};\n }\n let className;\n if (isFunction(nodeClassFunc)) {\n const {\n data\n } = node;\n className = nodeClassFunc(data, node);\n } else {\n className = nodeClassFunc;\n }\n if (isString(className)) {\n return {\n [className]: true\n };\n } else {\n return className;\n }\n };\n const handleSelectChange = (checked, indeterminate) => {\n if (oldChecked.value !== checked || oldIndeterminate.value !== indeterminate) {\n tree.ctx.emit(\"check-change\", props.node.data, checked, indeterminate);\n }\n oldChecked.value = checked;\n oldIndeterminate.value = indeterminate;\n };\n const handleClick = e => {\n handle