Skip to content

Commit 3d4b7ab

Browse files
Licen-itAkshat55
andauthored
feat: allow users to add a custom gap to each node offset (#2972)
Co-authored-by: Akshat Patel <[email protected]>
1 parent b4e5620 commit 3d4b7ab

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/treeview/tree-node.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ export class TreeNodeComponent implements AfterContentChecked, OnInit, OnDestroy
129129
@Input() value;
130130
@Input() icon: string | TemplateRef<any>;
131131
@Input() iconContext: any;
132+
@Input() gap = 0;
132133
@Input() children: Node[] = [];
133134

134135
/**
@@ -154,6 +155,7 @@ export class TreeNodeComponent implements AfterContentChecked, OnInit, OnDestroy
154155
this.icon = node.icon ?? this.icon;
155156
this.selected = node.selected ?? this.selected;
156157
this.depth = node.depth ?? this.depth;
158+
this.gap = node.gap ?? this.gap;
157159
this.children = node.children ?? this.children;
158160
this.iconContext = node.iconText ?? this.iconContext;
159161
}
@@ -232,7 +234,7 @@ export class TreeNodeComponent implements AfterContentChecked, OnInit, OnDestroy
232234
return this.depth + 2 + this.depth * 0.5;
233235
}
234236

235-
return this.depth + 2.5;
237+
return this.depth + this.gap + 2.5;
236238
}
237239

238240
emitFocusEvent(event) {

src/treeview/tree-node.types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export interface Node {
1111
selected?: boolean;
1212
icon?: string | TemplateRef<any>;
1313
iconContext?: any;
14+
gap?: number;
1415
children?: Node[];
1516
[key: string]: any;
1617
}

0 commit comments

Comments
 (0)