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

1 month ago
  1. {"ast":null,"code":"import { watch, nextTick, toRefs, computed } from 'vue';\nimport { pick } from 'lodash-unified';\nimport { ElSelect } from '../../select/index.mjs';\nimport { useNamespace } from '../../../hooks/use-namespace/index.mjs';\nimport { UPDATE_MODEL_EVENT } from '../../../constants/event.mjs';\nconst useSelect = (props, {\n attrs,\n emit\n}, {\n select,\n tree,\n key\n}) => {\n const ns = useNamespace(\"tree-select\");\n watch(() => props.data, () => {\n if (props.filterable) {\n nextTick(() => {\n var _a, _b;\n (_b = tree.value) == null ? void 0 : _b.filter((_a = select.value) == null ? void 0 : _a.states.inputValue);\n });\n }\n }, {\n flush: \"post\"\n });\n const result = {\n ...pick(toRefs(props), Object.keys(ElSelect.props)),\n ...attrs,\n \"onUpdate:modelValue\": value => emit(UPDATE_MODEL_EVENT, value),\n valueKey: key,\n popperClass: computed(() => {\n const classes = [ns.e(\"popper\")];\n if (props.popperClass) classes.push(props.popperClass);\n return classes.join(\" \");\n }),\n filterMethod: (keyword = \"\") => {\n var _a;\n if (props.filterMethod) {\n props.filterMethod(keyword);\n } else if (props.remoteMethod) {\n props.remoteMethod(keyword);\n } else {\n (_a = tree.value) == null ? void 0 : _a.filter(keyword);\n }\n }\n };\n return result;\n};\nexport { useSelect };","map":{"version":3,"names":["useSelect","props","attrs","emit","select","tree","key","ns","useNamespace","watch","data","filterable","nextTick","_a","_b","value","filter","states","inputValue","flush","result","pick","toRefs","Object","keys","ElSelect","UPDATE_MODEL_EVENT","valueKey","popperClass","computed","classes","e","push","join","filterMethod","keyword","remoteMethod"],"sources":["../../../../../../packages/components/tree-select/src/select.ts"],"sourcesContent":["// @ts-nocheck\nimport { computed, nextTick, toRefs, watch } from 'vue'\nimport { pick } from 'lodash-unified'\nimport ElSelect from '@element-plus/components/select'\nimport { useNamespace } from '@element-plus/hooks'\nimport { UPDATE_MODEL_EVENT } from '@element-plus/constants'\nimport type { Ref } from 'vue'\nimport type ElTree from '@element-plus/components/tree'\n\nexport const useSelect = (\n props,\n { attrs, emit },\n {\n select,\n tree,\n key,\n }: {\n select: Ref<InstanceType<typeof ElSelect> | undefined>\n tree: Ref<InstanceType<typeof ElTree> | undefined>\n key: Ref<string>\n }\n) => {\n const ns = useNamespace('tree-select')\n\n // update tree data when use filterMethod/remoteMethod\n watch(\n () => props.data,\n () => {\n if (props.filterable) {\n nextTick(() => {\n // let tree node expand only, same with tree filter\n tree.value?.filter(select.value?.states.inputValue)\n })\n }\n },\n { flush: 'post' }\n )\n\n const result = {\n ...pick(toRefs(props), Object.keys(ElSelect.props)),\n ...attrs,\n // attrs is not reactive, when v-model binding source changes,\n // this listener is still old, see the bug(or test 'v-model source change'):\n // https://github.com/element-plus/element-plus/issues/14204\n 'onUpdate:modelValue': (value) => emit(UPDATE_MODEL_EVENT, value),\n valueKey: key,\n popperClass: computed(() => {\n const classes = [ns.e('popper')]\n if (props.popperClass) classes.push(props.popperClass)\n return classes.join(' ')\n }),\n filterMethod: (keyword = '') => {\n if (props.filterMethod) {\n props.filterMethod(keyword)\n } else if (props.remoteMethod) {\n props.remoteMethod(keyword)\n } else {\n // let tree node expand only, same with tree filter\n tree.value?.filter(keyword)\n }\n },\n }\n\n return result\n}\n"],"mappings":";;;;;AAKY,MAACA,SAAS,GAAGA,CAACC,KAAK,EAAE;EAAEC,KAAK;EAAEC;AAAI,CAAE,EAAE;EAChDC,MAAM;EACNC,IAAI;EACJC;AACF,CAAC,KAAK;EACJ,MAAMC,EAAE,GAAGC,YAAY,CAAC,aAAa,CAAC;EACtCC,KAAK,CAAC,MAAMR,KAAK,CAACS,IAAI,EAAE,MAAM;IAC