4aeec7e0237e84b3fa24df578b226965b47360959e90951fdef7ca611991d1c9fde20982b41400cf978fc2b537963a5558b81c1da3609eabc848129f8ec1ae 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import { defineComponent, ref, computed, reactive, onMounted, h } from 'vue';
  2. import { pick } from 'lodash-unified';
  3. import { ElSelect } from '../../select/index.mjs';
  4. import { ElTree } from '../../tree/index.mjs';
  5. import { useSelect } from './select.mjs';
  6. import { useTree } from './tree.mjs';
  7. import CacheOptions from './cache-options.mjs';
  8. import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
  9. const _sfc_main = defineComponent({
  10. name: "ElTreeSelect",
  11. inheritAttrs: false,
  12. props: {
  13. ...ElSelect.props,
  14. ...ElTree.props,
  15. cacheData: {
  16. type: Array,
  17. default: () => []
  18. }
  19. },
  20. setup(props, context) {
  21. const { slots, expose } = context;
  22. const select = ref();
  23. const tree = ref();
  24. const key = computed(() => props.nodeKey || props.valueKey || "value");
  25. const selectProps = useSelect(props, context, { select, tree, key });
  26. const { cacheOptions, ...treeProps } = useTree(props, context, {
  27. select,
  28. tree,
  29. key
  30. });
  31. const methods = reactive({});
  32. expose(methods);
  33. onMounted(() => {
  34. Object.assign(methods, {
  35. ...pick(tree.value, [
  36. "filter",
  37. "updateKeyChildren",
  38. "getCheckedNodes",
  39. "setCheckedNodes",
  40. "getCheckedKeys",
  41. "setCheckedKeys",
  42. "setChecked",
  43. "getHalfCheckedNodes",
  44. "getHalfCheckedKeys",
  45. "getCurrentKey",
  46. "getCurrentNode",
  47. "setCurrentKey",
  48. "setCurrentNode",
  49. "getNode",
  50. "remove",
  51. "append",
  52. "insertBefore",
  53. "insertAfter"
  54. ]),
  55. ...pick(select.value, ["focus", "blur", "selectedLabel"]),
  56. treeRef: tree.value,
  57. selectRef: select.value
  58. });
  59. });
  60. return () => h(ElSelect, reactive({
  61. ...selectProps,
  62. ref: (ref2) => select.value = ref2
  63. }), {
  64. ...slots,
  65. default: () => [
  66. h(CacheOptions, { data: cacheOptions.value }),
  67. h(ElTree, reactive({
  68. ...treeProps,
  69. ref: (ref2) => tree.value = ref2
  70. }))
  71. ]
  72. });
  73. }
  74. });
  75. var TreeSelect = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "tree-select.vue"]]);
  76. export { TreeSelect as default };
  77. //# sourceMappingURL=tree-select.mjs.map