winbox-ui-next
Version:
We Design Vue 2.0: A Vue.js 3 UI Library
86 lines (85 loc) • 2.43 kB
JavaScript
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
import { defineComponent, toRefs, ref, computed, createVNode, mergeProps } from "vue";
import Tree from "../tree/index.js";
var Panel = defineComponent({
name: "TreeSelectPanel",
components: {
Tree
},
props: {
treeProps: {
type: Object,
default: () => ({})
},
selectedKeys: {
type: Array
},
showCheckable: {
type: Boolean
},
treeSlots: {
type: Object,
default: () => ({})
}
},
emits: ["change"],
setup(props, {
emit
}) {
const {
showCheckable,
selectedKeys,
treeProps
} = toRefs(props);
const refTree = ref();
const computedTreeProps = computed(() => {
return __spreadProps(__spreadValues({}, treeProps.value), {
disableSelectActionOnly: true,
checkedKeys: showCheckable.value ? selectedKeys.value : [],
selectedKeys: showCheckable.value ? [] : selectedKeys.value
});
});
return {
refTree,
computedTreeProps,
onSelect(newVal, e) {
var _a, _b;
if (showCheckable.value) {
(_b = (_a = refTree.value) == null ? void 0 : _a.toggleCheck) == null ? void 0 : _b.call(_a, newVal[0], e);
} else {
emit("change", newVal);
}
},
onCheck(newVal) {
emit("change", newVal);
}
};
},
render() {
return createVNode(Tree, mergeProps({
"ref": "refTree"
}, this.computedTreeProps, {
"onSelect": this.onSelect,
"onCheck": this.onCheck
}), this.treeSlots);
}
});
export { Panel as default };