@elliemae/ds-drag-and-drop 2.3.0-alpha.8 → 2.3.0-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/types/hierarchy/customCollisionDetection.d.ts +3 -0
- package/dist/types/hierarchy/getHierarchyKeyboardCoordinates.d.ts +3 -0
- package/dist/types/hierarchy/index.d.ts +1 -0
- package/dist/types/hierarchy/types.d.ts +80 -0
- package/dist/types/hierarchy/useHierarchyActionHandlers.d.ts +1 -0
- package/dist/types/hierarchy/useHierarchyAnnouncements.d.ts +3 -0
- package/dist/types/hierarchy/useHierarchyDndkitConfig.d.ts +2 -0
- package/dist/types/hierarchy/useHierarchyPreviewHandlers.d.ts +2 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/tree/constants.d.ts +6 -0
- package/dist/types/tree/customCollisionDetection.d.ts +4 -0
- package/dist/types/tree/getTreeKeyboardCoordinates.d.ts +3 -0
- package/dist/types/tree/index.d.ts +1 -0
- package/dist/types/tree/types.d.ts +102 -0
- package/dist/types/tree/useTreeActionHandlers.d.ts +2 -0
- package/dist/types/tree/useTreeAnnouncements.d.ts +4 -0
- package/dist/types/tree/useTreeDndkitConfig.d.ts +2 -0
- package/dist/types/tree/useTreePreviewHandlers.d.ts +2 -0
- package/dist/types/tree/utilities.d.ts +7 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useHierarchyDndkitConfig';
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { Active, Announcements, CollisionDetection, DragEndEvent, DragMoveEvent, DragOverEvent, DragStartEvent, MeasuringConfiguration, Modifier, Over, SensorDescriptor, SensorOptions } from '@dnd-kit/core';
|
|
2
|
+
import { DroppableContainers } from '@dnd-kit/core/dist/store';
|
|
3
|
+
import { Coordinates, DragCancelEvent, ViewRect } from '@dnd-kit/core/dist/types';
|
|
4
|
+
import { MutableRefObject } from 'react';
|
|
5
|
+
export declare type Item = {
|
|
6
|
+
id: string;
|
|
7
|
+
depth: number;
|
|
8
|
+
parentId: string;
|
|
9
|
+
index: number;
|
|
10
|
+
};
|
|
11
|
+
export declare type DndContextPropsType = {
|
|
12
|
+
announcements: Announcements;
|
|
13
|
+
modifiers: Modifier[];
|
|
14
|
+
sensors: SensorDescriptor<SensorOptions>[];
|
|
15
|
+
measuring: Partial<MeasuringConfiguration>;
|
|
16
|
+
collisionDetection: CollisionDetection;
|
|
17
|
+
onDragStart: (e: DragStartEvent) => void;
|
|
18
|
+
onDragMove: (e: DragMoveEvent) => void;
|
|
19
|
+
onDragOver: (e: DragOverEvent) => void;
|
|
20
|
+
onDragEnd: (e: DragEndEvent) => void;
|
|
21
|
+
onDragCancel: (e: DragCancelEvent) => void;
|
|
22
|
+
};
|
|
23
|
+
export declare type useHierarchyPreviewHandlersReturn = {
|
|
24
|
+
handlePreviewDragStart: (e: DragStartEvent) => void;
|
|
25
|
+
handlePreviewDragMove: (e: DragMoveEvent) => void;
|
|
26
|
+
handlePreviewDragEnd: (e: DragEndEvent) => void;
|
|
27
|
+
handlePreviewDragCancel: (e: DragCancelEvent) => void;
|
|
28
|
+
};
|
|
29
|
+
export declare type useHierarchyPreviewHandlersArgs = {
|
|
30
|
+
setActiveId: React.Dispatch<React.SetStateAction<string>>;
|
|
31
|
+
onPreviewResetState: () => void;
|
|
32
|
+
onPreviewDragStart: () => void;
|
|
33
|
+
};
|
|
34
|
+
export declare type useHierarchyActionHandlersArgs = useHierarchyPreviewHandlersReturn & {
|
|
35
|
+
dndItems: Item[];
|
|
36
|
+
onReorder: (movedItem: Item, indexes: {
|
|
37
|
+
targetIndex: number;
|
|
38
|
+
fromIndex: number;
|
|
39
|
+
}) => void;
|
|
40
|
+
};
|
|
41
|
+
export declare type useHierarchyActionHandlersReturn = {
|
|
42
|
+
onDragStart: (e: DragStartEvent) => void;
|
|
43
|
+
onDragMove: (e: DragMoveEvent) => void;
|
|
44
|
+
onDragOver: (e: DragOverEvent) => void;
|
|
45
|
+
onDragEnd: (e: DragEndEvent) => void;
|
|
46
|
+
onDragCancel: (e: DragCancelEvent) => void;
|
|
47
|
+
};
|
|
48
|
+
export declare type useHierarchyDndkitConfigArgs = {
|
|
49
|
+
indentationWidth?: number;
|
|
50
|
+
dragOverlayDataTestid: string;
|
|
51
|
+
flattenedItems: [Item, unknown][];
|
|
52
|
+
isHorizontalDnD?: boolean;
|
|
53
|
+
onReorder: (movedItem: Item, indexes: {
|
|
54
|
+
targetIndex: number;
|
|
55
|
+
fromIndex: number;
|
|
56
|
+
}) => void;
|
|
57
|
+
onPreviewResetState: () => void;
|
|
58
|
+
onPreviewDragStart: () => void;
|
|
59
|
+
};
|
|
60
|
+
export declare type useHierarchyDndkitConfigType = (args: useHierarchyDndkitConfigArgs) => useHierarchyDndkitConfigReturn;
|
|
61
|
+
export declare type useHierarchyDndkitConfigReturn = {
|
|
62
|
+
dndContextProps: DndContextPropsType;
|
|
63
|
+
activeId: string | null;
|
|
64
|
+
overId: string | null;
|
|
65
|
+
activeIndex: number | undefined;
|
|
66
|
+
};
|
|
67
|
+
export declare type GetKeyboardCoordinatesArgs = {
|
|
68
|
+
items: Item[];
|
|
69
|
+
active: Active | null;
|
|
70
|
+
over: Over | null;
|
|
71
|
+
event: KeyboardEvent;
|
|
72
|
+
currentCoordinates: Coordinates;
|
|
73
|
+
droppableContainers: DroppableContainers;
|
|
74
|
+
collisionRect: ViewRect;
|
|
75
|
+
dragOverlayDataTestid: string;
|
|
76
|
+
};
|
|
77
|
+
export declare type SensorContext = MutableRefObject<{
|
|
78
|
+
items: Item[];
|
|
79
|
+
offset?: number;
|
|
80
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useHierarchyActionHandlers: ({ handlePreviewDragStart, handlePreviewDragMove, handlePreviewDragEnd, handlePreviewDragCancel, onReorder, dndItems, }: UseHierarchyActionHandlersArgs) => UseHierarchyActionHandlersReturn;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import type { useHierarchyPreviewHandlersReturn, useHierarchyPreviewHandlersArgs } from './types';
|
|
2
|
+
export declare const useHierarchyPreviewHandlers: ({ setActiveId, onPreviewResetState, onPreviewDragStart, }: useHierarchyPreviewHandlersArgs) => useHierarchyPreviewHandlersReturn;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { CollisionDetection } from '@dnd-kit/core';
|
|
2
|
+
import { DropIndicatorPosition } from './constants';
|
|
3
|
+
import { Item } from './types';
|
|
4
|
+
export declare const customCollisionDetection: (activeId: string, visibleItemsDictionary: Record<string, Item>, setDropIndicatorPosition: React.Dispatch<React.SetStateAction<DropIndicatorPosition>>, maxDragAndDropLevel: number, lastPosition: string, setLastPosition: React.Dispatch<React.SetStateAction<string>>) => CollisionDetection;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useTreeDndkitConfig';
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { Active, Announcements, CollisionDetection, DragCancelEvent, DragEndEvent, DragMoveEvent, DragOverEvent, DragStartEvent, DroppableContainers, MeasuringConfiguration, Modifier, Over, ViewRect } from '@dnd-kit/core';
|
|
2
|
+
import type { SensorDescriptor, SensorOptions } from '@dnd-kit/core/dist/sensors';
|
|
3
|
+
import type { SortingStrategy } from '@dnd-kit/sortable';
|
|
4
|
+
import { Coordinates } from '@dnd-kit/core/dist/types';
|
|
5
|
+
import React, { MutableRefObject } from 'react';
|
|
6
|
+
import { DropIndicatorPosition } from './constants';
|
|
7
|
+
export declare type Item<T = unknown> = {
|
|
8
|
+
uid: string;
|
|
9
|
+
depth: number;
|
|
10
|
+
parentId: string | null;
|
|
11
|
+
realIndex: number;
|
|
12
|
+
childrenCount: number;
|
|
13
|
+
original: T;
|
|
14
|
+
};
|
|
15
|
+
export declare type DndContextPropsType = {
|
|
16
|
+
announcements: Announcements;
|
|
17
|
+
modifiers: Modifier[];
|
|
18
|
+
sensors: SensorDescriptor<SensorOptions>[];
|
|
19
|
+
measuring: Partial<MeasuringConfiguration>;
|
|
20
|
+
collisionDetection: CollisionDetection;
|
|
21
|
+
onDragStart: (e: DragStartEvent) => void;
|
|
22
|
+
onDragMove: (e: DragMoveEvent) => void;
|
|
23
|
+
onDragOver: (e: DragOverEvent) => void;
|
|
24
|
+
onDragEnd: (e: DragEndEvent) => void;
|
|
25
|
+
onDragCancel: (e: DragCancelEvent) => void;
|
|
26
|
+
};
|
|
27
|
+
export declare type SortableContextPropsType = {
|
|
28
|
+
items: string[];
|
|
29
|
+
strategy: SortingStrategy;
|
|
30
|
+
};
|
|
31
|
+
export declare type UseTreePreviewHandlersReturn = {
|
|
32
|
+
handlePreviewDragStart: (e: DragStartEvent) => void;
|
|
33
|
+
handlePreviewDragMove: (e: DragMoveEvent) => void;
|
|
34
|
+
handlePreviewDragOver: (e: DragOverEvent) => void;
|
|
35
|
+
handlePreviewDragEnd: (e: DragEndEvent) => void;
|
|
36
|
+
handlePreviewDragCancel: (e: DragCancelEvent) => void;
|
|
37
|
+
};
|
|
38
|
+
export declare type UseTreePreviewHandlersArgs = {
|
|
39
|
+
setOverId: React.Dispatch<React.SetStateAction<string>>;
|
|
40
|
+
setActiveId: React.Dispatch<React.SetStateAction<string>>;
|
|
41
|
+
setDropIndicatorPosition: React.Dispatch<React.SetStateAction<DropIndicatorPosition>>;
|
|
42
|
+
};
|
|
43
|
+
export declare type UseTreeActionHandlersArgs<T = unknown> = UseTreePreviewHandlersReturn & {
|
|
44
|
+
dropIndicatorPosition: DropIndicatorPosition;
|
|
45
|
+
flattenedItems: Item[];
|
|
46
|
+
projected: {
|
|
47
|
+
depth: number;
|
|
48
|
+
parentId: string;
|
|
49
|
+
} | null;
|
|
50
|
+
onReorder: <S = T>(newData: Item<S>[], indexes: {
|
|
51
|
+
targetIndex: number;
|
|
52
|
+
fromIndex: number;
|
|
53
|
+
}, considerExpanding: string) => void;
|
|
54
|
+
isDropValid: boolean;
|
|
55
|
+
};
|
|
56
|
+
export declare type UseTreeActionHandlersReturn = {
|
|
57
|
+
onDragStart: (e: DragStartEvent) => void;
|
|
58
|
+
onDragMove: (e: DragMoveEvent) => void;
|
|
59
|
+
onDragOver: (e: DragOverEvent) => void;
|
|
60
|
+
onDragEnd: (e: DragEndEvent) => void;
|
|
61
|
+
onDragCancel: (e: DragCancelEvent) => void;
|
|
62
|
+
};
|
|
63
|
+
export declare type UseTreeDndkitConfigArgs<T> = {
|
|
64
|
+
flattenedItems: Item[];
|
|
65
|
+
visibleItems: Item[];
|
|
66
|
+
isHorizontalDnD?: boolean;
|
|
67
|
+
isExpandable: boolean;
|
|
68
|
+
onReorder: <S = T>(newData: Item<S>[], indexes: {
|
|
69
|
+
targetIndex: number;
|
|
70
|
+
fromIndex: number;
|
|
71
|
+
}, considerExpanding: string) => void;
|
|
72
|
+
getIsDropValid: <S = T>(active: Item<S>, over: Item<S>, dropIndicatorPosition: 'none' | 'before' | 'after' | 'inside') => boolean;
|
|
73
|
+
maxDragAndDropLevel: number;
|
|
74
|
+
};
|
|
75
|
+
export declare type UseTreeDndkitConfigReturn = {
|
|
76
|
+
dndContextProps: DndContextPropsType;
|
|
77
|
+
sortableContextProps: SortableContextPropsType;
|
|
78
|
+
activeId: string;
|
|
79
|
+
activeIndex: number;
|
|
80
|
+
overId: string;
|
|
81
|
+
depth: number;
|
|
82
|
+
dropIndicatorPosition: DropIndicatorPosition;
|
|
83
|
+
isDropValid: boolean;
|
|
84
|
+
visibleItems: Item[];
|
|
85
|
+
};
|
|
86
|
+
export declare type UseTreeDndkitConfigType = <T = unknown>(args: UseTreeDndkitConfigArgs<T>) => UseTreeDndkitConfigReturn;
|
|
87
|
+
export declare type GetKeyboardCoordinatesArgs = {
|
|
88
|
+
items: Item[];
|
|
89
|
+
active: Active;
|
|
90
|
+
over: Over;
|
|
91
|
+
event: KeyboardEvent;
|
|
92
|
+
currentCoordinates: Coordinates;
|
|
93
|
+
droppableContainers: DroppableContainers;
|
|
94
|
+
collisionRect: ViewRect;
|
|
95
|
+
dropIndicatorPosition: DropIndicatorPosition;
|
|
96
|
+
maxDragAndDropLevel: number;
|
|
97
|
+
};
|
|
98
|
+
export declare type SensorContext = MutableRefObject<{
|
|
99
|
+
items: Item[];
|
|
100
|
+
dropIndicatorPosition: DropIndicatorPosition;
|
|
101
|
+
setDropIndicatorPosition: React.Dispatch<React.SetStateAction<DropIndicatorPosition>>;
|
|
102
|
+
}>;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import type { UseTreeActionHandlersReturn, UseTreeActionHandlersArgs } from './types';
|
|
2
|
+
export declare const useTreeActionHandlers: ({ handlePreviewDragStart, handlePreviewDragMove, handlePreviewDragOver, handlePreviewDragEnd, handlePreviewDragCancel, onReorder, flattenedItems, projected, dropIndicatorPosition, isDropValid, }: UseTreeActionHandlersArgs) => UseTreeActionHandlersReturn;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Announcements } from '@dnd-kit/core';
|
|
2
|
+
import { DropIndicatorPosition } from './constants';
|
|
3
|
+
import { Item } from './types';
|
|
4
|
+
export declare const useTreeAnnouncements: (visibleItemsDictionary: Record<string, Item>, dropIndicatorPosition: DropIndicatorPosition) => Announcements;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DropIndicatorPosition } from './constants';
|
|
2
|
+
import { Item } from './types';
|
|
3
|
+
export declare const getProjection: (items: Item[], visibleItemsDictionary: Record<string, Item>, overId: string, dropIndicatorPosition: DropIndicatorPosition, isExpandable: boolean) => {
|
|
4
|
+
depth: number;
|
|
5
|
+
parentId: string;
|
|
6
|
+
};
|
|
7
|
+
export declare const removeChildrenOf: (items: Item[], id: string) => Item[];
|