Skip to content

Commit ae8ce5b

Browse files
authored
feat: add TreeItemState.path property (#98)
* feat: add `TreeItemState.path` property * chore: add changeset
1 parent 6f88065 commit ae8ce5b

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

.changeset/icy-llamas-prove.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"svelte-file-tree": minor
3+
---
4+
5+
feat: add `TreeItemState.path` property

packages/svelte-file-tree/src/lib/tree.svelte.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,12 @@ export class TreeItemState<
9797
}
9898

9999
readonly type = "item";
100+
101+
readonly path: string = $derived.by(() => {
102+
const parent = this.parent;
103+
if (parent === undefined) {
104+
return this.node.name;
105+
}
106+
return `${parent.path}/${this.node.name}`;
107+
});
100108
}

0 commit comments

Comments
 (0)