@btfash/react-native-reanimated-dnd 1.1.1 → 1.1.3
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/lib/components/Sortable.d.ts +6 -2
- package/lib/components/SortableItem.d.ts +2 -2
- package/lib/components/sortableUtils.d.ts +6 -15
- package/lib/hooks/useDroppable.d.ts +2 -1
- package/lib/hooks/useHorizontalSortable.d.ts +2 -2
- package/lib/hooks/useHorizontalSortableList.d.ts +3 -2
- package/lib/hooks/useSortable.d.ts +16 -17
- package/lib/hooks/useSortableList.d.ts +7 -6
- package/lib/types/context.d.ts +16 -15
- package/lib/types/draggable.d.ts +4 -3
- package/lib/types/droppable.d.ts +4 -3
- package/lib/types/sortable.d.ts +49 -64
- package/package.json +1 -1
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { SortableProps } from "../types/sortable";
|
|
3
|
-
|
|
2
|
+
import { SortableProps, UniqueIdentifier } from "../types/sortable";
|
|
3
|
+
declare function SortableComponent<TData extends {
|
|
4
|
+
id: TID;
|
|
5
|
+
}, TID extends UniqueIdentifier = string>({ data, renderItem, direction, itemHeight, itemWidth, gap, paddingHorizontal, style, contentContainerStyle, itemKeyExtractor, useFlatList, }: SortableProps<TData, TID>): React.JSX.Element;
|
|
6
|
+
export declare const Sortable: typeof SortableComponent;
|
|
7
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { SortableItemProps, SortableHandleProps } from "../types/sortable";
|
|
3
|
-
export declare function SortableItem<T>({ id, data, positions, direction, lowerBound, leftBound, autoScrollDirection, autoScrollHorizontalDirection, itemsCount, itemHeight, itemWidth, gap, paddingHorizontal, containerHeight, containerWidth, children, style, animatedStyle: customAnimatedStyle, onMove, onDragStart, onDrop, onDragging, onDraggingHorizontal, }: SortableItemProps<T>): React.JSX.Element;
|
|
2
|
+
import { SortableItemProps, SortableHandleProps, UniqueIdentifier } from "../types/sortable";
|
|
3
|
+
export declare function SortableItem<T, TID extends UniqueIdentifier>({ id, data, positions, direction, lowerBound, leftBound, autoScrollDirection, autoScrollHorizontalDirection, itemsCount, itemHeight, itemWidth, gap, paddingHorizontal, containerHeight, containerWidth, children, style, animatedStyle: customAnimatedStyle, onMove, onDragStart, onDrop, onDragging, onDraggingHorizontal, }: SortableItemProps<T, TID>): React.JSX.Element;
|
|
4
4
|
export declare namespace SortableItem {
|
|
5
5
|
var Handle: ({ children, style }: SortableHandleProps) => React.JSX.Element;
|
|
6
6
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SharedValue } from "react-native-reanimated";
|
|
2
|
+
import { UniqueIdentifier } from "../types";
|
|
2
3
|
export declare enum ScrollDirection {
|
|
3
4
|
None = "none",
|
|
4
5
|
Up = "up",
|
|
@@ -10,24 +11,14 @@ export declare enum HorizontalScrollDirection {
|
|
|
10
11
|
Right = "right"
|
|
11
12
|
}
|
|
12
13
|
export declare function clamp(value: number, lowerBound: number, upperBound: number): number;
|
|
13
|
-
export declare function objectMove(object:
|
|
14
|
-
[id: string]: number;
|
|
15
|
-
}, from: number, to: number): {
|
|
16
|
-
[id: string]: number;
|
|
17
|
-
};
|
|
14
|
+
export declare function objectMove<TID extends UniqueIdentifier>(object: Record<TID, number>, from: number, to: number): Record<TID, number>;
|
|
18
15
|
export declare function listToObject<T extends {
|
|
19
|
-
id:
|
|
20
|
-
}>(list: T[]):
|
|
21
|
-
|
|
22
|
-
};
|
|
23
|
-
export declare function setPosition(positionY: number, itemsCount: number, positions: SharedValue<{
|
|
24
|
-
[id: string]: number;
|
|
25
|
-
}>, id: string, itemHeight: number): void;
|
|
16
|
+
id: TID;
|
|
17
|
+
}, TID extends UniqueIdentifier>(list: T[]): Record<TID, number>;
|
|
18
|
+
export declare function setPosition<TID extends UniqueIdentifier>(positionY: number, itemsCount: number, positions: SharedValue<Record<TID, number>>, id: TID, itemHeight: number): void;
|
|
26
19
|
export declare function setAutoScroll(positionY: number, lowerBound: number, upperBound: number, scrollThreshold: number, autoScroll: SharedValue<ScrollDirection>): void;
|
|
27
20
|
export declare function getItemXPosition(position: number, itemWidth: number, gap?: number, paddingHorizontal?: number): number;
|
|
28
21
|
export declare function getContentWidth(itemsCount: number, itemWidth: number, gap?: number, paddingHorizontal?: number): number;
|
|
29
|
-
export declare function setHorizontalPosition(positionX: number, itemsCount: number, positions: SharedValue<
|
|
30
|
-
[id: string]: number;
|
|
31
|
-
}>, id: string, itemWidth: number, gap?: number, paddingHorizontal?: number): void;
|
|
22
|
+
export declare function setHorizontalPosition<TID extends UniqueIdentifier>(positionX: number, itemsCount: number, positions: SharedValue<Record<TID, number>>, id: TID, itemWidth: number, gap?: number, paddingHorizontal?: number): void;
|
|
32
23
|
export declare function setHorizontalAutoScroll(positionX: number, leftBound: number, rightBound: number, scrollThreshold: number, autoScrollDirection: SharedValue<HorizontalScrollDirection>): void;
|
|
33
24
|
export declare const dataHash: (data: any[]) => string;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { UseDroppableOptions, UseDroppableReturn } from "../types/droppable";
|
|
2
|
-
|
|
2
|
+
import { UniqueIdentifier } from "../types";
|
|
3
|
+
export declare const useDroppable: <TData = unknown, TID extends UniqueIdentifier = string>(options: UseDroppableOptions<TData, TID>) => UseDroppableReturn;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { UseHorizontalSortableOptions, UseHorizontalSortableReturn } from "../types/sortable";
|
|
2
|
-
export declare function useHorizontalSortable<T>(options: UseHorizontalSortableOptions<T>): UseHorizontalSortableReturn;
|
|
1
|
+
import { UniqueIdentifier, UseHorizontalSortableOptions, UseHorizontalSortableReturn } from "../types/sortable";
|
|
2
|
+
export declare function useHorizontalSortable<T, TID extends UniqueIdentifier>(options: UseHorizontalSortableOptions<T, TID>): UseHorizontalSortableReturn;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import { UniqueIdentifier } from "../types/sortable";
|
|
1
2
|
import { UseHorizontalSortableListOptions, UseHorizontalSortableListReturn } from "../types/sortable";
|
|
2
3
|
export declare function useHorizontalSortableList<TData extends {
|
|
3
|
-
id:
|
|
4
|
-
}>(options: UseHorizontalSortableListOptions<TData>): UseHorizontalSortableListReturn<TData>;
|
|
4
|
+
id: TID;
|
|
5
|
+
}, TID extends UniqueIdentifier = string>(options: UseHorizontalSortableListOptions<TData, TID>): UseHorizontalSortableListReturn<TData, TID>;
|
|
@@ -2,42 +2,41 @@ import { StyleProp, ViewStyle } from "react-native";
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { SharedValue } from "react-native-reanimated";
|
|
4
4
|
import { GestureType } from "react-native-gesture-handler";
|
|
5
|
+
import { UniqueIdentifier } from "../types";
|
|
5
6
|
export declare enum ScrollDirection {
|
|
6
7
|
None = "none",
|
|
7
8
|
Up = "up",
|
|
8
9
|
Down = "down"
|
|
9
10
|
}
|
|
10
11
|
export declare function clamp(value: number, lowerBound: number, upperBound: number): number;
|
|
11
|
-
export declare function objectMove(object: {
|
|
12
|
-
[id
|
|
13
|
-
}, from: number, to: number): {
|
|
14
|
-
[id: string]: number;
|
|
15
|
-
};
|
|
12
|
+
export declare function objectMove<TID extends UniqueIdentifier>(object: {
|
|
13
|
+
[id in TID]: number;
|
|
14
|
+
}, from: number, to: number): { [id in TID]: number; };
|
|
16
15
|
export declare function listToObject<T extends {
|
|
17
16
|
id: string;
|
|
18
17
|
}>(list: T[]): {
|
|
19
18
|
[id: string]: number;
|
|
20
19
|
};
|
|
21
|
-
export declare function setPosition(positionY: number, itemsCount: number, positions: SharedValue<{
|
|
22
|
-
[id
|
|
23
|
-
}>, id:
|
|
20
|
+
export declare function setPosition<TID extends UniqueIdentifier>(positionY: number, itemsCount: number, positions: SharedValue<{
|
|
21
|
+
[id in TID]: number;
|
|
22
|
+
}>, id: TID, itemHeight: number): void;
|
|
24
23
|
export declare function setAutoScroll(positionY: number, lowerBound: number, upperBound: number, scrollThreshold: number, autoScroll: SharedValue<ScrollDirection>): void;
|
|
25
|
-
export interface UseSortableOptions<T> {
|
|
26
|
-
id:
|
|
24
|
+
export interface UseSortableOptions<T, TID extends UniqueIdentifier> {
|
|
25
|
+
id: TID;
|
|
27
26
|
positions: SharedValue<{
|
|
28
|
-
[id
|
|
27
|
+
[id in TID]: number;
|
|
29
28
|
}>;
|
|
30
29
|
lowerBound: SharedValue<number>;
|
|
31
30
|
autoScrollDirection: SharedValue<ScrollDirection>;
|
|
32
31
|
itemsCount: number;
|
|
33
32
|
itemHeight: number;
|
|
34
33
|
containerHeight?: number;
|
|
35
|
-
onMove?: (id:
|
|
36
|
-
onDragStart?: (id:
|
|
37
|
-
onDrop?: (id:
|
|
38
|
-
[id
|
|
34
|
+
onMove?: (id: TID, from: number, to: number) => void;
|
|
35
|
+
onDragStart?: (id: TID, position: number) => void;
|
|
36
|
+
onDrop?: (id: TID, position: number, allPositions?: {
|
|
37
|
+
[id in TID]: number;
|
|
39
38
|
}) => void;
|
|
40
|
-
onDragging?: (id:
|
|
39
|
+
onDragging?: (id: TID, overItemId: TID | null, yPosition: number) => void;
|
|
41
40
|
children?: React.ReactNode;
|
|
42
41
|
handleComponent?: React.ComponentType<any>;
|
|
43
42
|
}
|
|
@@ -47,4 +46,4 @@ export interface UseSortableReturn {
|
|
|
47
46
|
isMoving: boolean;
|
|
48
47
|
hasHandle: boolean;
|
|
49
48
|
}
|
|
50
|
-
export declare function useSortable<T>(options: UseSortableOptions<T>): UseSortableReturn;
|
|
49
|
+
export declare function useSortable<T, TID extends UniqueIdentifier>(options: UseSortableOptions<T, TID>): UseSortableReturn;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { UniqueIdentifier } from "../types/sortable";
|
|
1
2
|
import { DropProviderRef } from "../types/context";
|
|
2
|
-
export interface UseSortableListOptions<TData> {
|
|
3
|
+
export interface UseSortableListOptions<TData, TID extends UniqueIdentifier = string> {
|
|
3
4
|
data: TData[];
|
|
4
5
|
itemHeight: number;
|
|
5
|
-
itemKeyExtractor?: (item: TData, index: number) =>
|
|
6
|
+
itemKeyExtractor?: (item: TData, index: number) => TID;
|
|
6
7
|
}
|
|
7
|
-
export interface UseSortableListReturn<TData> {
|
|
8
|
+
export interface UseSortableListReturn<TData, TID extends UniqueIdentifier> {
|
|
8
9
|
positions: any;
|
|
9
10
|
scrollY: any;
|
|
10
11
|
autoScroll: any;
|
|
@@ -14,7 +15,7 @@ export interface UseSortableListReturn<TData> {
|
|
|
14
15
|
handleScrollEnd: () => void;
|
|
15
16
|
contentHeight: number;
|
|
16
17
|
getItemProps: (item: TData, index: number) => {
|
|
17
|
-
id:
|
|
18
|
+
id: TID;
|
|
18
19
|
positions: any;
|
|
19
20
|
lowerBound: any;
|
|
20
21
|
autoScrollDirection: any;
|
|
@@ -23,5 +24,5 @@ export interface UseSortableListReturn<TData> {
|
|
|
23
24
|
};
|
|
24
25
|
}
|
|
25
26
|
export declare function useSortableList<TData extends {
|
|
26
|
-
id:
|
|
27
|
-
}>(options: UseSortableListOptions<TData>): UseSortableListReturn<TData>;
|
|
27
|
+
id: TID;
|
|
28
|
+
}, TID extends UniqueIdentifier = string>(options: UseSortableListOptions<TData, TID>): UseSortableListReturn<TData, TID>;
|
package/lib/types/context.d.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
|
+
import { UniqueIdentifier } from "./sortable";
|
|
2
3
|
export type DropAlignment = "center" | "top-left" | "top-center" | "top-right" | "center-left" | "center-right" | "bottom-left" | "bottom-center" | "bottom-right";
|
|
3
4
|
export interface DropOffset {
|
|
4
5
|
x: number;
|
|
5
6
|
y: number;
|
|
6
7
|
}
|
|
7
|
-
export
|
|
8
|
-
[draggableId
|
|
9
|
-
droppableId:
|
|
8
|
+
export type DroppedItemsMap<TData = unknown, TID extends UniqueIdentifier = string> = {
|
|
9
|
+
[draggableId in TID]: {
|
|
10
|
+
droppableId: TID;
|
|
10
11
|
data: TData;
|
|
11
12
|
};
|
|
12
|
-
}
|
|
13
|
-
export interface DropSlot<TData = unknown> {
|
|
14
|
-
id:
|
|
13
|
+
};
|
|
14
|
+
export interface DropSlot<TData = unknown, TID extends UniqueIdentifier = string> {
|
|
15
|
+
id: TID;
|
|
15
16
|
x: number;
|
|
16
17
|
y: number;
|
|
17
18
|
width: number;
|
|
@@ -22,20 +23,20 @@ export interface DropSlot<TData = unknown> {
|
|
|
22
23
|
capacity?: number;
|
|
23
24
|
}
|
|
24
25
|
export type PositionUpdateListener = () => void;
|
|
25
|
-
export interface SlotsContextValue<TData = unknown> {
|
|
26
|
-
register: (id: number, slot: DropSlot<TData>) => void;
|
|
26
|
+
export interface SlotsContextValue<TData = unknown, TID extends UniqueIdentifier = string> {
|
|
27
|
+
register: (id: number, slot: DropSlot<TData, TID>) => void;
|
|
27
28
|
unregister: (id: number) => void;
|
|
28
|
-
getSlots: () => Record<number, DropSlot<TData>>;
|
|
29
|
+
getSlots: () => Record<number, DropSlot<TData, TID>>;
|
|
29
30
|
isRegistered: (id: number) => boolean;
|
|
30
31
|
setActiveHoverSlot: (id: number | null) => void;
|
|
31
32
|
activeHoverSlotId: number | null;
|
|
32
|
-
registerPositionUpdateListener: (id:
|
|
33
|
-
unregisterPositionUpdateListener: (id:
|
|
33
|
+
registerPositionUpdateListener: (id: TID, listener: PositionUpdateListener) => void;
|
|
34
|
+
unregisterPositionUpdateListener: (id: TID) => void;
|
|
34
35
|
requestPositionUpdate: () => void;
|
|
35
|
-
registerDroppedItem: (draggableId:
|
|
36
|
-
unregisterDroppedItem: (draggableId:
|
|
36
|
+
registerDroppedItem: (draggableId: TID, droppableId: TID, itemData: any) => void;
|
|
37
|
+
unregisterDroppedItem: (draggableId: TID) => void;
|
|
37
38
|
getDroppedItems: () => DroppedItemsMap<any>;
|
|
38
|
-
hasAvailableCapacity: (droppableId:
|
|
39
|
+
hasAvailableCapacity: (droppableId: TID) => boolean;
|
|
39
40
|
onDragging?: (payload: {
|
|
40
41
|
x: number;
|
|
41
42
|
y: number;
|
|
@@ -46,7 +47,7 @@ export interface SlotsContextValue<TData = unknown> {
|
|
|
46
47
|
onDragStart?: (data: any) => void;
|
|
47
48
|
onDragEnd?: (data: any) => void;
|
|
48
49
|
}
|
|
49
|
-
export declare const SlotsContext: import("react").Context<SlotsContextValue<any>>;
|
|
50
|
+
export declare const SlotsContext: import("react").Context<SlotsContextValue<any, string>>;
|
|
50
51
|
export interface DropProviderProps {
|
|
51
52
|
children: ReactNode;
|
|
52
53
|
onLayoutUpdateComplete?: () => void;
|
package/lib/types/draggable.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { ViewStyle, View, StyleProp } from "react-native";
|
|
|
2
2
|
import Animated, { AnimatedStyle, useAnimatedRef } from "react-native-reanimated";
|
|
3
3
|
import { GestureType } from "react-native-gesture-handler";
|
|
4
4
|
import { LayoutChangeEvent } from "react-native";
|
|
5
|
+
import { UniqueIdentifier } from "./sortable";
|
|
5
6
|
export declare enum DraggableState {
|
|
6
7
|
IDLE = "IDLE",
|
|
7
8
|
DRAGGING = "DRAGGING",
|
|
@@ -9,9 +10,9 @@ export declare enum DraggableState {
|
|
|
9
10
|
}
|
|
10
11
|
export type AnimationFunction = (toValue: number) => number;
|
|
11
12
|
export type CollisionAlgorithm = "center" | "intersect" | "contain";
|
|
12
|
-
export interface UseDraggableOptions<TData = unknown> {
|
|
13
|
+
export interface UseDraggableOptions<TData = unknown, TID extends UniqueIdentifier = string> {
|
|
13
14
|
data: TData;
|
|
14
|
-
draggableId?:
|
|
15
|
+
draggableId?: TID;
|
|
15
16
|
dragDisabled?: boolean;
|
|
16
17
|
preDragDelay?: number;
|
|
17
18
|
onDragStart?: (data: TData) => void;
|
|
@@ -43,7 +44,7 @@ export interface DraggableContextValue {
|
|
|
43
44
|
gesture: any;
|
|
44
45
|
state: DraggableState;
|
|
45
46
|
}
|
|
46
|
-
export interface DraggableProps<TData = unknown> extends UseDraggableOptions<TData> {
|
|
47
|
+
export interface DraggableProps<TData = unknown, TID extends UniqueIdentifier = string> extends UseDraggableOptions<TData, TID> {
|
|
47
48
|
style?: StyleProp<ViewStyle>;
|
|
48
49
|
children: React.ReactNode;
|
|
49
50
|
onStateChange?: (state: DraggableState) => void;
|
package/lib/types/droppable.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { LayoutChangeEvent, StyleProp, ViewStyle } from "react-native";
|
|
2
2
|
import Animated, { useAnimatedRef } from "react-native-reanimated";
|
|
3
3
|
import { DropAlignment, DropOffset } from "./context";
|
|
4
|
-
|
|
4
|
+
import { UniqueIdentifier } from "./sortable";
|
|
5
|
+
export interface UseDroppableOptions<TData = unknown, TID extends UniqueIdentifier = string> {
|
|
5
6
|
onDrop: (data: TData) => void;
|
|
6
7
|
dropDisabled?: boolean;
|
|
7
8
|
onActiveChange?: (isActive: boolean) => void;
|
|
8
9
|
dropAlignment?: DropAlignment;
|
|
9
10
|
dropOffset?: DropOffset;
|
|
10
11
|
activeStyle?: StyleProp<ViewStyle>;
|
|
11
|
-
droppableId?:
|
|
12
|
+
droppableId?: TID;
|
|
12
13
|
capacity?: number;
|
|
13
14
|
}
|
|
14
15
|
export interface UseDroppableReturn {
|
|
@@ -20,7 +21,7 @@ export interface UseDroppableReturn {
|
|
|
20
21
|
activeStyle?: StyleProp<ViewStyle>;
|
|
21
22
|
animatedViewRef: ReturnType<typeof useAnimatedRef<Animated.View>>;
|
|
22
23
|
}
|
|
23
|
-
export interface DroppableProps<TData = unknown> extends UseDroppableOptions<TData> {
|
|
24
|
+
export interface DroppableProps<TData = unknown, TID extends UniqueIdentifier = string> extends UseDroppableOptions<TData, TID> {
|
|
24
25
|
style?: StyleProp<ViewStyle>;
|
|
25
26
|
children: React.ReactNode;
|
|
26
27
|
}
|
package/lib/types/sortable.d.ts
CHANGED
|
@@ -2,8 +2,9 @@ import { StyleProp, ViewStyle } from "react-native";
|
|
|
2
2
|
import { SharedValue } from "react-native-reanimated";
|
|
3
3
|
import { DropProviderRef } from "../types/context";
|
|
4
4
|
import { ReactNode } from "react";
|
|
5
|
-
export
|
|
6
|
-
|
|
5
|
+
export type UniqueIdentifier = string | number;
|
|
6
|
+
export interface SortableData<TID extends UniqueIdentifier = string> {
|
|
7
|
+
id: TID;
|
|
7
8
|
}
|
|
8
9
|
export declare enum ScrollDirection {
|
|
9
10
|
None = "none",
|
|
@@ -19,22 +20,20 @@ export declare enum SortableDirection {
|
|
|
19
20
|
Vertical = "vertical",
|
|
20
21
|
Horizontal = "horizontal"
|
|
21
22
|
}
|
|
22
|
-
export interface UseSortableOptions<T> {
|
|
23
|
-
id:
|
|
24
|
-
positions: SharedValue<
|
|
25
|
-
[id: string]: number;
|
|
26
|
-
}>;
|
|
23
|
+
export interface UseSortableOptions<T, TID extends UniqueIdentifier = string> {
|
|
24
|
+
id: TID;
|
|
25
|
+
positions: SharedValue<Record<TID, number>>;
|
|
27
26
|
lowerBound: SharedValue<number>;
|
|
28
27
|
autoScrollDirection: SharedValue<ScrollDirection>;
|
|
29
28
|
itemsCount: number;
|
|
30
29
|
itemHeight: number;
|
|
31
30
|
containerHeight?: number;
|
|
32
|
-
onMove?: (id:
|
|
33
|
-
onDragStart?: (id:
|
|
34
|
-
onDrop?: (id:
|
|
35
|
-
[id
|
|
31
|
+
onMove?: (id: TID, from: number, to: number) => void;
|
|
32
|
+
onDragStart?: (id: TID, position: number) => void;
|
|
33
|
+
onDrop?: (id: TID, position: number, allPositions?: {
|
|
34
|
+
[id in TID]: number;
|
|
36
35
|
}) => void;
|
|
37
|
-
onDragging?: (id:
|
|
36
|
+
onDragging?: (id: TID, overItemId: TID | null, yPosition: number) => void;
|
|
38
37
|
}
|
|
39
38
|
export interface UseSortableReturn {
|
|
40
39
|
animatedStyle: StyleProp<ViewStyle>;
|
|
@@ -42,12 +41,12 @@ export interface UseSortableReturn {
|
|
|
42
41
|
isMoving: boolean;
|
|
43
42
|
hasHandle: boolean;
|
|
44
43
|
}
|
|
45
|
-
export interface UseSortableListOptions<TData extends SortableData> {
|
|
44
|
+
export interface UseSortableListOptions<TData extends SortableData<TID>, TID extends UniqueIdentifier = string> {
|
|
46
45
|
data: TData[];
|
|
47
46
|
itemHeight: number;
|
|
48
47
|
itemKeyExtractor?: (item: TData, index: number) => string;
|
|
49
48
|
}
|
|
50
|
-
export interface UseSortableListReturn<TData extends SortableData> {
|
|
49
|
+
export interface UseSortableListReturn<TData extends SortableData<TID>, TID extends UniqueIdentifier = string> {
|
|
51
50
|
positions: any;
|
|
52
51
|
scrollY: any;
|
|
53
52
|
autoScroll: any;
|
|
@@ -65,12 +64,10 @@ export interface UseSortableListReturn<TData extends SortableData> {
|
|
|
65
64
|
itemHeight: number;
|
|
66
65
|
};
|
|
67
66
|
}
|
|
68
|
-
export interface SortableItemProps<T> {
|
|
69
|
-
id:
|
|
67
|
+
export interface SortableItemProps<T, TID extends UniqueIdentifier> {
|
|
68
|
+
id: TID;
|
|
70
69
|
data: T;
|
|
71
|
-
positions: SharedValue<
|
|
72
|
-
[id: string]: number;
|
|
73
|
-
}>;
|
|
70
|
+
positions: SharedValue<Record<TID, number>>;
|
|
74
71
|
lowerBound?: SharedValue<number>;
|
|
75
72
|
leftBound?: SharedValue<number>;
|
|
76
73
|
autoScrollDirection?: SharedValue<ScrollDirection>;
|
|
@@ -86,17 +83,15 @@ export interface SortableItemProps<T> {
|
|
|
86
83
|
children: ReactNode;
|
|
87
84
|
style?: StyleProp<ViewStyle>;
|
|
88
85
|
animatedStyle?: StyleProp<ViewStyle>;
|
|
89
|
-
onMove?: (id:
|
|
90
|
-
onDragStart?: (id:
|
|
91
|
-
onDrop?: (id:
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
onDragging?: (id: string, overItemId: string | null, yPosition: number) => void;
|
|
95
|
-
onDraggingHorizontal?: (id: string, overItemId: string | null, xPosition: number) => void;
|
|
86
|
+
onMove?: (id: TID, from: number, to: number) => void;
|
|
87
|
+
onDragStart?: (id: TID, position: number) => void;
|
|
88
|
+
onDrop?: (id: TID, position: number, allPositions?: Record<TID, number>) => void;
|
|
89
|
+
onDragging?: (id: TID, overItemId: TID | null, yPosition: number) => void;
|
|
90
|
+
onDraggingHorizontal?: (id: TID, overItemId: TID | null, xPosition: number) => void;
|
|
96
91
|
}
|
|
97
|
-
export interface SortableProps<TData extends SortableData> {
|
|
92
|
+
export interface SortableProps<TData extends SortableData<TID>, TID extends UniqueIdentifier> {
|
|
98
93
|
data: TData[];
|
|
99
|
-
renderItem: (props: SortableRenderItemProps<TData>) => ReactNode;
|
|
94
|
+
renderItem: (props: SortableRenderItemProps<TData, TID>) => ReactNode;
|
|
100
95
|
direction?: SortableDirection;
|
|
101
96
|
itemHeight?: number;
|
|
102
97
|
itemWidth?: number;
|
|
@@ -104,16 +99,14 @@ export interface SortableProps<TData extends SortableData> {
|
|
|
104
99
|
paddingHorizontal?: number;
|
|
105
100
|
style?: StyleProp<ViewStyle>;
|
|
106
101
|
contentContainerStyle?: StyleProp<ViewStyle>;
|
|
107
|
-
itemKeyExtractor?: (item: TData, index: number) =>
|
|
102
|
+
itemKeyExtractor?: (item: TData, index: number) => TID;
|
|
108
103
|
useFlatList?: boolean;
|
|
109
104
|
}
|
|
110
|
-
export interface SortableRenderItemProps<TData extends SortableData> {
|
|
105
|
+
export interface SortableRenderItemProps<TData extends SortableData<TID>, TID extends UniqueIdentifier> {
|
|
111
106
|
item: TData;
|
|
112
107
|
index: number;
|
|
113
|
-
id:
|
|
114
|
-
positions: SharedValue<
|
|
115
|
-
[id: string]: number;
|
|
116
|
-
}>;
|
|
108
|
+
id: TID;
|
|
109
|
+
positions: SharedValue<Record<TID, number>>;
|
|
117
110
|
direction?: SortableDirection;
|
|
118
111
|
lowerBound?: SharedValue<number>;
|
|
119
112
|
leftBound?: SharedValue<number>;
|
|
@@ -132,11 +125,9 @@ export interface SortableHandleProps {
|
|
|
132
125
|
children: React.ReactNode;
|
|
133
126
|
style?: StyleProp<ViewStyle>;
|
|
134
127
|
}
|
|
135
|
-
export interface UseHorizontalSortableOptions<T> {
|
|
136
|
-
id:
|
|
137
|
-
positions: SharedValue<
|
|
138
|
-
[id: string]: number;
|
|
139
|
-
}>;
|
|
128
|
+
export interface UseHorizontalSortableOptions<T, TID extends UniqueIdentifier = string> {
|
|
129
|
+
id: TID;
|
|
130
|
+
positions: SharedValue<Record<TID, number>>;
|
|
140
131
|
leftBound: SharedValue<number>;
|
|
141
132
|
autoScrollDirection: SharedValue<HorizontalScrollDirection>;
|
|
142
133
|
itemsCount: number;
|
|
@@ -144,12 +135,10 @@ export interface UseHorizontalSortableOptions<T> {
|
|
|
144
135
|
gap?: number;
|
|
145
136
|
paddingHorizontal?: number;
|
|
146
137
|
containerWidth?: number;
|
|
147
|
-
onMove?: (id:
|
|
148
|
-
onDragStart?: (id:
|
|
149
|
-
onDrop?: (id:
|
|
150
|
-
|
|
151
|
-
}) => void;
|
|
152
|
-
onDragging?: (id: string, overItemId: string | null, xPosition: number) => void;
|
|
138
|
+
onMove?: (id: TID, from: number, to: number) => void;
|
|
139
|
+
onDragStart?: (id: TID, position: number) => void;
|
|
140
|
+
onDrop?: (id: TID, position: number, allPositions?: Record<TID, number>) => void;
|
|
141
|
+
onDragging?: (id: TID, overItemId: TID | null, xPosition: number) => void;
|
|
153
142
|
}
|
|
154
143
|
export interface UseHorizontalSortableReturn {
|
|
155
144
|
animatedStyle: StyleProp<ViewStyle>;
|
|
@@ -157,14 +146,14 @@ export interface UseHorizontalSortableReturn {
|
|
|
157
146
|
isMoving: boolean;
|
|
158
147
|
hasHandle: boolean;
|
|
159
148
|
}
|
|
160
|
-
export interface UseHorizontalSortableListOptions<TData extends SortableData> {
|
|
149
|
+
export interface UseHorizontalSortableListOptions<TData extends SortableData<TID>, TID extends UniqueIdentifier = string> {
|
|
161
150
|
data: TData[];
|
|
162
151
|
itemWidth: number;
|
|
163
152
|
gap?: number;
|
|
164
153
|
paddingHorizontal?: number;
|
|
165
|
-
itemKeyExtractor?: (item: TData, index: number) =>
|
|
154
|
+
itemKeyExtractor?: (item: TData, index: number) => TID;
|
|
166
155
|
}
|
|
167
|
-
export interface UseHorizontalSortableListReturn<TData extends SortableData> {
|
|
156
|
+
export interface UseHorizontalSortableListReturn<TData extends SortableData<TID>, TID extends UniqueIdentifier = string> {
|
|
168
157
|
positions: any;
|
|
169
158
|
scrollX: any;
|
|
170
159
|
autoScroll: any;
|
|
@@ -174,7 +163,7 @@ export interface UseHorizontalSortableListReturn<TData extends SortableData> {
|
|
|
174
163
|
handleScrollEnd: () => void;
|
|
175
164
|
contentWidth: number;
|
|
176
165
|
getItemProps: (item: TData, index: number) => {
|
|
177
|
-
id:
|
|
166
|
+
id: TID;
|
|
178
167
|
positions: any;
|
|
179
168
|
leftBound: any;
|
|
180
169
|
autoScrollDirection: any;
|
|
@@ -184,12 +173,10 @@ export interface UseHorizontalSortableListReturn<TData extends SortableData> {
|
|
|
184
173
|
paddingHorizontal: number;
|
|
185
174
|
};
|
|
186
175
|
}
|
|
187
|
-
export interface HorizontalSortableItemProps<T> {
|
|
188
|
-
id:
|
|
176
|
+
export interface HorizontalSortableItemProps<T, TID extends UniqueIdentifier = string> {
|
|
177
|
+
id: TID;
|
|
189
178
|
data: T;
|
|
190
|
-
positions: SharedValue<
|
|
191
|
-
[id: string]: number;
|
|
192
|
-
}>;
|
|
179
|
+
positions: SharedValue<Record<TID, number>>;
|
|
193
180
|
leftBound: SharedValue<number>;
|
|
194
181
|
autoScrollDirection: SharedValue<HorizontalScrollDirection>;
|
|
195
182
|
itemsCount: number;
|
|
@@ -200,24 +187,22 @@ export interface HorizontalSortableItemProps<T> {
|
|
|
200
187
|
children: ReactNode;
|
|
201
188
|
style?: StyleProp<ViewStyle>;
|
|
202
189
|
animatedStyle?: StyleProp<ViewStyle>;
|
|
203
|
-
onMove?: (id:
|
|
204
|
-
onDragStart?: (id:
|
|
205
|
-
onDrop?: (id:
|
|
206
|
-
|
|
207
|
-
}) => void;
|
|
208
|
-
onDragging?: (id: string, overItemId: string | null, xPosition: number) => void;
|
|
190
|
+
onMove?: (id: TID, from: number, to: number) => void;
|
|
191
|
+
onDragStart?: (id: TID, position: number) => void;
|
|
192
|
+
onDrop?: (id: TID, position: number, allPositions?: Record<TID, number>) => void;
|
|
193
|
+
onDragging?: (id: TID, overItemId: TID | null, xPosition: number) => void;
|
|
209
194
|
}
|
|
210
|
-
export interface HorizontalSortableProps<TData extends SortableData> {
|
|
195
|
+
export interface HorizontalSortableProps<TData extends SortableData<TID>, TID extends UniqueIdentifier = string> {
|
|
211
196
|
data: TData[];
|
|
212
|
-
renderItem: (props: HorizontalSortableRenderItemProps<TData>) => ReactNode;
|
|
197
|
+
renderItem: (props: HorizontalSortableRenderItemProps<TData, TID>) => ReactNode;
|
|
213
198
|
itemWidth: number;
|
|
214
199
|
gap?: number;
|
|
215
200
|
paddingHorizontal?: number;
|
|
216
201
|
style?: StyleProp<ViewStyle>;
|
|
217
202
|
contentContainerStyle?: StyleProp<ViewStyle>;
|
|
218
|
-
itemKeyExtractor?: (item: TData, index: number) =>
|
|
203
|
+
itemKeyExtractor?: (item: TData, index: number) => TID;
|
|
219
204
|
}
|
|
220
|
-
export interface HorizontalSortableRenderItemProps<TData extends SortableData> {
|
|
205
|
+
export interface HorizontalSortableRenderItemProps<TData extends SortableData<TID>, TID extends UniqueIdentifier = string> {
|
|
221
206
|
item: TData;
|
|
222
207
|
index: number;
|
|
223
208
|
id: string;
|