element-plus
Version:
A Component Library for Vue 3
103 lines (98 loc) • 3.01 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
var lodashUnified = require('lodash-unified');
var index = require('../../select/index.js');
var index$1 = require('../../tree/index.js');
var select$1 = require('./select.js');
var tree$1 = require('./tree.js');
var cacheOptions = require('./cache-options.js');
var tree = require('../../tree/src/tree.js');
var select = require('../../select/src/select.js');
var _sfc_main = vue.defineComponent({
name: "ElTreeSelect",
// disable `ElSelect` inherit current attrs
inheritAttrs: false,
props: {
...select.selectProps,
...tree.treeProps,
/**
* @description The cached data of the lazy node, the structure is the same as the data, used to get the label of the unloaded data
*/
cacheData: {
type: Array,
default: () => []
}
},
setup(props, context) {
const { slots, expose } = context;
const select = vue.ref();
const tree = vue.ref();
const key = vue.computed(() => props.nodeKey || props.valueKey || "value");
const selectProps2 = select$1.useSelect(props, context, { select, tree, key });
const { cacheOptions: cacheOptions$1, ...treeProps2 } = tree$1.useTree(props, context, {
select,
tree,
key
});
const methods = vue.reactive({});
expose(methods);
vue.onMounted(() => {
Object.assign(methods, {
//TODO: let only tree and select in 3.0
...lodashUnified.pick(tree.value, [
"filter",
"updateKeyChildren",
"getCheckedNodes",
"setCheckedNodes",
"getCheckedKeys",
"setCheckedKeys",
"setChecked",
"getHalfCheckedNodes",
"getHalfCheckedKeys",
"getCurrentKey",
"getCurrentNode",
"setCurrentKey",
"setCurrentNode",
"getNode",
"remove",
"append",
"insertBefore",
"insertAfter"
]),
...lodashUnified.pick(select.value, ["focus", "blur", "selectedLabel"]),
treeRef: tree.value,
selectRef: select.value
});
});
return () => vue.h(
index.ElSelect,
/**
* 1. The `props` is processed into `Refs`, but `v-bind` and
* render function props cannot read `Refs`, so use `reactive`
* unwrap the `Refs` and keep reactive.
* 2. The keyword `ref` requires `Ref`, but `reactive` broke it,
* so use function.
*/
vue.reactive({
...selectProps2,
ref: (ref2) => select.value = ref2
}),
{
...slots,
default: () => [
vue.h(cacheOptions.default, { data: cacheOptions$1.value }),
vue.h(
index$1.ElTree,
vue.reactive({
...treeProps2,
ref: (ref2) => tree.value = ref2
})
)
]
}
);
}
});
exports.default = _sfc_main;
//# sourceMappingURL=tree-select.vue2.js.map