-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtree-node.vue
60 lines (57 loc) · 1.35 KB
/
tree-node.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<template>
<li :aria-expanded="expanded" role="treeitem" class="tree-node">
<div class="tree-node-preview-container" @click="onClick">
<span
v-if="shouldShowArrow"
:class="[
'tree-node-arrow',
expanded ? 'tree-node-arrow-expanded' : 'tree-node-arrow-collapsed',
]"
>
▶ </span
><span
v-else-if="shouldShowPlaceholder && $slots.default"
class="tree-node-placeholder"
> </span
><node-renderer />
</div>
<ol role="group" class="tree-node-child-nodes-container">
<slot v-if="expanded"></slot>
<!-- <span v-else>undefined</span> -->
</ol>
</li>
</template>
<script>
export default {
name: 'tree-node',
components: {
NodeRenderer: {
render(h) {
const parent = this.$parent.$parent
return parent.nodeRenderer(
parent.depth,
parent.name,
parent.data,
parent.isNonenumerable
)
},
},
},
props: {
name: { type: String },
data: { type: null },
depth: { type: Number },
expanded: { type: Boolean },
shouldShowArrow: { type: Boolean },
shouldShowPlaceholder: { type: Boolean },
nodeRenderer: { type: Function },
},
computed: {},
methods: {
onClick() {
this.$emit('click')
},
},
}
</script>
<style lang="less"></style>