@@ -6,14 +6,20 @@ import { NuxtLink } from '#components'
66const props = withDefaults (defineProps <{
77 node: ModuleTreeNode
88 icon? : string
9+ iconOpen? : string
910 link? : string | boolean
11+ padding? : number
12+ open? : boolean
1013}>(), {
11- icon: ' i-carbon-folder' ,
14+ icon: ' i-catppuccin:folder catppuccin' ,
15+ iconOpen: ' i-catppuccin:folder-open catppuccin' ,
16+ padding: 0 ,
1217})
1318
1419const emit = defineEmits <{
1520 (e : ' select' , node : ModuleDest ): void
1621}>()
22+ const open = defineModel <boolean >(' open' , { required: false , default: true })
1723const route = useRoute ()
1824const location = window .location
1925function select(node : ModuleDest ) {
@@ -24,40 +30,48 @@ function select(node: ModuleDest) {
2430 </script >
2531
2632<template >
27- <details open >
33+ <details : open= " open " @toggle = " e => open = (e.target as HTMLDetailsElement)?.open " >
2834 <summary
2935 cursor-default
3036 select-none
3137 text-sm
3238 truncate
33- p =" y1"
39+ :style =" { paddingLeft: `${padding + 0.5}rem` }"
40+ flex =" ~ gap-1"
41+ px2 py1 rounded
42+ hover =" bg-active "
3443 >
35- <div :class =" icon" inline-block vertical-text-bottom />
36- {{ node.name }}
44+ <div class =" i-ph:caret-right-duotone transition op50" :class =" open ? 'rotate-90' : ''" />
45+ <div :class =" open ? iconOpen || icon : icon" inline-block vertical-text-bottom />
46+ <div font-mono >
47+ <DisplayHighlightedPath :path =" node.name || ''" />
48+ </div >
3749 </summary >
3850
39- <DisplayTreeNode v-for =" e of Object.entries(node.children)" :key =" e[0]" ml4 :node =" e[1]" :link =" link" />
40- <div
41- v-for =" i of node.items"
42- :key =" i.full"
43- ml4
44- ws-nowrap
45- >
46- <component
47- :is =" link ? NuxtLink : 'div'"
48- :to =" link ? (typeof link === 'string' ? link : { path: route.path, query: { ...route.query, module: i.full }, hash: location.hash }) : undefined"
49- block
50- text-sm
51- p =" x2 y1"
52- ml1
53- rounded
54- @click =" select(i)"
55- >
56- <DisplayFileIcon :filename =" i.full" inline-block vertical-text-bottom />
57- <span ml-1 >
58- {{ i.path.split('/').pop() }}
59- </span >
60- </component >
61- </div >
51+ <template v-if =" open " >
52+ <DisplayTreeNode
53+ v-for =" e of Object.entries(node.children)"
54+ :key =" e[0]" :node =" e[1]" :link =" link"
55+ :padding =" padding + 1"
56+ />
57+ <template v-for =" i of node .items " :key =" i .full " >
58+ <component
59+ :is =" link ? NuxtLink : 'div'"
60+ :to =" link ? (typeof link === 'string' ? link : { path: route.path, query: { ...route.query, module: i.full }, hash: location.hash }) : undefined"
61+ text-sm
62+ ws-nowrap
63+ flex =" ~ gap-1"
64+ px2 py1 rounded
65+ hover =" bg-active"
66+ :style =" { paddingLeft: `${padding + 2.7}rem` }"
67+ @click =" select(i)"
68+ >
69+ <DisplayFileIcon :filename =" i.full" />
70+ <div font-mono >
71+ <DisplayHighlightedPath :path =" i.path.split('/').pop() || ''" />
72+ </div >
73+ </component >
74+ </template >
75+ </template >
6276 </details >
6377</template >
0 commit comments