2019-01-12 03:33:27 +00:00
|
|
|
import { TreeNode } from '../../vc-tree';
|
2018-12-25 04:00:39 +00:00
|
|
|
/**
|
|
|
|
* SelectNode wrapped the tree node.
|
|
|
|
* Let's use SelectNode instead of TreeNode
|
|
|
|
* since TreeNode is so confuse here.
|
|
|
|
*/
|
|
|
|
export default {
|
|
|
|
functional: true,
|
|
|
|
name: 'SelectNode',
|
|
|
|
isTreeNode: true,
|
|
|
|
props: TreeNode.props,
|
2019-01-12 03:33:27 +00:00
|
|
|
render(h, context) {
|
|
|
|
const { props, slots, listeners, data } = context;
|
|
|
|
const $slots = slots();
|
|
|
|
const children = $slots.default;
|
|
|
|
delete $slots.default;
|
2018-12-25 04:00:39 +00:00
|
|
|
const treeNodeProps = {
|
2019-01-12 03:33:27 +00:00
|
|
|
...data,
|
|
|
|
on: { ...listeners, ...data.nativeOn },
|
|
|
|
props,
|
|
|
|
};
|
|
|
|
const slotsKey = Object.keys($slots);
|
|
|
|
return (
|
|
|
|
<TreeNode {...treeNodeProps}>
|
|
|
|
{children}
|
|
|
|
{slotsKey.length
|
|
|
|
? slotsKey.map(name => {
|
|
|
|
return <template slot={name}>{$slots[name]}</template>;
|
|
|
|
})
|
|
|
|
: null}
|
|
|
|
</TreeNode>
|
|
|
|
);
|
2018-12-25 04:00:39 +00:00
|
|
|
},
|
2019-01-12 03:33:27 +00:00
|
|
|
};
|