react-reorder-list 0.6.3 → 0.6.5
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 +7 -4
- package/dist/hooks.js +1 -1
- package/dist/index.d.ts +2 -3
- package/dist/index.js +4 -2
- package/package.json +3 -4
package/dist/hooks.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
export type Props = DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
|
|
3
|
-
export default function useDraggable(initValue?: boolean): {
|
|
1
|
+
export declare function useDraggable(initValue?: boolean): {
|
|
4
2
|
draggable: boolean;
|
|
5
|
-
draggableProps:
|
|
3
|
+
draggableProps: {
|
|
4
|
+
onMouseEnter: () => void;
|
|
5
|
+
onMouseLeave: () => void;
|
|
6
|
+
onTouchStart: () => void;
|
|
7
|
+
onTouchEnd: () => void;
|
|
8
|
+
};
|
|
6
9
|
};
|
package/dist/hooks.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useState } from "react";
|
|
2
|
-
export
|
|
2
|
+
export function useDraggable(initValue = false) {
|
|
3
3
|
const [draggable, setDraggable] = useState(initValue);
|
|
4
4
|
const enableDragging = () => setDraggable(true);
|
|
5
5
|
const disableDragging = () => setDraggable(false);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import React, { ReactNode } from "react";
|
|
2
|
-
|
|
3
|
-
export type { Props } from "./hooks.js";
|
|
1
|
+
import React, { DetailedHTMLProps, HTMLAttributes, ReactNode } from "react";
|
|
2
|
+
export type Props = DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
|
|
4
3
|
export type PositionChangeHandler = (params?: {
|
|
5
4
|
start?: number;
|
|
6
5
|
end?: number;
|
package/dist/index.js
CHANGED
|
@@ -12,7 +12,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
import React, { Children, cloneElement, createRef, forwardRef, isValidElement, useEffect, useMemo, useRef, useState } from "react";
|
|
13
13
|
import { PiDotsSixVerticalBold } from "./icons.js";
|
|
14
14
|
import Animation from "./animation.js";
|
|
15
|
-
import useDraggable from "./hooks.js";
|
|
15
|
+
import { useDraggable } from "./hooks.js";
|
|
16
16
|
if (typeof window !== "undefined")
|
|
17
17
|
import("drag-drop-touch");
|
|
18
18
|
const scrollThreshold = { x: 10, y: 100 };
|
|
@@ -109,6 +109,8 @@ export default function ReorderList({ useOnlyIconToDrag = false, selectedItemOpa
|
|
|
109
109
|
function ReorderItem(_a, ref) {
|
|
110
110
|
var { useOnlyIconToDrag, onTouchEnd: propOnTouchEnd, children } = _a, props = __rest(_a, ["useOnlyIconToDrag", "onTouchEnd", "children"]);
|
|
111
111
|
const _b = useDraggable(), { draggable } = _b, _c = _b.draggableProps, { onTouchEnd: draggableOnTouchEnd } = _c, draggableProps = __rest(_c, ["onTouchEnd"]);
|
|
112
|
+
if (!draggable)
|
|
113
|
+
props.onDragStart = undefined;
|
|
112
114
|
const recursiveClone = (children) => Children.map(children, (child) => {
|
|
113
115
|
if (!isValidElement(child))
|
|
114
116
|
return child;
|
|
@@ -116,7 +118,7 @@ function ReorderItem(_a, ref) {
|
|
|
116
118
|
});
|
|
117
119
|
const recursiveChildren = useMemo(() => (useOnlyIconToDrag ? recursiveClone(children) : children), [useOnlyIconToDrag, children]);
|
|
118
120
|
return (React.createElement("div", Object.assign({ ref: ref, draggable: draggable }, props, (!useOnlyIconToDrag && draggableProps), { onTouchEnd: (event) => {
|
|
119
|
-
draggableOnTouchEnd(
|
|
121
|
+
draggableOnTouchEnd();
|
|
120
122
|
propOnTouchEnd(event);
|
|
121
123
|
} }), recursiveChildren));
|
|
122
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.5",
|
|
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,11 +26,10 @@
|
|
|
26
26
|
},
|
|
27
27
|
"homepage": "https://github.com/SahilAggarwal2004/react-reorder-list#readme",
|
|
28
28
|
"peerDependencies": {
|
|
29
|
-
"react": ">=16.0.0"
|
|
30
|
-
"react-dom": ">=16.0.0"
|
|
29
|
+
"react": ">=16.0.0"
|
|
31
30
|
},
|
|
32
31
|
"devDependencies": {
|
|
33
|
-
"@types/react": "^18.2.
|
|
32
|
+
"@types/react": "^18.2.55"
|
|
34
33
|
},
|
|
35
34
|
"dependencies": {
|
|
36
35
|
"drag-drop-touch": "^1.3.1"
|