react-reorder-list 0.6.4 → 0.6.6
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/hooks.d.ts +6 -10
- package/dist/hooks.js +3 -9
- package/dist/index.d.ts +13 -1
- package/dist/index.js +2 -4
- package/package.json +3 -3
package/dist/hooks.d.ts
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
onTouchStart: (event: MouseEvent | TouchEvent) => void;
|
|
8
|
-
onTouchEnd: (event: MouseEvent | TouchEvent) => void;
|
|
9
|
-
};
|
|
10
|
-
};
|
|
1
|
+
export declare function useDraggable(initValue?: boolean): readonly [boolean, {
|
|
2
|
+
onMouseEnter: () => void;
|
|
3
|
+
onMouseLeave: () => void;
|
|
4
|
+
onTouchStart: () => void;
|
|
5
|
+
onTouchEnd: () => void;
|
|
6
|
+
}];
|
package/dist/hooks.js
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
import { useState } from "react";
|
|
2
2
|
export function useDraggable(initValue = false) {
|
|
3
3
|
const [draggable, setDraggable] = useState(initValue);
|
|
4
|
-
const enableDragging = (
|
|
5
|
-
|
|
6
|
-
setDraggable(true);
|
|
7
|
-
};
|
|
8
|
-
const disableDragging = (event) => {
|
|
9
|
-
event.stopPropagation();
|
|
10
|
-
setDraggable(false);
|
|
11
|
-
};
|
|
4
|
+
const enableDragging = () => setDraggable(true);
|
|
5
|
+
const disableDragging = () => setDraggable(false);
|
|
12
6
|
const draggableProps = { onMouseEnter: enableDragging, onMouseLeave: disableDragging, onTouchStart: enableDragging, onTouchEnd: disableDragging };
|
|
13
|
-
return
|
|
7
|
+
return [draggable, draggableProps];
|
|
14
8
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { DetailedHTMLProps, HTMLAttributes, ReactNode } from "react";
|
|
1
|
+
import React, { CSSProperties, DetailedHTMLProps, DragEventHandler, HTMLAttributes, ReactNode, TouchEventHandler } from "react";
|
|
2
2
|
export type Props = DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
|
|
3
3
|
export type PositionChangeHandler = (params?: {
|
|
4
4
|
start?: number;
|
|
@@ -18,6 +18,18 @@ export type ReorderListProps = {
|
|
|
18
18
|
props?: Props;
|
|
19
19
|
children?: ReactNode;
|
|
20
20
|
};
|
|
21
|
+
export type DivDragEventHandler = DragEventHandler<HTMLDivElement>;
|
|
22
|
+
export type DivTouchEventHandler = TouchEventHandler<HTMLDivElement>;
|
|
23
|
+
export type ReorderItemProps = {
|
|
24
|
+
useOnlyIconToDrag: boolean;
|
|
25
|
+
style: CSSProperties;
|
|
26
|
+
onDragStart?: DivDragEventHandler;
|
|
27
|
+
onDragEnter: DivDragEventHandler;
|
|
28
|
+
onDragEnd: DivDragEventHandler;
|
|
29
|
+
onTouchMove: DivTouchEventHandler;
|
|
30
|
+
onTouchEnd: DivTouchEventHandler;
|
|
31
|
+
children: ReactNode;
|
|
32
|
+
};
|
|
21
33
|
export type { IconProps } from "./icons.js";
|
|
22
34
|
export default function ReorderList({ useOnlyIconToDrag, selectedItemOpacity, animationDuration, watchChildrenUpdates, preserveOrder, onPositionChange, disabled, props, children }: ReorderListProps): React.JSX.Element;
|
|
23
35
|
export declare function ReorderIcon({ children, style, ...props }: Props): React.JSX.Element;
|
package/dist/index.js
CHANGED
|
@@ -90,7 +90,6 @@ export default function ReorderList({ useOnlyIconToDrag = false, selectedItemOpa
|
|
|
90
90
|
setIsAnimating(true);
|
|
91
91
|
setTimeout(() => setIsAnimating(false), animationDuration);
|
|
92
92
|
}, onDragEnd: handleDragEnd, onTouchMove: (event) => {
|
|
93
|
-
event.stopPropagation();
|
|
94
93
|
if (start === -1)
|
|
95
94
|
return;
|
|
96
95
|
const { clientX, screenX, clientY, screenY } = event.touches[0];
|
|
@@ -109,7 +108,7 @@ export default function ReorderList({ useOnlyIconToDrag = false, selectedItemOpa
|
|
|
109
108
|
}
|
|
110
109
|
function ReorderItem(_a, ref) {
|
|
111
110
|
var { useOnlyIconToDrag, onTouchEnd: propOnTouchEnd, children } = _a, props = __rest(_a, ["useOnlyIconToDrag", "onTouchEnd", "children"]);
|
|
112
|
-
const _b = useDraggable(), {
|
|
111
|
+
const [draggable, _b] = useDraggable(), { onTouchEnd: draggableOnTouchEnd } = _b, draggableProps = __rest(_b, ["onTouchEnd"]);
|
|
113
112
|
if (!draggable)
|
|
114
113
|
props.onDragStart = undefined;
|
|
115
114
|
const recursiveClone = (children) => Children.map(children, (child) => {
|
|
@@ -119,8 +118,7 @@ function ReorderItem(_a, ref) {
|
|
|
119
118
|
});
|
|
120
119
|
const recursiveChildren = useMemo(() => (useOnlyIconToDrag ? recursiveClone(children) : children), [useOnlyIconToDrag, children]);
|
|
121
120
|
return (React.createElement("div", Object.assign({ ref: ref, draggable: draggable }, props, (!useOnlyIconToDrag && draggableProps), { onTouchEnd: (event) => {
|
|
122
|
-
|
|
123
|
-
draggableOnTouchEnd(event);
|
|
121
|
+
draggableOnTouchEnd();
|
|
124
122
|
propOnTouchEnd(event);
|
|
125
123
|
} }), recursiveChildren));
|
|
126
124
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-reorder-list",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.6",
|
|
4
4
|
"description": "A simple react component that facilitates the reordering of JSX/HTML elements through drag-and-drop functionality, allowing for easy position changes.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
},
|
|
27
27
|
"homepage": "https://github.com/SahilAggarwal2004/react-reorder-list#readme",
|
|
28
28
|
"peerDependencies": {
|
|
29
|
-
"react": ">=
|
|
29
|
+
"react": ">=17.0.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@types/react": "^18.2.
|
|
32
|
+
"@types/react": "^18.2.55"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"drag-drop-touch": "^1.3.1"
|