Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support TreeView item label templating #1660

Closed
brunnerh opened this issue Feb 14, 2023 · 3 comments · Fixed by #1843
Closed

Support TreeView item label templating #1660

brunnerh opened this issue Feb 14, 2023 · 3 comments · Fixed by #1843
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@brunnerh
Copy link
Contributor

Currently the TreeView does not allow much customization in how the items are displayed.
It would be helpful if an optional slot is provided that is passed the item instance, e.g.

<TreeView {children}>
  <svelte:fragment slot="item" let:item>
     <span class:important={item.important}>{item.text}</span>
  </svelte:fragment>
</TreeView>
@theetrain
Copy link
Collaborator

This sounds appropriate to me, especially given the proposed state for slots in #1621.

@theetrain theetrain added enhancement New feature or request good first issue Good for newcomers labels Feb 14, 2023
metonym added a commit that referenced this issue Nov 11, 2023
metonym added a commit that referenced this issue Nov 12, 2023
@metonym
Copy link
Collaborator

metonym commented Nov 13, 2023

Released in v0.82.0.

Docs.

<TreeView children="{children}" let:node>
  {node.id}
  {node.text}
  {node.expanded}
  {node.selected}
  {node.disabled}
  {node.leaf} // True if the node is a leaf (node does not have children)
</TreeView>

@brunnerh
Copy link
Contributor Author

I think this is too restrictive, though.

In my example I access the source item as is, so additional properties can be used for styling or data display.

Maybe that should be split into two props, node and item where node contains any metadata and item is just the object as it has been passed in as part of children (without any modification to maintain the prototype). Ideally children would use a generic type parameter so type information can be propagated to the slot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants