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.

1 line
14 KiB

{"ast":null,"code":"import { defineComponent, getCurrentInstance, inject, ref, computed, resolveComponent, openBlock, createBlock, normalizeClass, withCtx, createElementBlock, Fragment, renderList, createVNode, createTextVNode, toDisplayString, renderSlot, createCommentVNode } from 'vue';\nimport { ElScrollbar } from '../../scrollbar/index.mjs';\nimport '../../../hooks/index.mjs';\nimport { Loading } from '@element-plus/icons-vue';\nimport { ElIcon } from '../../icon/index.mjs';\nimport ElCascaderNode from './node2.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';\nimport { useLocale } from '../../../hooks/use-locale/index.mjs';\nimport { useId } from '../../../hooks/use-id/index.mjs';\nconst _sfc_main = defineComponent({\n name: \"ElCascaderMenu\",\n components: {\n Loading,\n ElIcon,\n ElScrollbar,\n ElCascaderNode\n },\n props: {\n nodes: {\n type: Array,\n required: true\n },\n index: {\n type: Number,\n required: true\n }\n },\n setup(props) {\n const instance = getCurrentInstance();\n const ns = useNamespace(\"cascader-menu\");\n const {\n t\n } = useLocale();\n const id = useId();\n let activeNode = null;\n let hoverTimer = null;\n const panel = inject(CASCADER_PANEL_INJECTION_KEY);\n const hoverZone = ref(null);\n const isEmpty = computed(() => !props.nodes.length);\n const isLoading = computed(() => !panel.initialLoaded);\n const menuId = computed(() => `${id.value}-${props.index}`);\n const handleExpand = e => {\n activeNode = e.target;\n };\n const handleMouseMove = e => {\n if (!panel.isHoverMenu || !activeNode || !hoverZone.value) return;\n if (activeNode.contains(e.target)) {\n clearHoverTimer();\n const el = instance.vnode.el;\n const {\n left\n } = el.getBoundingClientRect();\n const {\n offsetWidth,\n offsetHeight\n } = el;\n const startX = e.clientX - left;\n const top = activeNode.offsetTop;\n const bottom = top + activeNode.offsetHeight;\n hoverZone.value.innerHTML = `\n <path style=\"pointer-events: auto;\" fill=\"transparent\" d=\"M${startX} ${top} L${offsetWidth} 0 V${top} Z\" />\n <path style=\"pointer-events: auto;\" fill=\"transparent\" d=\"M${startX} ${bottom} L${offsetWidth} ${offsetHeight} V${bottom} Z\" />\n `;\n } else if (!hoverTimer) {\n hoverTimer = window.setTimeout(clearHoverZone, panel.config.hoverThreshold);\n }\n };\n const clearHoverTimer = () => {\n if (!hoverTimer) return;\n clearTimeout(hoverTimer);\n hoverTimer = null;\n };\n const clearHoverZone = () => {\n if (!hoverZone.value) return;\n hoverZone.value.innerHTML = \"\";\n clearHoverTimer();\n };\n return {\n ns,\n panel,\n hoverZone,\n isEmpty,\n isLoading,\n menuId,\n t,\n handleExpand,\n handleMouseMove,\n clearHoverZone\n };\n }\n});\nfunction _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {\n const _component_el_cascader_node = resolveComponent(\"el-cascader-node\");\n const _component_loading = resolveComponent(\"loading\");\n const _component_el_icon = resolveComponent(\"el-icon\");\n const _component_el_scrollbar = resolveComponent(\"el-scrollbar\");\n return openBlock(), createBlock(_component_el_scrollbar, {\n key: _ctx.menuId,\n tag: \"ul\",\n role: \"menu\",\n class: normalizeClass(_ctx.ns.b()),\n \"wrap-class\": _ctx.ns.e(\"wrap\"),\n \"view-class\": [_ctx.ns.e(\"list\"), _ctx.ns.is(\"empty\", _ctx.isEmpty)],\n onMousemove: _ctx.handleMouseMove,\n onMouseleave: _ctx.clearHoverZone\n }, {\n default: withCtx(() => {\n var _a;\n return [(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.nodes, node => {\n return openBlock(), createBlock(_component_el_cascader_node, {\n key: node.uid,\n node,\n \"menu-id\": _ctx.menuId,\n onExpand: _ctx.handleExpand\n }, null, 8, [\"node\", \"menu-id\", \"onExpand\"]);\n }), 128)), _ctx.isLoading ? (openBlock(), createElementBlock(\"div\", {\n key: 0,\n class: normalizeClass(_ctx.ns.e(\"empty-text\"))\n }, [createVNode(_component_el_icon, {\n size: \"14\",\n class: normalizeClass(_ctx.ns.is(\"loading\"))\n }, {\n default: withCtx(() => [createVNode(_component_loading)]),\n _: 1\n }, 8, [\"class\"]), createTextVNode(\" \" + toDisplayString(_ctx.t(\"el.cascader.loading\")), 1)], 2)) : _ctx.isEmpty ? (openBlock(), createElementBlock(\"div\", {\n key: 1,\n class: normalizeClass(_ctx.ns.e(\"empty-text\"))\n }, [renderSlot(_ctx.$slots, \"empty\", {}, () => [createTextVNode(toDisplayString(_ctx.t(\"el.cascader.noData\")), 1)])], 2)) : ((_a = _ctx.panel) == null ? void 0 : _a.isHoverMenu) ? (openBlock(), createElementBlock(\"svg\", {\n key: 2,\n ref: \"hoverZone\",\n class: normalizeClass(_ctx.ns.e(\"hover-zone\"))\n }, null, 2)) : createCommentVNode(\"v-if\", true)];\n }),\n _: 3\n }, 8, [\"class\", \"wrap-class\", \"view-class\", \"onMousemove\", \"onMouseleave\"]);\n}\nvar ElCascaderMenu = /* @__PURE__ */_export_sfc(_sfc_main, [[\"render\", _sfc_render], [\"__file\", \"menu.vue\"]]);\nexport { ElCascaderMenu as default };","map":{"version":3,"names":["_sfc_main","defineComponent","name","components","Loading","ElIcon","ElScrollbar","ElCascaderNode","props","nodes","type","Array","required","index","Number","setup","instance","getCurrentInstance","ns","useNamespace","t","useLocale","id","useId","activeNode","hoverTimer","panel","inject","CASCADER_PANEL_INJECTION_KEY","hoverZone","ref","isEmpty","computed","length","isLoading","initialLoaded","menuId","value","handleExpand","e","target","handleMouseMove","isHoverMenu","contains","clearHoverTimer","el","vnode","left","getBoundingClientRect","offsetWidth","offsetHeight","startX","clientX","top","offsetTop","bottom","innerHTML","window","setTimeout","clearHoverZone","config","hoverThreshold","clearTimeout","createBlock","_component_el_scrollbar","key","_ctx","tag","role","class","normalizeClass","b","is","onMousemove","onMouseleave","_a","openBlock","createElementBlock","Fragment","renderList","node","_component_el_cascader_node","onExpand","createVNode","_component_el_icon","size","default","withCtx","_component_loading","_","createTextVNode","toDisplayString","createCommentVNode","ElCascaderMenu","_export_sfc","_sfc_render"],"sources":["../../../../../../packages/components/cascader-panel/src/menu.vue"],"sourcesContent":["<template>\n <el-scrollbar\n :key=\"menuId\"\n tag=\"ul\"\n role=\"menu\"\n :class=\"ns.b()\"\n :wrap-class=\"ns.e('wrap')\"\n :view-class=\"[ns.e('list'), ns.is('empty', isEmpty)]\"\n @mousemove=\"handleMouseMove\"\n @mouseleave=\"clearHoverZone\"\n >\n <el-cascader-node\n v-for=\"node in nodes\"\n :key=\"node.uid\"\n :node=\"node\"\n :menu-id=\"menuId\"\n @expand=\"handleExpand\"\n />\n <div v-if=\"isLoading\" :class=\"ns.e('empty-text')\">\n <el-icon size=\"14\" :class=\"ns.is('loading')\">\n <loading />\n </el-icon>\n {{ t('el.cascader.loading') }}\n </div>\n <div v-else-if=\"isEmpty\" :class=\"ns.e('empty-text')\">\n <slot name=\"empty\">{{ t('el.cascader.noData') }}</slot>\n </div>\n <svg\n v-else-if=\"panel?.isHoverMenu\"\n ref=\"hoverZone\"\n :class=\"ns.e('hover-zone')\"\n />\n </el-scrollbar>\n</template>\n\n<script lang=\"ts\">\nimport { computed, defineComponent, getCurrentInstance, inject, ref } from 'vue'\nimport ElScrollbar from '@element-plus/components/scrollbar'\nimport { useId, useLocale, useNamespace } from '@element-plus/hooks'\nimport { Loading } from '@element-plus/icons-vue'\nimport ElIcon from '@element-plus/components/icon'\nimport ElCascaderNode from './node.vue'\nimport { CASCADER_PANEL_INJECTION_KEY } from './types'\n\nimport type { default as CascaderNode } from './node'\nimport type { PropType } from 'vue'\nimport type { Nullable } from '@element-plus/utils'\n\nexport default defineComponent({\n name: 'ElCascaderMenu',\n\n components: {\n Loading,\n ElIcon,\n ElScrollbar,\n ElCascaderNode,\n },\n\n props: {\n nodes: {\n type: Array as PropType<CascaderNode[]>,\n required: true,\n },\n index: {\n type: Number,\n required: true,\n },\n },\n\n setup(props) {\n const instance = getCurrentInstance()!\n const ns = useNamespace('cascader-menu')\n\n const { t } = useLocale()\n const id = useId()\n let activeNode: Nullable<HTMLElement> = null\n let hoverTimer: Nullable<number> = null\n\n const panel = inject(CASCADER_PANEL_INJECTION_KEY)!\n\n const hoverZone = ref<null | SVGSVGElement>(null)\n\n const isEmpty = computed(() => !props.nodes.length)\n const isLoading = computed(() => !panel.initialLoaded)\n const menuId = computed(() => `${id.value}-${props.index}`)\n\n const handleExpand = (e: MouseEvent) => {\n activeNode = e.target as HTMLElement\n }\n\n const handleMouseMove = (e: MouseEvent) => {\n if (!panel.isHoverMenu || !activeNode || !hoverZone.value) return\n\n if (activeNode.contains(e.target as HTMLElement)) {\n clearHoverTimer()\n\n const el = instance.vnode.el as HTMLElement\n const { left } = el.getBoundingClientRect()\n const { offsetWidth, offsetHeight } = el\n const startX = e.clientX - left\n const top = activeNode.offsetTop\n const bottom = top + activeNode.offsetHeight\n\n hoverZone.value.innerHTML = `\n <path style=\"pointer-events: auto;\" fill=\"transparent\" d=\"M${startX} ${top} L${offsetWidth} 0 V${top} Z\" />\n <path style=\"pointer-events: auto;\" fill=\"transparent\" d=\"M${startX} ${bottom} L${offsetWidth} ${offsetHeight} V${bottom} Z\" />\n `\n } else if (!hoverTimer) {\n hoverTimer = window.setTimeout(\n clearHoverZone,\n panel.config.hoverThreshold\n )\n }\n }\n\n const clearHoverTimer = () => {\n if (!hoverTimer) return\n clearTimeout(hoverTimer)\n hoverTimer = null\n }\n\n const clearHoverZone = () => {\n if (!hoverZone.value) return\n hoverZone.value.innerHTML = ''\n clearHoverTimer()\n }\n return {\n ns,\n panel,\n hoverZone,\n isEmpty,\n isLoading,\n menuId,\n t,\n handleExpand,\n handleMouseMove,\n clearHoverZone,\n }\n },\n})\n</script>\n"],"mappings":";;;;;;;;;;;AAgDA,MAAKA,SAAA,GAAaC,eAAa;EAC7BC,IAAM;EAENC,UAAY;IACVC,OAAA;IACAC,MAAA;IACAC,WAAA;IACAC;EAAA,CACF;EAEAC,KAAO;IACLC,KAAO;MACLC,IAAM,EAAAC,KAAA;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