@@ -66,9 +66,9 @@ export interface HeTreeProps<T extends Record<string, any>> extends Partial<type
66
66
onDragStart ?: ( e : React . DragEvent < HTMLElement > , stat : Stat < T > ) => void ,
67
67
onDragOver ?: ( e : React . DragEvent < HTMLElement > , stat : Stat < T > , isExternal : boolean ) => void ,
68
68
onExternalDragOver ?: ( e : React . DragEvent < HTMLElement > ) => boolean ,
69
- onDrop ?: ( e : React . DragEvent < HTMLElement > , parentStat : Stat < T > | null , index : number , isExternal : boolean ) => void ,
69
+ onExternalDrop ?: ( e : React . DragEvent < HTMLElement > , parentStat : Stat < T > | null , index : number , isExternal : boolean ) => void ,
70
70
/**
71
- * Call on drag end in the window. If you use draggedStat in the callback, it will be undefined if onDrop alreay triggered.
71
+ * Call on drag end in the window. If you use draggedStat in the callback, it will be undefined if onExternalDrop alreay triggered.
72
72
*/
73
73
onDragEnd ?: ( e : React . DragEvent < HTMLElement > , stat : Stat < T > , isOutside : boolean ) => void | boolean ,
74
74
onChange : ( data : T [ ] ) => void ,
@@ -478,7 +478,7 @@ export function useHeTree<T extends Record<string, any>>(
478
478
return r
479
479
}
480
480
}
481
- const onDropToRoot : React . DragEventHandler < HTMLElement > = ( e ) => {
481
+ const onExternalDropToRoot : React . DragEventHandler < HTMLElement > = ( e ) => {
482
482
if ( isExternal && ! props . onExternalDragOver ?.( e ) ) {
483
483
return
484
484
}
@@ -487,7 +487,7 @@ export function useHeTree<T extends Record<string, any>>(
487
487
e . preventDefault ( ) ;
488
488
if ( isExternal ) {
489
489
const { index : targetIndexInSiblings } = placeholder
490
- props . onDrop ?.( e , placeholder . parentStat , targetIndexInSiblings , isExternal )
490
+ props . onExternalDrop ?.( e , placeholder . parentStat , targetIndexInSiblings , isExternal )
491
491
}
492
492
}
493
493
}
@@ -598,14 +598,14 @@ export function useHeTree<T extends Record<string, any>>(
598
598
}
599
599
return index
600
600
}
601
- return { visibleIds, attrsList, onDragOverRoot, onDropToRoot , onDragEndOnRoot }
601
+ return { visibleIds, attrsList, onDragOverRoot, onExternalDropToRoot , onDragEndOnRoot }
602
602
} , [ mainCache , indent , draggedStat ,
603
603
// watch placeholder position
604
604
placeholder ?. parentStat , placeholder ?. index ,
605
605
// watch props
606
606
indent , placeholderId , rtl , props . rootId ,
607
607
// watch func
608
- ...( [ props . canDrop , props . canDropToRoot , props . customDragImage , props . onDragStart , props . onDragOver , props . onExternalDragOver , props . onDrop , props . onDragEnd , props . onChange , props . onDragOpen ] . map ( func => isFunctionReactive && func ) ) ,
608
+ ...( [ props . canDrop , props . canDropToRoot , props . customDragImage , props . onDragStart , props . onDragOver , props . onExternalDragOver , props . onExternalDrop , props . onDragEnd , props . onChange , props . onDragOpen ] . map ( func => isFunctionReactive && func ) ) ,
609
609
] )
610
610
// listen dragover on window
611
611
const t2 = useMemo ( ( ) => {
@@ -636,7 +636,7 @@ export function useHeTree<T extends Record<string, any>>(
636
636
} , [ props . keepPlaceholder ] )
637
637
useAddEventListener ( t2 . getEl , 'dragover' , t2 . onDragOverWindow )
638
638
//
639
- const { visibleIds, attrsList, onDragOverRoot, onDropToRoot , onDragEndOnRoot } = cacheForVisible
639
+ const { visibleIds, attrsList, onDragOverRoot, onExternalDropToRoot , onDragEndOnRoot } = cacheForVisible
640
640
const persistentIndices = useMemo ( ( ) => draggedStat ? [ visibleIds . indexOf ( draggedStat . id ) ] : [ ] , [ draggedStat , visibleIds ] ) ;
641
641
// render
642
642
const renderHeTree = ( options ?: { className ?: string , style ?: React . CSSProperties } ) => {
@@ -648,7 +648,7 @@ export function useHeTree<T extends Record<string, any>>(
648
648
</ div >
649
649
}
650
650
return (
651
- < div className = { `he-tree ${ options ?. className || '' } ` } style = { options ?. style } ref = { rootRef } onDragOver = { onDragOverRoot } onDrop = { onDropToRoot } onDragEnd = { onDragEndOnRoot } >
651
+ < div className = { `he-tree ${ options ?. className || '' } ` } style = { options ?. style } ref = { rootRef } onDragOver = { onDragOverRoot } onExternalDrop = { onExternalDropToRoot } onDragEnd = { onDragEndOnRoot } >
652
652
< VirtualList < Id > ref = { virtualListRef } items = { visibleIds } virtual = { props . virtual } persistentIndices = { persistentIndices } style = { { height : '100%' } }
653
653
renderItem = { ( id , index ) => renderNodeBox ( {
654
654
stat : getStat ( id ) ! , attrs : attrsList [ index ] , isPlaceholder : id === placeholderId
0 commit comments