Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
bind:this={treeItems[i]}
bind:open={node.open}
hideLead={!node.lead}
hideTrail={!node.trail}
hideChildren={!node.children || node.children.length === 0}
bind:disabled={node.disabled}
bind:group
Expand All @@ -111,6 +112,9 @@
<svelte:fragment slot="lead">
{@html node.lead}
</svelte:fragment>
<svelte:fragment slot="trail">
{@html node.trail}
</svelte:fragment>
<svelte:fragment slot="children">
<TreeViewDataDrivenItem bind:nodes={node.children} bind:treeItems={children[i]} />
</svelte:fragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Slots:
/**
* @slot {{}} lead - Allows for an optional leading element, such as an icon.
* @slot {{}} trail - Allows for an optional trailing element, such as action icons.
* @slot {{}} children - Provide TreeView item children.
*/
import { getContext, createEventDispatcher } from 'svelte';
Expand Down Expand Up @@ -75,6 +76,8 @@
/** Don't use this prop, workaround until svelte implements conditional slots */
export let hideLead = false;
/** Don't use this prop, workaround until svelte implements conditional slots */
export let hideTrail = false;
/** Don't use this prop, workaround until svelte implements conditional slots */
export let hideChildren = false;

// Locals
Expand Down Expand Up @@ -356,6 +359,12 @@
<div class="tree-item-content">
<slot />
</div>
<!-- Slot: Trail -->
{#if $$slots.trail && !hideTrail}
<div class="tree-item-trail">
<slot name="trail" />
</div>
{/if}
</summary>
<div bind:this={childrenDiv} class="tree-item-children {classesChildren}" role="group">
<slot name="children" />
Expand Down
2 changes: 2 additions & 0 deletions packages/skeleton/src/lib/components/TreeView/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ export interface TreeViewNode {
content: string;
/** Lead content. accepts HTML. */
lead?: string;
/** Trail content. accepts HTML. */
trail?: string;
/** Set open by default on load. */
open?: boolean;
/** Set the tree disabled state. */
Expand Down