13
13
import { AriaGridListProps , useGridList } from '@react-aria/gridlist' ;
14
14
import { AsyncLoadable , DOMRef , LoadingState , SpectrumSelectionProps , StyleProps } from '@react-types/shared' ;
15
15
import { classNames , useDOMRef , useStyleProps } from '@react-spectrum/utils' ;
16
- import type { DnDHooks } from '@react-spectrum/dnd' ;
16
+ import type { DragAndDropHooks } from '@react-spectrum/dnd' ;
17
17
import type { DraggableCollectionState , DroppableCollectionState } from '@react-stately/dnd' ;
18
18
import type { DroppableCollectionResult } from '@react-aria/dnd' ;
19
19
import { filterDOMProps , mergeProps , useLayoutEffect } from '@react-aria/utils' ;
@@ -56,17 +56,16 @@ export interface SpectrumListViewProps<T> extends AriaGridListProps<T>, StylePro
56
56
*/
57
57
onAction ?: ( key : Key ) => void ,
58
58
/**
59
- * The drag and drop hooks returned by `useDnDHooks` used to enable drag and drop behavior for the ListView.
60
- * @private
59
+ * The drag and drop hooks returned by `useDragAndDrop` used to enable drag and drop behavior for the ListView.
61
60
*/
62
- dndHooks ?: DnDHooks [ 'dndHooks ']
61
+ dragAndDropHooks ?: DragAndDropHooks [ 'dragAndDropHooks ']
63
62
}
64
63
65
64
interface ListViewContextValue < T > {
66
65
state : ListState < T > ,
67
66
dragState : DraggableCollectionState ,
68
67
dropState : DroppableCollectionState ,
69
- dndHooks : DnDHooks [ 'dndHooks '] ,
68
+ dragAndDropHooks : DragAndDropHooks [ 'dragAndDropHooks '] ,
70
69
onAction :( key : Key ) => void ,
71
70
isListDraggable : boolean ,
72
71
isListDroppable : boolean ,
@@ -118,11 +117,11 @@ function ListView<T extends object>(props: SpectrumListViewProps<T>, ref: DOMRef
118
117
isQuiet,
119
118
overflowMode = 'truncate' ,
120
119
onAction,
121
- dndHooks ,
120
+ dragAndDropHooks ,
122
121
...otherProps
123
122
} = props ;
124
- let isListDraggable = ! ! dndHooks ?. useDraggableCollectionState ;
125
- let isListDroppable = ! ! dndHooks ?. useDroppableCollectionState ;
123
+ let isListDraggable = ! ! dragAndDropHooks ?. useDraggableCollectionState ;
124
+ let isListDroppable = ! ! dragAndDropHooks ?. useDroppableCollectionState ;
126
125
let dragHooksProvided = useRef ( isListDraggable ) ;
127
126
let dropHooksProvided = useRef ( isListDroppable ) ;
128
127
if ( dragHooksProvided . current !== isListDraggable ) {
@@ -144,12 +143,12 @@ function ListView<T extends object>(props: SpectrumListViewProps<T>, ref: DOMRef
144
143
let dragState : DraggableCollectionState ;
145
144
let preview = useRef ( null ) ;
146
145
if ( isListDraggable ) {
147
- dragState = dndHooks . useDraggableCollectionState ( {
146
+ dragState = dragAndDropHooks . useDraggableCollectionState ( {
148
147
collection,
149
148
selectionManager,
150
149
preview
151
150
} ) ;
152
- dndHooks . useDraggableCollection ( { } , dragState , domRef ) ;
151
+ dragAndDropHooks . useDraggableCollection ( { } , dragState , domRef ) ;
153
152
}
154
153
let layout = useListLayout (
155
154
state ,
@@ -160,16 +159,16 @@ function ListView<T extends object>(props: SpectrumListViewProps<T>, ref: DOMRef
160
159
layout . allowDisabledKeyFocus = state . selectionManager . disabledBehavior === 'selection' || ! ! dragState ?. draggingKeys . size ;
161
160
162
161
163
- let DragPreview = dndHooks ?. DragPreview ;
162
+ let DragPreview = dragAndDropHooks ?. DragPreview ;
164
163
let dropState : DroppableCollectionState ;
165
164
let droppableCollection : DroppableCollectionResult ;
166
165
let isRootDropTarget : boolean ;
167
166
if ( isListDroppable ) {
168
- dropState = dndHooks . useDroppableCollectionState ( {
167
+ dropState = dragAndDropHooks . useDroppableCollectionState ( {
169
168
collection,
170
169
selectionManager
171
170
} ) ;
172
- droppableCollection = dndHooks . useDroppableCollection ( {
171
+ droppableCollection = dragAndDropHooks . useDroppableCollection ( {
173
172
keyboardDelegate : layout ,
174
173
dropTargetDelegate : layout
175
174
} , dropState , domRef ) ;
@@ -206,7 +205,7 @@ function ListView<T extends object>(props: SpectrumListViewProps<T>, ref: DOMRef
206
205
let hasAnyChildren = useMemo ( ( ) => [ ...collection ] . some ( item => item . hasChildNodes ) , [ collection ] ) ;
207
206
208
207
return (
209
- < ListViewContext . Provider value = { { state, dragState, dropState, dndHooks , onAction, isListDraggable, isListDroppable, layout, loadingState} } >
208
+ < ListViewContext . Provider value = { { state, dragState, dropState, dragAndDropHooks , onAction, isListDraggable, isListDroppable, layout, loadingState} } >
210
209
< FocusScope >
211
210
< FocusRing focusRingClass = { classNames ( listStyles , 'focus-ring' ) } >
212
211
< Virtualizer
0 commit comments