@os-design/drag-sort 1.0.30 → 1.0.32
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/DragAndDrop.d.ts +52 -0
- package/dist/DragAndDrop.d.ts.map +1 -0
- package/dist/{esm/DragAndDrop.js → DragAndDrop.js} +26 -24
- package/dist/Draggable.d.ts +42 -0
- package/dist/Draggable.d.ts.map +1 -0
- package/dist/{esm/Draggable.js → Draggable.js} +12 -10
- package/dist/Droppable.d.ts +38 -0
- package/dist/Droppable.d.ts.map +1 -0
- package/dist/{esm/Droppable.js → Droppable.js} +13 -12
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/utils/ListStore.d.ts +22 -0
- package/dist/utils/ListStore.d.ts.map +1 -0
- package/dist/{esm/utils → utils}/ListStore.js +1 -2
- package/dist/utils/NodeList.d.ts +104 -0
- package/dist/utils/NodeList.d.ts.map +1 -0
- package/dist/{esm/utils → utils}/NodeList.js +2 -3
- package/dist/utils/getElementOffset.d.ts.map +1 -0
- package/dist/{esm/utils → utils}/getElementOffset.js +1 -2
- package/dist/utils/getElementScroll.d.ts.map +1 -0
- package/dist/{esm/utils → utils}/getElementScroll.js +1 -2
- package/dist/{types/utils → utils}/getNodeRect.d.ts +4 -1
- package/dist/utils/getNodeRect.d.ts.map +1 -0
- package/dist/{esm/utils → utils}/getNodeRect.js +3 -5
- package/dist/utils/useAppendClassName.d.ts +7 -0
- package/dist/utils/useAppendClassName.d.ts.map +1 -0
- package/dist/{esm/utils → utils}/useAppendClassName.js +1 -2
- package/dist/{types/utils → utils}/useBlankNode.d.ts +4 -0
- package/dist/utils/useBlankNode.d.ts.map +1 -0
- package/dist/{esm/utils → utils}/useBlankNode.js +1 -2
- package/dist/{types/utils → utils}/useDragAndDrop.d.ts +3 -3
- package/dist/utils/useDragAndDrop.d.ts.map +1 -0
- package/dist/{esm/utils → utils}/useDragAndDrop.js +1 -2
- package/dist/{types/utils → utils}/useDragEffect.d.ts +3 -3
- package/dist/utils/useDragEffect.d.ts.map +1 -0
- package/dist/{esm/utils → utils}/useDragEffect.js +9 -14
- package/dist/{types/utils → utils}/useDroppable.d.ts +2 -2
- package/dist/utils/useDroppable.d.ts.map +1 -0
- package/dist/{esm/utils → utils}/useDroppable.js +1 -2
- package/dist/utils/useGeneratedId.d.ts.map +1 -0
- package/dist/{esm/utils → utils}/useGeneratedId.js +1 -2
- package/dist/{types/utils → utils}/useGetNodeStyle.d.ts +1 -1
- package/dist/utils/useGetNodeStyle.d.ts.map +1 -0
- package/dist/{esm/utils → utils}/useGetNodeStyle.js +1 -2
- package/dist/{types/utils → utils}/useInitRect.d.ts +1 -1
- package/dist/utils/useInitRect.d.ts.map +1 -0
- package/dist/{esm/utils → utils}/useInitRect.js +1 -2
- package/dist/{types/utils → utils}/useInitScrollOffset.d.ts +1 -1
- package/dist/utils/useInitScrollOffset.d.ts.map +1 -0
- package/dist/{esm/utils → utils}/useInitScrollOffset.js +2 -3
- package/dist/{types/utils → utils}/useMoveNode.d.ts +3 -4
- package/dist/utils/useMoveNode.d.ts.map +1 -0
- package/dist/{esm/utils → utils}/useMoveNode.js +2 -5
- package/dist/utils/useScrollEventByPoint.d.ts +11 -0
- package/dist/utils/useScrollEventByPoint.d.ts.map +1 -0
- package/dist/{esm/utils → utils}/useScrollEventByPoint.js +1 -2
- package/dist/{types/utils → utils}/useTargetList.d.ts +2 -2
- package/dist/utils/useTargetList.d.ts.map +1 -0
- package/dist/{esm/utils → utils}/useTargetList.js +2 -3
- package/dist/{types/utils → utils}/useTransitionStyle.d.ts +3 -0
- package/dist/utils/useTransitionStyle.d.ts.map +1 -0
- package/dist/{esm/utils → utils}/useTransitionStyle.js +1 -2
- package/package.json +16 -17
- package/src/DragAndDrop.tsx +10 -10
- package/src/Draggable.tsx +5 -5
- package/src/Droppable.tsx +6 -6
- package/src/utils/NodeList.ts +2 -2
- package/src/utils/getNodeRect.ts +1 -1
- package/src/utils/useAppendClassName.ts +1 -1
- package/src/utils/useBlankNode.ts +1 -1
- package/src/utils/useDragAndDrop.ts +3 -3
- package/src/utils/useDragEffect.ts +8 -7
- package/src/utils/useDroppable.ts +2 -2
- package/src/utils/useGetNodeStyle.ts +1 -1
- package/src/utils/useInitRect.ts +1 -1
- package/src/utils/useInitScrollOffset.ts +1 -1
- package/src/utils/useMoveNode.ts +3 -5
- package/src/utils/useTargetList.ts +2 -2
- package/dist/cjs/DragAndDrop.js +0 -181
- package/dist/cjs/DragAndDrop.js.map +0 -1
- package/dist/cjs/Draggable.js +0 -81
- package/dist/cjs/Draggable.js.map +0 -1
- package/dist/cjs/Droppable.js +0 -98
- package/dist/cjs/Droppable.js.map +0 -1
- package/dist/cjs/index.js +0 -68
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/utils/ListStore.js +0 -61
- package/dist/cjs/utils/ListStore.js.map +0 -1
- package/dist/cjs/utils/NodeList.js +0 -228
- package/dist/cjs/utils/NodeList.js.map +0 -1
- package/dist/cjs/utils/getElementOffset.js +0 -22
- package/dist/cjs/utils/getElementOffset.js.map +0 -1
- package/dist/cjs/utils/getElementScroll.js +0 -22
- package/dist/cjs/utils/getElementScroll.js.map +0 -1
- package/dist/cjs/utils/getNodeRect.js +0 -38
- package/dist/cjs/utils/getNodeRect.js.map +0 -1
- package/dist/cjs/utils/useAppendClassName.js +0 -23
- package/dist/cjs/utils/useAppendClassName.js.map +0 -1
- package/dist/cjs/utils/useBlankNode.js +0 -94
- package/dist/cjs/utils/useBlankNode.js.map +0 -1
- package/dist/cjs/utils/useDragAndDrop.js +0 -22
- package/dist/cjs/utils/useDragAndDrop.js.map +0 -1
- package/dist/cjs/utils/useDragEffect.js +0 -468
- package/dist/cjs/utils/useDragEffect.js.map +0 -1
- package/dist/cjs/utils/useDroppable.js +0 -25
- package/dist/cjs/utils/useDroppable.js.map +0 -1
- package/dist/cjs/utils/useGeneratedId.js +0 -14
- package/dist/cjs/utils/useGeneratedId.js.map +0 -1
- package/dist/cjs/utils/useGetNodeStyle.js +0 -24
- package/dist/cjs/utils/useGetNodeStyle.js.map +0 -1
- package/dist/cjs/utils/useInitRect.js +0 -21
- package/dist/cjs/utils/useInitRect.js.map +0 -1
- package/dist/cjs/utils/useInitScrollOffset.js +0 -21
- package/dist/cjs/utils/useInitScrollOffset.js.map +0 -1
- package/dist/cjs/utils/useMoveNode.js +0 -90
- package/dist/cjs/utils/useMoveNode.js.map +0 -1
- package/dist/cjs/utils/useScrollEventByPoint.js +0 -57
- package/dist/cjs/utils/useScrollEventByPoint.js.map +0 -1
- package/dist/cjs/utils/useTargetList.js +0 -44
- package/dist/cjs/utils/useTargetList.js.map +0 -1
- package/dist/cjs/utils/useTransitionStyle.js +0 -26
- package/dist/cjs/utils/useTransitionStyle.js.map +0 -1
- package/dist/esm/DragAndDrop.js.map +0 -1
- package/dist/esm/Draggable.js.map +0 -1
- package/dist/esm/Droppable.js.map +0 -1
- package/dist/esm/index.js +0 -7
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/utils/ListStore.js.map +0 -1
- package/dist/esm/utils/NodeList.js.map +0 -1
- package/dist/esm/utils/getElementOffset.js.map +0 -1
- package/dist/esm/utils/getElementScroll.js.map +0 -1
- package/dist/esm/utils/getNodeRect.js.map +0 -1
- package/dist/esm/utils/useAppendClassName.js.map +0 -1
- package/dist/esm/utils/useBlankNode.js.map +0 -1
- package/dist/esm/utils/useDragAndDrop.js.map +0 -1
- package/dist/esm/utils/useDragEffect.js.map +0 -1
- package/dist/esm/utils/useDroppable.js.map +0 -1
- package/dist/esm/utils/useGeneratedId.js.map +0 -1
- package/dist/esm/utils/useGetNodeStyle.js.map +0 -1
- package/dist/esm/utils/useInitRect.js.map +0 -1
- package/dist/esm/utils/useInitScrollOffset.js.map +0 -1
- package/dist/esm/utils/useMoveNode.js.map +0 -1
- package/dist/esm/utils/useScrollEventByPoint.js.map +0 -1
- package/dist/esm/utils/useTargetList.js.map +0 -1
- package/dist/esm/utils/useTransitionStyle.js.map +0 -1
- package/dist/types/DragAndDrop.d.ts +0 -17
- package/dist/types/DragAndDrop.d.ts.map +0 -1
- package/dist/types/Draggable.d.ts +0 -18
- package/dist/types/Draggable.d.ts.map +0 -1
- package/dist/types/Droppable.d.ts +0 -15
- package/dist/types/Droppable.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/utils/ListStore.d.ts +0 -10
- package/dist/types/utils/ListStore.d.ts.map +0 -1
- package/dist/types/utils/NodeList.d.ts +0 -44
- package/dist/types/utils/NodeList.d.ts.map +0 -1
- package/dist/types/utils/getElementOffset.d.ts.map +0 -1
- package/dist/types/utils/getElementScroll.d.ts.map +0 -1
- package/dist/types/utils/getNodeRect.d.ts.map +0 -1
- package/dist/types/utils/useAppendClassName.d.ts +0 -4
- package/dist/types/utils/useAppendClassName.d.ts.map +0 -1
- package/dist/types/utils/useBlankNode.d.ts.map +0 -1
- package/dist/types/utils/useDragAndDrop.d.ts.map +0 -1
- package/dist/types/utils/useDragEffect.d.ts.map +0 -1
- package/dist/types/utils/useDroppable.d.ts.map +0 -1
- package/dist/types/utils/useGeneratedId.d.ts.map +0 -1
- package/dist/types/utils/useGetNodeStyle.d.ts.map +0 -1
- package/dist/types/utils/useInitRect.d.ts.map +0 -1
- package/dist/types/utils/useInitScrollOffset.d.ts.map +0 -1
- package/dist/types/utils/useMoveNode.d.ts.map +0 -1
- package/dist/types/utils/useScrollEventByPoint.d.ts +0 -7
- package/dist/types/utils/useScrollEventByPoint.d.ts.map +0 -1
- package/dist/types/utils/useTargetList.d.ts.map +0 -1
- package/dist/types/utils/useTransitionStyle.d.ts.map +0 -1
- /package/dist/{types/index.d.ts → index.d.ts} +0 -0
- /package/dist/{types/utils → utils}/getElementOffset.d.ts +0 -0
- /package/dist/{types/utils → utils}/getElementScroll.d.ts +0 -0
- /package/dist/{types/utils → utils}/useGeneratedId.d.ts +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDroppable.d.ts","sourceRoot":"","sources":["../../src/utils/useDroppable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,KAAK,UAAU,EAAE,KAAK,UAAU,EAAc,MAAM,OAAO,CAAC;AAC5E,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE1D,UAAU,qBAAqB;IAC7B,YAAY,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,YAAY,CAAC;IACjD,cAAc,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,IAAI,CAAC;IAC7C,WAAW,EAAE,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,KAAK,IAAI,CAAC;IACzD,YAAY,EAAE,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,KAAK,IAAI,CAAC;CAC3D;AAED,eAAO,MAAM,gBAAgB,sCAM3B,CAAC;AAEH,QAAA,MAAM,YAAY,QAAO,qBAAqD,CAAC;AAE/E,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGeneratedId.d.ts","sourceRoot":"","sources":["../../src/utils/useGeneratedId.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,cAAc,cACoC,CAAC;AAEzD,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGetNodeStyle.d.ts","sourceRoot":"","sources":["../../src/utils/useGetNodeStyle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAkC,MAAM,OAAO,CAAC;AAE3E,UAAU,QAAQ;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,eAAe,GAAG,CAC5B,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,EAC5B,UAAU,EAAE,OAAO,KAChB,aAAa,CAAC;AAEnB,QAAA,MAAM,eAAe,SAAU,QAAQ,GAAG,IAAI,KAAG,eAmBhD,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useInitRect.d.ts","sourceRoot":"","sources":["../../src/utils/useInitRect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAW,MAAM,OAAO,CAAC;AAEhD,QAAA,MAAM,WAAW,SAAU,SAAS,CAAC,WAAW,CAAC;;;;;QAYtC,CAAC;AAEZ,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useInitScrollOffset.d.ts","sourceRoot":"","sources":["../../src/utils/useInitScrollOffset.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAW,MAAM,OAAO,CAAC;AAGhD,QAAA,MAAM,mBAAmB,SAAU,SAAS,CAAC,WAAW,CAAC;;;QAU9C,CAAC;AAEZ,eAAe,mBAAmB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
|
-
import getElementScroll from
|
|
2
|
+
import getElementScroll from "./getElementScroll.js";
|
|
3
3
|
const useInitScrollOffset = ref => useMemo(() => {
|
|
4
4
|
if (!ref || !ref.current) return null;
|
|
5
5
|
const scrollOffset = getElementScroll(ref.current);
|
|
@@ -8,5 +8,4 @@ const useInitScrollOffset = ref => useMemo(() => {
|
|
|
8
8
|
initScrollTop: scrollOffset.scrollTop
|
|
9
9
|
};
|
|
10
10
|
}, [ref]);
|
|
11
|
-
export default useInitScrollOffset;
|
|
12
|
-
//# sourceMappingURL=useInitScrollOffset.js.map
|
|
11
|
+
export default useInitScrollOffset;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import { NodeStyleGetter } from './useGetNodeStyle';
|
|
1
|
+
import { type Position } from '@os-design/use-drag';
|
|
2
|
+
import NodeList, { type ExistingNode } from './NodeList';
|
|
3
|
+
import type { NodeStyleGetter } from './useGetNodeStyle';
|
|
5
4
|
interface DraggedNode {
|
|
6
5
|
node: ExistingNode;
|
|
7
6
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMoveNode.d.ts","sourceRoot":"","sources":["../../src/utils/useMoveNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,QAAQ,EAAE,EAAE,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAEzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,UAAU,WAAW;IACnB,IAAI,EAAE,YAAY,CAAC;CACpB;AAED,UAAU,gBAAgB;IACxB,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC1B,WAAW,EAAE,WAAW,GAAG,IAAI,CAAC;IAChC,YAAY,EAAE,eAAe,CAAC;CAC/B;AAED,UAAU,SAAS;IACjB,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,YAAY,CAAC;IACxB,SAAS,EAAE,IAAI,GAAG,MAAM,CAAC;IACzB,WAAW,EAAE,QAAQ,GAAG,KAAK,CAAC;IAC9B,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,QAAA,MAAM,WAAW,UAAW,gBAAgB,eAI9B,SAAS,2JAgEtB,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { useCallback } from 'react';
|
|
2
|
-
import getNodeRect from
|
|
3
|
-
/* eslint-disable no-constant-condition */
|
|
4
|
-
|
|
2
|
+
import getNodeRect from "./getNodeRect.js";
|
|
5
3
|
const useMoveNode = props => {
|
|
6
4
|
const {
|
|
7
5
|
position,
|
|
@@ -61,5 +59,4 @@ const useMoveNode = props => {
|
|
|
61
59
|
}
|
|
62
60
|
}, [draggedNode, getNodeStyle, position]);
|
|
63
61
|
};
|
|
64
|
-
export default useMoveNode;
|
|
65
|
-
//# sourceMappingURL=useMoveNode.js.map
|
|
62
|
+
export default useMoveNode;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface Point {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Sets the listener that will be called whenever the scroll event occurs
|
|
7
|
+
* in one of the elements located under the specified point.
|
|
8
|
+
*/
|
|
9
|
+
declare const useScrollEventByPoint: (point: Point | null, listener: (e: Event) => void) => void;
|
|
10
|
+
export default useScrollEventByPoint;
|
|
11
|
+
//# sourceMappingURL=useScrollEventByPoint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useScrollEventByPoint.d.ts","sourceRoot":"","sources":["../../src/utils/useScrollEventByPoint.ts"],"names":[],"mappings":"AAeA,MAAM,WAAW,KAAK;IACpB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED;;;GAGG;AACH,QAAA,MAAM,qBAAqB,UAClB,KAAK,GAAG,IAAI,YACT,CAAC,CAAC,EAAE,KAAK,KAAK,IAAI,SA2B7B,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Position } from '@os-design/use-drag';
|
|
2
|
-
import { RefObject } from 'react';
|
|
1
|
+
import type { Position } from '@os-design/use-drag';
|
|
2
|
+
import { type RefObject } from 'react';
|
|
3
3
|
import ListStore from './ListStore';
|
|
4
4
|
declare const useTargetList: (position: Position | null, listStoreRef: RefObject<ListStore>) => import("./NodeList").default | null;
|
|
5
5
|
export default useTargetList;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTargetList.d.ts","sourceRoot":"","sources":["../../src/utils/useTargetList.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,KAAK,SAAS,EAAkC,MAAM,OAAO,CAAC;AACvE,OAAO,SAAS,MAAM,aAAa,CAAC;AAGpC,QAAA,MAAM,aAAa,aACP,QAAQ,GAAG,IAAI,gBACX,SAAS,CAAC,SAAS,CAAC,wCAoBnC,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import useThrottle from '@os-design/use-throttle';
|
|
2
2
|
import { useCallback, useMemo, useState } from 'react';
|
|
3
|
-
import useScrollEventByPoint from
|
|
3
|
+
import useScrollEventByPoint from "./useScrollEventByPoint.js";
|
|
4
4
|
const useTargetList = (position, listStoreRef) => {
|
|
5
5
|
const [number, setNumber] = useState(0);
|
|
6
6
|
const targetList = useMemo(() => {
|
|
@@ -22,5 +22,4 @@ const useTargetList = (position, listStoreRef) => {
|
|
|
22
22
|
useScrollEventByPoint(position, throttledForceUpdate);
|
|
23
23
|
return targetList;
|
|
24
24
|
};
|
|
25
|
-
export default useTargetList;
|
|
26
|
-
//# sourceMappingURL=useTargetList.js.map
|
|
25
|
+
export default useTargetList;
|
|
@@ -3,6 +3,9 @@ interface UseTransitionStyleProps {
|
|
|
3
3
|
ms: number;
|
|
4
4
|
enabled: boolean;
|
|
5
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* Creates the global style for setting the transition delay.
|
|
8
|
+
*/
|
|
6
9
|
declare const useTransitionStyle: (props: UseTransitionStyleProps) => void;
|
|
7
10
|
export default useTransitionStyle;
|
|
8
11
|
//# sourceMappingURL=useTransitionStyle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTransitionStyle.d.ts","sourceRoot":"","sources":["../../src/utils/useTransitionStyle.ts"],"names":[],"mappings":"AAEA,UAAU,uBAAuB;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,QAAA,MAAM,kBAAkB,UAAW,uBAAuB,SAYzD,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@os-design/drag-sort",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.32",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"repository": "git@gitlab.com:os-team/libs/os-design.git",
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"types": "dist/
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
9
|
"files": [
|
|
10
10
|
"dist",
|
|
11
11
|
"src",
|
|
@@ -20,9 +20,8 @@
|
|
|
20
20
|
"sideEffects": false,
|
|
21
21
|
"scripts": {
|
|
22
22
|
"clean": "rimraf dist",
|
|
23
|
-
"build:esm": "cross-env BABEL_ENV=esm babel src --root-mode upward --extensions .ts,.tsx --out-dir dist
|
|
24
|
-
"build:
|
|
25
|
-
"build:types": "tsc --emitDeclarationOnly --declaration --declarationDir dist/types",
|
|
23
|
+
"build:esm": "cross-env BABEL_ENV=esm babel src --root-mode upward --extensions .ts,.tsx --out-dir dist",
|
|
24
|
+
"build:types": "tsc -p tsconfig.build.json --emitDeclarationOnly --declaration --declarationDir dist",
|
|
26
25
|
"build": "yarn clean && npm-run-all 'build:*'",
|
|
27
26
|
"ncu": "ncu -u"
|
|
28
27
|
},
|
|
@@ -30,22 +29,22 @@
|
|
|
30
29
|
"access": "public"
|
|
31
30
|
},
|
|
32
31
|
"dependencies": {
|
|
33
|
-
"@os-design/portal": "^1.0.
|
|
34
|
-
"@os-design/use-auto-scroll": "^1.0.
|
|
35
|
-
"@os-design/use-drag": "^1.0.
|
|
36
|
-
"@os-design/use-event": "^1.0.
|
|
37
|
-
"@os-design/use-memo-object": "^1.0.
|
|
38
|
-
"@os-design/use-prevent-default-event": "^1.0.
|
|
39
|
-
"@os-design/use-throttle": "^1.0.
|
|
32
|
+
"@os-design/portal": "^1.0.19",
|
|
33
|
+
"@os-design/use-auto-scroll": "^1.0.23",
|
|
34
|
+
"@os-design/use-drag": "^1.0.21",
|
|
35
|
+
"@os-design/use-event": "^1.0.24",
|
|
36
|
+
"@os-design/use-memo-object": "^1.0.19",
|
|
37
|
+
"@os-design/use-prevent-default-event": "^1.0.21",
|
|
38
|
+
"@os-design/use-throttle": "^1.0.23"
|
|
40
39
|
},
|
|
41
40
|
"devDependencies": {
|
|
42
|
-
"@os-design/omit-emotion-props": "^1.0.
|
|
43
|
-
"@os-design/use-size": "^1.0.
|
|
41
|
+
"@os-design/omit-emotion-props": "^1.0.21",
|
|
42
|
+
"@os-design/use-size": "^1.0.25",
|
|
44
43
|
"react-window": "^1.8.10"
|
|
45
44
|
},
|
|
46
45
|
"peerDependencies": {
|
|
47
46
|
"react": ">=18",
|
|
48
47
|
"react-dom": ">=18"
|
|
49
48
|
},
|
|
50
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "211f9e5f1ecca50454cc7415359de5a4d950c7b1"
|
|
51
50
|
}
|
package/src/DragAndDrop.tsx
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import Portal, { PortalProps } from '@os-design/portal';
|
|
1
|
+
import Portal, { type PortalProps } from '@os-design/portal';
|
|
2
2
|
import useAutoScroll from '@os-design/use-auto-scroll';
|
|
3
3
|
import useDrag, {
|
|
4
|
-
OnDragEnd,
|
|
5
|
-
OnDragMove,
|
|
6
|
-
OnDragStart,
|
|
7
|
-
Position,
|
|
4
|
+
type OnDragEnd,
|
|
5
|
+
type OnDragMove,
|
|
6
|
+
type OnDragStart,
|
|
7
|
+
type Position,
|
|
8
8
|
} from '@os-design/use-drag';
|
|
9
9
|
import useMemoObject from '@os-design/use-memo-object';
|
|
10
10
|
import usePreventDefaultEvent from '@os-design/use-prevent-default-event';
|
|
11
11
|
import React, {
|
|
12
|
-
MouseEvent,
|
|
13
|
-
TouchEvent,
|
|
12
|
+
type MouseEvent,
|
|
13
|
+
type TouchEvent,
|
|
14
14
|
useCallback,
|
|
15
15
|
useMemo,
|
|
16
16
|
useRef,
|
|
17
17
|
useState,
|
|
18
18
|
} from 'react';
|
|
19
19
|
import ListStore from './utils/ListStore';
|
|
20
|
-
import NodeList, { ExistingNode } from './utils/NodeList';
|
|
20
|
+
import NodeList, { type ExistingNode } from './utils/NodeList';
|
|
21
21
|
import { DragAndDropContext } from './utils/useDragAndDrop';
|
|
22
22
|
import useDragEffect, {
|
|
23
|
-
DragEndHandler,
|
|
24
|
-
DraggedNode,
|
|
23
|
+
type DragEndHandler,
|
|
24
|
+
type DraggedNode,
|
|
25
25
|
} from './utils/useDragEffect';
|
|
26
26
|
import useGeneratedId from './utils/useGeneratedId';
|
|
27
27
|
import useInitRect from './utils/useInitRect';
|
package/src/Draggable.tsx
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import useMemoObject from '@os-design/use-memo-object';
|
|
2
2
|
import React, {
|
|
3
|
-
CSSProperties,
|
|
4
|
-
MouseEvent,
|
|
5
|
-
RefObject,
|
|
6
|
-
TouchEvent,
|
|
3
|
+
type CSSProperties,
|
|
4
|
+
type MouseEvent,
|
|
5
|
+
type RefObject,
|
|
6
|
+
type TouchEvent,
|
|
7
7
|
useCallback,
|
|
8
8
|
useEffect,
|
|
9
9
|
useRef,
|
|
10
10
|
useState,
|
|
11
11
|
} from 'react';
|
|
12
|
-
import { Node } from './utils/NodeList';
|
|
12
|
+
import type { Node } from './utils/NodeList';
|
|
13
13
|
import useAppendClassName from './utils/useAppendClassName';
|
|
14
14
|
import useDragAndDrop from './utils/useDragAndDrop';
|
|
15
15
|
import useDroppable from './utils/useDroppable';
|
package/src/Droppable.tsx
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import useMemoObject from '@os-design/use-memo-object';
|
|
2
2
|
import React, {
|
|
3
|
-
MouseEvent,
|
|
4
|
-
RefObject,
|
|
5
|
-
TouchEvent,
|
|
3
|
+
type MouseEvent,
|
|
4
|
+
type RefObject,
|
|
5
|
+
type TouchEvent,
|
|
6
6
|
useCallback,
|
|
7
7
|
useEffect,
|
|
8
8
|
useMemo,
|
|
9
9
|
useRef,
|
|
10
10
|
} from 'react';
|
|
11
11
|
import NodeList, {
|
|
12
|
-
ExistingNode,
|
|
13
|
-
NodeProps,
|
|
14
|
-
RenderDraggedNode,
|
|
12
|
+
type ExistingNode,
|
|
13
|
+
type NodeProps,
|
|
14
|
+
type RenderDraggedNode,
|
|
15
15
|
} from './utils/NodeList';
|
|
16
16
|
import useDragAndDrop from './utils/useDragAndDrop';
|
|
17
17
|
import { DroppableContext } from './utils/useDroppable';
|
package/src/utils/NodeList.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React, { CSSProperties, RefObject } from 'react';
|
|
1
|
+
import React, { type CSSProperties, type RefObject } from 'react';
|
|
2
2
|
|
|
3
|
-
/* eslint-disable @typescript-eslint/no-explicit-any
|
|
3
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
4
4
|
|
|
5
5
|
// [prev, next, ref, setStyle, index, id]
|
|
6
6
|
export type Node =
|
package/src/utils/getNodeRect.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Position } from '@os-design/use-drag';
|
|
2
|
-
import React, { MouseEvent, TouchEvent, useContext } from 'react';
|
|
3
|
-
import NodeList, { ExistingNode } from './NodeList';
|
|
1
|
+
import type { Position } from '@os-design/use-drag';
|
|
2
|
+
import React, { type MouseEvent, type TouchEvent, useContext } from 'react';
|
|
3
|
+
import NodeList, { type ExistingNode } from './NodeList';
|
|
4
4
|
|
|
5
5
|
export interface SetDraggedNodeProps {
|
|
6
6
|
list: NodeList;
|
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
import { Position } from '@os-design/use-drag';
|
|
1
|
+
import type { Position } from '@os-design/use-drag';
|
|
2
2
|
import useEvent from '@os-design/use-event';
|
|
3
3
|
import useThrottle from '@os-design/use-throttle';
|
|
4
4
|
import {
|
|
5
|
-
CSSProperties,
|
|
6
|
-
RefObject,
|
|
5
|
+
type CSSProperties,
|
|
6
|
+
type RefObject,
|
|
7
7
|
useCallback,
|
|
8
8
|
useEffect,
|
|
9
9
|
useMemo,
|
|
10
10
|
useRef,
|
|
11
11
|
} from 'react';
|
|
12
12
|
import ListStore from './ListStore';
|
|
13
|
-
import NodeList, {
|
|
13
|
+
import NodeList, {
|
|
14
|
+
type ExistingNode,
|
|
15
|
+
type Node,
|
|
16
|
+
type NodeProps,
|
|
17
|
+
} from './NodeList';
|
|
14
18
|
import getElementScroll from './getElementScroll';
|
|
15
19
|
import getNodeRect from './getNodeRect';
|
|
16
20
|
import useBlankNode from './useBlankNode';
|
|
@@ -62,8 +66,6 @@ const createEmptyNode = ({
|
|
|
62
66
|
next?: Node;
|
|
63
67
|
}): ExistingNode => [prev, next, { current: null }, () => {}, -1, 'id'];
|
|
64
68
|
|
|
65
|
-
/* eslint-disable no-constant-condition */
|
|
66
|
-
|
|
67
69
|
const useDragEffect = (props: UseDragEffectProps) => {
|
|
68
70
|
const { draggedNode, cursorPosition, listStoreRef, onDragEnd } = props;
|
|
69
71
|
|
|
@@ -472,7 +474,6 @@ const useDragEffect = (props: UseDragEffectProps) => {
|
|
|
472
474
|
useEffect(() => {
|
|
473
475
|
if (!draggedNode) return () => {};
|
|
474
476
|
return () => {
|
|
475
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
476
477
|
const target = targetRef.current;
|
|
477
478
|
if (!target) return;
|
|
478
479
|
const [, , , , draggedNodeIndex, draggedNodeId] = draggedNode.node;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React, { MouseEvent, TouchEvent, useContext } from 'react';
|
|
2
|
-
import { ExistingNode, NodeProps } from './NodeList';
|
|
1
|
+
import React, { type MouseEvent, type TouchEvent, useContext } from 'react';
|
|
2
|
+
import type { ExistingNode, NodeProps } from './NodeList';
|
|
3
3
|
|
|
4
4
|
interface DroppableContextProps {
|
|
5
5
|
registerNode: (props: NodeProps) => ExistingNode;
|
package/src/utils/useInitRect.ts
CHANGED
package/src/utils/useMoveNode.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Position } from '@os-design/use-drag';
|
|
1
|
+
import { type Position } from '@os-design/use-drag';
|
|
2
2
|
import { useCallback } from 'react';
|
|
3
|
-
import NodeList, { ExistingNode } from './NodeList';
|
|
3
|
+
import NodeList, { type ExistingNode } from './NodeList';
|
|
4
4
|
import getNodeRect from './getNodeRect';
|
|
5
|
-
import { NodeStyleGetter } from './useGetNodeStyle';
|
|
5
|
+
import type { NodeStyleGetter } from './useGetNodeStyle';
|
|
6
6
|
|
|
7
7
|
interface DraggedNode {
|
|
8
8
|
node: ExistingNode;
|
|
@@ -22,8 +22,6 @@ interface MoveProps {
|
|
|
22
22
|
isAnotherList?: boolean;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
/* eslint-disable no-constant-condition */
|
|
26
|
-
|
|
27
25
|
const useMoveNode = (props: UseMoveNodeProps) => {
|
|
28
26
|
const { position, draggedNode, getNodeStyle } = props;
|
|
29
27
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Position } from '@os-design/use-drag';
|
|
1
|
+
import type { Position } from '@os-design/use-drag';
|
|
2
2
|
import useThrottle from '@os-design/use-throttle';
|
|
3
|
-
import { RefObject, useCallback, useMemo, useState } from 'react';
|
|
3
|
+
import { type RefObject, useCallback, useMemo, useState } from 'react';
|
|
4
4
|
import ListStore from './ListStore';
|
|
5
5
|
import useScrollEventByPoint from './useScrollEventByPoint';
|
|
6
6
|
|