File tree Expand file tree Collapse file tree 3 files changed +24
-6
lines changed
packages/clay-core/src/tree-view Expand file tree Collapse file tree 3 files changed +24
-6
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ import React from 'react';
9
9
import { ChildrenFunction , Collection , ICollectionProps } from './Collection' ;
10
10
import { TreeViewGroup } from './TreeViewGroup' ;
11
11
import { TreeViewItem , TreeViewItemStack } from './TreeViewItem' ;
12
- import { TreeViewContext } from './context' ;
12
+ import { Icons , TreeViewContext } from './context' ;
13
13
import { IExpandable , IMultipleSelection , useTree } from './useTree' ;
14
14
15
15
interface ITreeViewProps < T >
@@ -18,6 +18,7 @@ interface ITreeViewProps<T>
18
18
IExpandable ,
19
19
ICollectionProps < T > {
20
20
displayType ?: 'light' | 'dark' ;
21
+ expanderIcons ?: Icons ;
21
22
nestedKey ?: string ;
22
23
showExpanderOnHover ?: boolean ;
23
24
}
@@ -35,6 +36,7 @@ export function TreeView<T>({
35
36
className,
36
37
displayType = 'light' ,
37
38
expandedKeys,
39
+ expanderIcons,
38
40
items,
39
41
nestedKey,
40
42
onExpandedChange,
@@ -51,6 +53,7 @@ export function TreeView<T>({
51
53
typeof children === 'function'
52
54
? ( children as ChildrenFunction < Object > )
53
55
: undefined ,
56
+ expanderIcons,
54
57
nestedKey,
55
58
showExpanderOnHover,
56
59
...state ,
Original file line number Diff line number Diff line change @@ -110,11 +110,21 @@ export function TreeViewItemStack({
110
110
onClick = { ( ) => toggle ! ( item . key ) }
111
111
>
112
112
< span className = "c-inner" tabIndex = { - 2 } >
113
- < Icon symbol = "angle-down" />
114
- < Icon
115
- className = "component-expanded-d-none"
116
- symbol = "angle-right"
117
- />
113
+ { expanderIcons ?. close ? (
114
+ expanderIcons . close
115
+ ) : (
116
+ < Icon symbol = "angle-down" />
117
+ ) }
118
+ { expanderIcons ?. open ? (
119
+ React . cloneElement ( expanderIcons . open , {
120
+ className : 'component-expanded-d-none' ,
121
+ } )
122
+ ) : (
123
+ < Icon
124
+ className = "component-expanded-d-none"
125
+ symbol = "angle-right"
126
+ />
127
+ ) }
118
128
</ span >
119
129
</ Button >
120
130
</ Layout . ContentCol >
Original file line number Diff line number Diff line change 5
5
6
6
import React , { Key , useContext } from 'react' ;
7
7
8
+ export type Icons = {
9
+ open : React . ReactElement ;
10
+ close : React . ReactElement ;
11
+ } ;
12
+
8
13
export interface ITreeViewContext {
9
14
childrenRoot ?: ( item : Object ) => React . ReactElement ;
10
15
expandedKeys ?: Set < Key > ;
You can’t perform that action at this time.
0 commit comments