{"version":3,"file":"node2.mjs","sources":["../../../../../../packages/components/cascader-panel/src/node.vue"],"sourcesContent":["<template>\r\n  <li\r\n    :id=\"`${menuId}-${node.uid}`\"\r\n    role=\"menuitem\"\r\n    :aria-haspopup=\"!isLeaf\"\r\n    :aria-owns=\"isLeaf ? undefined : menuId\"\r\n    :aria-expanded=\"inExpandingPath\"\r\n    :tabindex=\"expandable ? -1 : undefined\"\r\n    :class=\"[\r\n      'sg-cascader-node',\r\n      checkStrictly && 'is-selectable',\r\n      inExpandingPath && 'in-active-path',\r\n      inCheckedPath && 'in-checked-path',\r\n      node.checked && 'is-active',\r\n      !expandable && 'is-disabled',\r\n    ]\"\r\n    @mouseenter=\"handleHoverExpand\"\r\n    @focus=\"handleHoverExpand\"\r\n    @click=\"handleClick\"\r\n  >\r\n    <!-- prefix -->\r\n    <sg-checkbox\r\n      v-if=\"multiple\"\r\n      :model-value=\"node.checked\"\r\n      :indeterminate=\"node.indeterminate\"\r\n      :disabled=\"isDisabled\"\r\n      @click.stop\r\n      @update:model-value=\"handleSelectCheck\"\r\n    />\r\n    <sg-radio\r\n      v-else-if=\"checkStrictly\"\r\n      :model-value=\"checkedNodeId\"\r\n      :label=\"node.uid\"\r\n      :disabled=\"isDisabled\"\r\n      @update:model-value=\"handleSelectCheck\"\r\n      @click.stop\r\n    >\r\n      <!--\r\n        Add an empty element to avoid render label,\r\n        do not use empty fragment here for https://github.com/vuejs/vue-next/pull/2485\r\n      -->\r\n      <span></span>\r\n    </sg-radio>\r\n    <sg-icon\r\n      v-else-if=\"isLeaf && node.checked\"\r\n      class=\"sg-cascader-node__prefix\"\r\n    >\r\n<!--      <finish />-->\r\n    </sg-icon>\r\n\r\n    <!-- content -->\r\n    <node-content />\r\n\r\n    <!-- postfix -->\r\n    <template v-if=\"!isLeaf\">\r\n      <sg-icon v-if=\"node.loading\" class=\"is-loading sg-cascader-node__postfix\">\r\n<!--        <loading1 />-->\r\n      </sg-icon>\r\n      <sg-icon v-else class=\"arrow-right sg-cascader-node__postfix\">\r\n        <ArrowRight />\r\n      </sg-icon>\r\n    </template>\r\n  </li>\r\n</template>\r\n\r\n<script lang=\"ts\">\r\nimport { computed, defineComponent, inject } from 'vue'\r\nimport SgCheckbox from '@sgui-plus/components/checkbox'\r\nimport SgRadio from '@sgui-plus/components/radio'\r\nimport SgIcon from '@sgui-plus/components/icon'\r\nimport { ArrowRight } from '@sgui-plus/icons-vue'\r\nimport NodeContent from './node-content'\r\nimport { CASCADER_PANEL_INJECTION_KEY } from './types'\r\nimport type { default as CascaderNode } from './node'\r\n\r\nimport type { PropType } from 'vue'\r\n\r\nexport default defineComponent({\r\n  name: 'SgCascaderNode',\r\n\r\n  components: {\r\n    SgCheckbox,\r\n    SgRadio,\r\n    NodeContent,\r\n    SgIcon,\r\n    ArrowRight\r\n  },\r\n\r\n  props: {\r\n    node: {\r\n      type: Object as PropType<CascaderNode>,\r\n      required: true,\r\n    },\r\n    menuId: String,\r\n  },\r\n\r\n  emits: ['expand'],\r\n\r\n  setup(props, { emit }) {\r\n    const panel = inject(CASCADER_PANEL_INJECTION_KEY)!\r\n\r\n    const isHoverMenu = computed(() => panel.isHoverMenu)\r\n    const multiple = computed(() => panel.config.multiple)\r\n    const checkStrictly = computed(() => panel.config.checkStrictly)\r\n    const checkedNodeId = computed(() => panel.checkedNodes[0]?.uid)\r\n    const isDisabled = computed(() => props.node.isDisabled)\r\n    const isLeaf = computed(() => props.node.isLeaf)\r\n    const expandable = computed(\r\n      () => (checkStrictly.value && !isLeaf.value) || !isDisabled.value\r\n    )\r\n    const inExpandingPath = computed(() => isInPath(panel.expandingNode!))\r\n    // only useful in check-strictly mode\r\n    const inCheckedPath = computed(\r\n      () => checkStrictly.value && panel.checkedNodes.some(isInPath)\r\n    )\r\n\r\n    const isInPath = (node: CascaderNode) => {\r\n      const { level, uid } = props.node\r\n      return node?.pathNodes[level - 1]?.uid === uid\r\n    }\r\n\r\n    const doExpand = () => {\r\n      if (inExpandingPath.value) return\r\n      panel.expandNode(props.node)\r\n    }\r\n\r\n    const doCheck = (checked: boolean) => {\r\n      const { node } = props\r\n      if (checked === node.checked) return\r\n      panel.handleCheckChange(node, checked)\r\n    }\r\n\r\n    const doLoad = () => {\r\n      panel.lazyLoad(props.node, () => {\r\n        if (!isLeaf.value) doExpand()\r\n      })\r\n    }\r\n\r\n    const handleHoverExpand = (e: Event) => {\r\n      if (!isHoverMenu.value) return\r\n      handleExpand()\r\n      !isLeaf.value && emit('expand', e)\r\n    }\r\n\r\n    const handleExpand = () => {\r\n      const { node } = props\r\n      // do not exclude leaf node because the menus expanded might have to reset\r\n      if (!expandable.value || node.loading) return\r\n      node.loaded ? doExpand() : doLoad()\r\n    }\r\n\r\n    const handleClick = () => {\r\n      if (isHoverMenu.value && !isLeaf.value) return\r\n\r\n      if (\r\n        isLeaf.value &&\r\n        !isDisabled.value &&\r\n        !checkStrictly.value &&\r\n        !multiple.value\r\n      ) {\r\n        handleCheck(true)\r\n      } else {\r\n        handleExpand()\r\n      }\r\n    }\r\n\r\n    const handleSelectCheck = (checked: boolean) => {\r\n      if (checkStrictly.value) {\r\n        doCheck(checked)\r\n        if (props.node.loaded) {\r\n          doExpand()\r\n        }\r\n      } else {\r\n        handleCheck(checked)\r\n      }\r\n    }\r\n\r\n    const handleCheck = (checked: boolean) => {\r\n      if (!props.node.loaded) {\r\n        doLoad()\r\n      } else {\r\n        doCheck(checked)\r\n        !checkStrictly.value && doExpand()\r\n      }\r\n    }\r\n\r\n    return {\r\n      panel,\r\n      isHoverMenu,\r\n      multiple,\r\n      checkStrictly,\r\n      checkedNodeId,\r\n      isDisabled,\r\n      isLeaf,\r\n      expandable,\r\n      inExpandingPath,\r\n      inCheckedPath,\r\n      handleHoverExpand,\r\n      handleExpand,\r\n      handleClick,\r\n      handleCheck,\r\n      handleSelectCheck,\r\n    }\r\n  },\r\n})\r\n</script>\r\n"],"names":["_resolveComponent","_openBlock","_createElementBlock","_normalizeClass","_createCommentVNode","_createBlock","_withModifiers","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