@@ -174,46 +174,17 @@ export function useHeTree<T extends Record<string, any>>(
174
174
}
175
175
return stats [ id ]
176
176
}
177
- let draft : T [ ] | null = null
178
- function getDraft ( ) {
179
- if ( ! draft ) {
180
- const map = new Map < Stat < T > | null , T [ ] > ( )
181
- map . set ( null , [ ] )
182
- draft = map . get ( null ) !
183
- for ( const [ stat , { parent : parentStat } ] of walkTreeDataGenerator ( rootStats , 'childStats' ) ) {
184
- const newNode = { ...stat . node , [ CHILDREN ] : [ ] }
185
- map . set ( stat , newNode [ CHILDREN ] )
186
- map . get ( parentStat ) ! . push ( newNode )
187
- }
188
- }
189
- return draft
190
- }
191
- function nextData ( ) {
192
- const draft = getDraft ( )
193
- let result = draft
194
- if ( props . dataType === 'flat' ) {
195
- result = [ ] ;
196
- for ( const [ node , { parent } ] of walkTreeDataGenerator ( draft , CHILDREN ) ) {
197
- // @ts -ignore
198
- node [ PID ] = parent ? parent [ ID ] : props . rootId
199
- result . push ( node )
200
- }
201
- }
202
- return result
203
- }
204
177
return {
205
178
// root
206
179
rootIds, rootNodes, rootStats,
207
180
// methods
208
181
getStat,
209
- getDraft,
210
- nextData,
211
182
}
212
183
} , [ props . data , props . dataType , ID , PID , openIdSet , checkedIdSet , props . rootId ,
213
184
isFunctionReactive && props . canDrag ,
214
185
]
215
186
) ;
216
- const { rootIds, rootStats, getStat, getDraft , nextData } = mainCache ;
187
+ const { rootIds, rootStats, getStat, } = mainCache ;
217
188
// about drag ==================================
218
189
const indent = props . indent !
219
190
const [ draggedStat , setDraggedStat ] = useState < Stat < T > > ( ) ;
0 commit comments