-
-
Notifications
You must be signed in to change notification settings - Fork 639
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #749 from clauderic/improve-keyboard-sorting-strategy
Improve default keyboard sorting strategy
- Loading branch information
Showing
17 changed files
with
148 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@dnd-kit/core': patch | ||
--- | ||
|
||
The `Data` and `DataRef` types are now exported by `@dnd-kit/core`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@dnd-kit/core': minor | ||
--- | ||
|
||
The `onDragStart`, `onDragMove`, `onDragOver`, `onDragEnd` and `onDragCancel` events of `<DndContext>` and `useDndMonitor` now expose the `activatorEvent` event that instantiated the activated sensor. |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import type {UniqueIdentifier} from '@dnd-kit/core'; | ||
|
||
export type SortableData = { | ||
sortable: { | ||
containerId: UniqueIdentifier; | ||
items: UniqueIdentifier[]; | ||
index: number; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,3 @@ | ||
import type {ClientRect} from '@dnd-kit/core'; | ||
import type {Transform} from '@dnd-kit/utilities'; | ||
|
||
export type SortingStrategy = (args: { | ||
activeNodeRect: ClientRect | null; | ||
activeIndex: number; | ||
index: number; | ||
rects: ClientRect[]; | ||
overIndex: number; | ||
}) => Transform | null; | ||
export type {SortableData} from './data'; | ||
export type {SortingStrategy} from './strategies'; | ||
export {hasSortableData} from './type-guard'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import type {ClientRect} from '@dnd-kit/core'; | ||
import type {Transform} from '@dnd-kit/utilities'; | ||
|
||
export type SortingStrategy = (args: { | ||
activeNodeRect: ClientRect | null; | ||
activeIndex: number; | ||
index: number; | ||
rects: ClientRect[]; | ||
overIndex: number; | ||
}) => Transform | null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import type {Data, DroppableContainer, DraggableNode} from '@dnd-kit/core'; | ||
|
||
import type {SortableData} from './data'; | ||
|
||
export function hasSortableData<T extends DraggableNode | DroppableContainer>( | ||
entry: T | null | undefined | ||
): entry is T & {data: {current: Data<SortableData>}} { | ||
if (!entry) { | ||
return false; | ||
} | ||
|
||
const data = entry.data.current; | ||
|
||
if ( | ||
data && | ||
'sortable' in data && | ||
typeof data.sortable === 'object' && | ||
'containerId' in data.sortable && | ||
'items' in data.sortable && | ||
'index' in data.sortable | ||
) { | ||
return true; | ||
} | ||
|
||
return false; | ||
} |