N00ts / vue3-treeview

a simple treeview in vue js 3
MIT License
71 stars 61 forks source link

Add slot for the item text itself #30

Open Employee87 opened 1 year ago

Employee87 commented 1 year ago

I see there is a slot for before and after. But what if I want to replace the actual text itself to some template code?

N00ts commented 1 year ago

that could be a good idea, you can propose a P%R if you want :)

Employee87 commented 1 year ago

@N00ts I made the pull request, please check and merge, thanks.

https://github.com/N00ts/vue3-treeview/pull/34

N00ts commented 1 year ago

Hey what is exactly the use case ? Can't you use existing slots ?

Employee87 commented 1 year ago

It's because by default the code will always take the text prop and show it in the treeview main text area. But for example I wanted to replace that with a highlight plugin like <highlight :search="search_text" :value="node.text" /> (which highlights part of the content based on the search text), and since I can't override the main text, I have to set text prop to empty string so that nothing shows in the main text area, and override the before or after slots with this highlight component. I then have to make a new property like text2 to use for the actual text. Plus I then have to inject some custom css to remove the margin around the main text area.

This could all be solved, if I have a slot for the main text area.

N00ts commented 1 year ago

Why not just a custom class ?

Employee87 commented 1 year ago

I am not sure how that would help me though? Does the main area (i.e. not the before or after area) have a prop to insert a custom class?

scscgit commented 1 year ago

Another use-cases:

Isn't this slot a most basic feature users of a tree view would expect?

dustin-auby commented 10 months ago

This would help in many situations, i want to add tool tips to the nodes and would need to have a custom slot for the text to do this.

MrAmine08 commented 6 months ago

How about making the label clickable? and not just the checkbox.