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
19 KiB

1 month ago
  1. {"ast":null,"code":"import { defineComponent, inject, computed, resolveComponent, openBlock, createElementBlock, normalizeClass, createCommentVNode, createBlock, withModifiers, withCtx, createElementVNode, createVNode, Fragment } from 'vue';\nimport { ElCheckbox } from '../../checkbox/index.mjs';\nimport { ElRadio } from '../../radio/index.mjs';\nimport { ElIcon } from '../../icon/index.mjs';\nimport { Check, Loading, ArrowRight } from '@element-plus/icons-vue';\nimport NodeContent from './node-content.mjs';\nimport { CASCADER_PANEL_INJECTION_KEY } from './types.mjs';\nimport _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';\nimport { useNamespace } from '../../../hooks/use-namespace/index.mjs';\nconst _sfc_main = defineComponent({\n name: \"ElCascaderNode\",\n components: {\n ElCheckbox,\n ElRadio,\n NodeContent,\n ElIcon,\n Check,\n Loading,\n ArrowRight\n },\n props: {\n node: {\n type: Object,\n required: true\n },\n menuId: String\n },\n emits: [\"expand\"],\n setup(props, {\n emit\n }) {\n const panel = inject(CASCADER_PANEL_INJECTION_KEY);\n const ns = useNamespace(\"cascader-node\");\n const isHoverMenu = computed(() => panel.isHoverMenu);\n const multiple = computed(() => panel.config.multiple);\n const checkStrictly = computed(() => panel.config.checkStrictly);\n const checkedNodeId = computed(() => {\n var _a;\n return (_a = panel.checkedNodes[0]) == null ? void 0 : _a.uid;\n });\n const isDisabled = computed(() => props.node.isDisabled);\n const isLeaf = computed(() => props.node.isLeaf);\n const expandable = computed(() => checkStrictly.value && !isLeaf.value || !isDisabled.value);\n const inExpandingPath = computed(() => isInPath(panel.expandingNode));\n const inCheckedPath = computed(() => checkStrictly.value && panel.checkedNodes.some(isInPath));\n const isInPath = node => {\n var _a;\n const {\n level,\n uid\n } = props.node;\n return ((_a = node == null ? void 0 : node.pathNodes[level - 1]) == null ? void 0 : _a.uid) === uid;\n };\n const doExpand = () => {\n if (inExpandingPath.value) return;\n panel.expandNode(props.node);\n };\n const doCheck = checked => {\n const {\n node\n } = props;\n if (checked === node.checked) return;\n panel.handleCheckChange(node, checked);\n };\n const doLoad = () => {\n panel.lazyLoad(props.node, () => {\n if (!isLeaf.value) doExpand();\n });\n };\n const handleHoverExpand = e => {\n if (!isHoverMenu.value) return;\n handleExpand();\n !isLeaf.value && emit(\"expand\", e);\n };\n const handleExpand = () => {\n const {\n node\n } = props;\n if (!expandable.value || node.loading) return;\n node.loaded ? doExpand() : doLoad();\n };\n const handleClick = () => {\n if (isHoverMenu.value && !isLeaf.value) return;\n if (isLeaf.value && !isDisabled.value && !checkStrictly.value && !multiple.value) {\n handleCheck(true);\n } else {\n handleExpand();\n }\n };\n const handleSelectCheck = checked => {\n if (checkStrictly.value) {\n doCheck(checked);\n if (props.node.loaded) {\n doExpand();\n }\n } else {\n handleCheck(checked);\n }\n };\n const handleCheck = checked => {\n if (!props.node.loaded) {\n doLoad();\n } else {\n doCheck(checked);\n !checkStrictly.value && doExpand();\n }\n };\n return {\n panel,\n isHoverMenu,\n multiple,\n checkStrictly,\n checkedNodeId,\n isDisabled,\n isLeaf,\n expandable,\n inExpandingPath,\n inCheckedPath,\n ns,\n handleHoverExpand,\n handleExpand,\n handleClick,\n handleCheck,\n handleSelectCheck\n };\n }\n});\nfunction _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {\n const _component_el_checkbox = resolveComponent(\"el-checkbox\");\n co