@@ -87,7 +87,7 @@ export function useHeTree<T extends Record<string, any>>(
87
87
throw new Error ( "Either renderNodeBox or renderNode is required." ) ;
88
88
}
89
89
const rtl = props . direction === 'rtl'
90
- const openIdsStr = useMemo ( ( ) => props . openIds ? [ ...props . openIds ] . sort ( ) . toString ( ) : '' , [ props . openIds ] )
90
+ const openIdsStr = useMemo ( ( ) => props . openIds ? [ ...props . openIds ] . sort ( ) . toString ( ) : undefined , [ props . openIds ] )
91
91
const openIdSet = useMemo ( ( ) => new Set ( props . openIds ) , [ openIdsStr ] )
92
92
const checkedIdsStr = useMemo ( ( ) => props . checkedIds ? [ ...props . checkedIds ] . sort ( ) . toString ( ) : '' , [ props . checkedIds ] )
93
93
const checkedIdSet = useMemo ( ( ) => new Set ( props . checkedIds ) , [ checkedIdsStr ] )
@@ -101,6 +101,7 @@ export function useHeTree<T extends Record<string, any>>(
101
101
const rootIds : Id [ ] = [ ]
102
102
const rootNodes : T [ ] = [ ]
103
103
const rootStats : Stat < T > [ ] = [ ]
104
+ const allIds : Id [ ] = [ ]
104
105
//
105
106
function * simpleWalk ( ) {
106
107
if ( props . dataType === 'flat' ) {
@@ -116,6 +117,7 @@ export function useHeTree<T extends Record<string, any>>(
116
117
let count = 0
117
118
for ( const [ node , info ] of simpleWalk ( ) ) {
118
119
const id : Id = node [ ID ] ?? count
120
+ allIds . push ( id )
119
121
let pid = node [ PID ] as Id
120
122
if ( props . dataType === 'tree' ) {
121
123
pid = info . parent ?. [ ID ] ?? null
@@ -186,6 +188,8 @@ export function useHeTree<T extends Record<string, any>>(
186
188
return {
187
189
// root
188
190
rootIds, rootNodes, rootStats,
191
+ //
192
+ allIds,
189
193
// methods
190
194
getStat,
191
195
}
0 commit comments