Skip to content

Commit fc86d05

Browse files
J-SekKaelWD
authored andcommitted
feat(VTreeview): add header slot
1 parent eb42f4d commit fc86d05

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

packages/docs/src/data/new-in.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@
258258
"indentLines": "3.9.0"
259259
},
260260
"slots": {
261+
"header": "3.10.0",
261262
"toggle": "3.10.0"
262263
}
263264
},

packages/vuetify/src/components/VTreeview/VTreeviewChildren.tsx

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ export type VTreeviewChildrenSlots<T> = {
3232
item: T
3333
internalItem: InternalListItem<T>
3434
}
35+
header: {
36+
props: InternalListItem['props']
37+
item: T
38+
internalItem: InternalListItem<T>
39+
loading: boolean
40+
}
3541
divider: { props: InternalListItem['props'] }
3642
subheader: { props: InternalListItem['props'] }
3743
}
@@ -200,17 +206,21 @@ export const VTreeviewChildren = genericComponent<new <T extends InternalListIte
200206
: () => selectItem(activatorItems.value[index]?.select, !activatorItems.value[index]?.isSelected),
201207
}
202208

203-
return (
204-
<VTreeviewItem
205-
ref={ el => activatorItems.value[index] = el as VTreeviewItem }
206-
{ ...listItemProps }
207-
hasCustomPrepend={ !!slots.prepend }
208-
hideActions={ props.hideActions }
209-
indentLines={ indentLines.node }
210-
value={ props.returnObject ? item.raw : itemProps.value }
211-
loading={ loading }
212-
v-slots={ slotsWithItem }
213-
/>
209+
return renderSlot(
210+
slots.header,
211+
{ props: listItemProps, item: item.raw, internalItem: item, loading },
212+
() => (
213+
<VTreeviewItem
214+
ref={ el => activatorItems.value[index] = el as VTreeviewItem }
215+
{ ...listItemProps }
216+
hasCustomPrepend={ !!slots.prepend }
217+
hideActions={ props.hideActions }
218+
indentLines={ indentLines.node }
219+
value={ props.returnObject ? item.raw : itemProps.value }
220+
loading={ loading }
221+
v-slots={ slotsWithItem }
222+
/>
223+
)
214224
)
215225
},
216226
default: () => (

0 commit comments

Comments
 (0)