@os-design/drag-sort 1.0.18 → 1.0.19
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/cjs/DragAndDrop.js +9 -9
- package/dist/cjs/DragAndDrop.js.map +1 -1
- package/dist/cjs/Draggable.js +6 -6
- package/dist/cjs/Draggable.js.map +1 -1
- package/dist/cjs/Droppable.js +2 -2
- package/dist/cjs/Droppable.js.map +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/utils/ListStore.js.map +1 -1
- package/dist/cjs/utils/NodeList.js +27 -35
- package/dist/cjs/utils/NodeList.js.map +1 -1
- package/dist/cjs/utils/getElementOffset.js.map +1 -1
- package/dist/cjs/utils/getElementScroll.js.map +1 -1
- package/dist/cjs/utils/getNodeRect.js +1 -1
- package/dist/cjs/utils/getNodeRect.js.map +1 -1
- package/dist/cjs/utils/useAppendClassName.js.map +1 -1
- package/dist/cjs/utils/useBlankNode.js +2 -2
- package/dist/cjs/utils/useBlankNode.js.map +1 -1
- package/dist/cjs/utils/useDragAndDrop.js.map +1 -1
- package/dist/cjs/utils/useDragEffect.js +14 -14
- package/dist/cjs/utils/useDragEffect.js.map +1 -1
- package/dist/cjs/utils/useDroppable.js.map +1 -1
- package/dist/cjs/utils/useGeneratedId.js.map +1 -1
- package/dist/cjs/utils/useGetNodeStyle.js.map +1 -1
- package/dist/cjs/utils/useInitRect.js.map +1 -1
- package/dist/cjs/utils/useInitScrollOffset.js.map +1 -1
- package/dist/cjs/utils/useMoveNode.js +2 -2
- package/dist/cjs/utils/useMoveNode.js.map +1 -1
- package/dist/cjs/utils/useScrollEventByPoint.js +1 -1
- package/dist/cjs/utils/useScrollEventByPoint.js.map +1 -1
- package/dist/cjs/utils/useTargetList.js +3 -3
- package/dist/cjs/utils/useTargetList.js.map +1 -1
- package/dist/cjs/utils/useTransitionStyle.js.map +1 -1
- package/dist/esm/DragAndDrop.js +6 -6
- package/dist/esm/DragAndDrop.js.map +1 -1
- package/dist/esm/Draggable.js +3 -3
- package/dist/esm/Draggable.js.map +1 -1
- package/dist/esm/Droppable.js +1 -1
- package/dist/esm/Droppable.js.map +1 -1
- package/dist/esm/utils/ListStore.js.map +1 -1
- package/dist/esm/utils/NodeList.js +26 -37
- package/dist/esm/utils/NodeList.js.map +1 -1
- package/dist/esm/utils/getNodeRect.js +1 -1
- package/dist/esm/utils/getNodeRect.js.map +1 -1
- package/dist/esm/utils/useAppendClassName.js.map +1 -1
- package/dist/esm/utils/useBlankNode.js.map +1 -1
- package/dist/esm/utils/useDragAndDrop.js.map +1 -1
- package/dist/esm/utils/useDragEffect.js +6 -6
- package/dist/esm/utils/useDragEffect.js.map +1 -1
- package/dist/esm/utils/useDroppable.js.map +1 -1
- package/dist/esm/utils/useGeneratedId.js.map +1 -1
- package/dist/esm/utils/useInitRect.js.map +1 -1
- package/dist/esm/utils/useMoveNode.js.map +1 -1
- package/dist/esm/utils/useScrollEventByPoint.js +1 -1
- package/dist/esm/utils/useScrollEventByPoint.js.map +1 -1
- package/dist/esm/utils/useTargetList.js +1 -1
- package/dist/esm/utils/useTargetList.js.map +1 -1
- package/dist/types/DragAndDrop.d.ts +1 -1
- package/dist/types/DragAndDrop.d.ts.map +1 -1
- package/dist/types/Draggable.d.ts +1 -1
- package/dist/types/Draggable.d.ts.map +1 -1
- package/dist/types/Droppable.d.ts.map +1 -1
- package/dist/types/utils/useDragAndDrop.d.ts +1 -1
- package/dist/types/utils/useDragAndDrop.d.ts.map +1 -1
- package/dist/types/utils/useDragEffect.d.ts +1 -1
- package/dist/types/utils/useDragEffect.d.ts.map +1 -1
- package/dist/types/utils/useDroppable.d.ts.map +1 -1
- package/dist/types/utils/useMoveNode.d.ts.map +1 -1
- package/dist/types/utils/useTargetList.d.ts +1 -1
- package/dist/types/utils/useTargetList.d.ts.map +1 -1
- package/package.json +9 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Draggable.js","names":["React","useCallback","useEffect","useRef","useState","
|
|
1
|
+
{"version":3,"file":"Draggable.js","names":["useMemoObject","React","useCallback","useEffect","useRef","useState","useAppendClassName","useDragAndDrop","useDroppable","Draggable","index","id","children","ref","nodeRef","style","setStyle","nodeClassName","registerNode","deregisterNode","onMouseDown","onTouchStart","current","mouseDownHandler","e","touchStartHandler","handlers","createElement","Fragment"],"sources":["../../src/Draggable.tsx"],"sourcesContent":["import useMemoObject from '@os-design/use-memo-object';\n\nimport React, {\n CSSProperties,\n MouseEvent,\n RefObject,\n TouchEvent,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from 'react';\nimport { Node } from './utils/NodeList';\n\nimport useAppendClassName from './utils/useAppendClassName';\nimport useDragAndDrop from './utils/useDragAndDrop';\nimport useDroppable from './utils/useDroppable';\n\nexport interface DraggableHandlers {\n /**\n * The handler that should be called when the mouse down event occurs.\n */\n onMouseDown: (e: MouseEvent) => void;\n /**\n * The handler that should be called when the touch start event occurs.\n */\n onTouchStart: (e: TouchEvent) => void;\n}\n\nexport interface DraggableChildrenProps {\n /**\n * The reference to the draggable list item.\n */\n ref: RefObject<any>; // eslint-disable-line @typescript-eslint/no-explicit-any\n /**\n * Additional styles for moving the list item.\n */\n style: CSSProperties;\n /**\n * The handlers to catch events when the user starts dragging the list item.\n */\n handlers: DraggableHandlers;\n}\n\nexport interface DraggableProps {\n /**\n * The index of the draggable node.\n */\n index: number;\n /**\n * The ID of the draggable node.\n */\n id: string;\n /**\n * The function that renders the draggable node.\n */\n children: (props: DraggableChildrenProps) => React.ReactNode;\n}\n\nconst Draggable: React.FC<DraggableProps> = ({ index, id, children }) => {\n // The reference to the list item\n const ref = useRef<HTMLDivElement | null>(null);\n // The reference to the node containing the refs to the prev and next nodes\n const nodeRef = useRef<Node>(null);\n // Additional styles for moving the list item\n const [style, setStyle] = useState<CSSProperties>({});\n\n const { nodeClassName } = useDragAndDrop();\n const { registerNode, deregisterNode, onMouseDown, onTouchStart } =\n useDroppable();\n\n // Register the node in the list\n useEffect(() => {\n nodeRef.current = registerNode({ ref, setStyle, index, id });\n return () => {\n if (!nodeRef.current) return;\n deregisterNode(nodeRef.current);\n nodeRef.current = null;\n };\n }, [deregisterNode, id, index, registerNode]);\n\n // Set the class name for the node to apply the transition style (see the DragAndDrop container)\n useAppendClassName(ref, nodeClassName);\n\n // Handlers that determine whether a user clicks on the node\n const mouseDownHandler = useCallback(\n (e: MouseEvent) => {\n if (!nodeRef.current) return;\n onMouseDown(e, nodeRef.current);\n },\n [onMouseDown]\n );\n const touchStartHandler = useCallback(\n (e: TouchEvent) => {\n if (!nodeRef.current) return;\n onTouchStart(e, nodeRef.current);\n },\n [onTouchStart]\n );\n\n const handlers = useMemoObject({\n onMouseDown: mouseDownHandler,\n onTouchStart: touchStartHandler,\n });\n\n return <>{children({ ref, style, handlers })}</>;\n};\n\nexport default Draggable;\n"],"mappings":"AAAA,OAAOA,aAAa,MAAM,4BAA4B;AAEtD,OAAOC,KAAK,IAKVC,WAAW,EACXC,SAAS,EACTC,MAAM,EACNC,QAAQ,QACH,OAAO;AAGd,OAAOC,kBAAkB,MAAM,4BAA4B;AAC3D,OAAOC,cAAc,MAAM,wBAAwB;AACnD,OAAOC,YAAY,MAAM,sBAAsB;AA2C/C,MAAMC,SAAmC,GAAGA,CAAC;EAAEC,KAAK;EAAEC,EAAE;EAAEC;AAAS,CAAC,KAAK;EACvE;EACA,MAAMC,GAAG,GAAGT,MAAM,CAAwB,IAAI,CAAC;EAC/C;EACA,MAAMU,OAAO,GAAGV,MAAM,CAAO,IAAI,CAAC;EAClC;EACA,MAAM,CAACW,KAAK,EAAEC,QAAQ,CAAC,GAAGX,QAAQ,CAAgB,CAAC,CAAC,CAAC;EAErD,MAAM;IAAEY;EAAc,CAAC,GAAGV,cAAc,CAAC,CAAC;EAC1C,MAAM;IAAEW,YAAY;IAAEC,cAAc;IAAEC,WAAW;IAAEC;EAAa,CAAC,GAC/Db,YAAY,CAAC,CAAC;;EAEhB;EACAL,SAAS,CAAC,MAAM;IACdW,OAAO,CAACQ,OAAO,GAAGJ,YAAY,CAAC;MAAEL,GAAG;MAAEG,QAAQ;MAAEN,KAAK;MAAEC;IAAG,CAAC,CAAC;IAC5D,OAAO,MAAM;MACX,IAAI,CAACG,OAAO,CAACQ,OAAO,EAAE;MACtBH,cAAc,CAACL,OAAO,CAACQ,OAAO,CAAC;MAC/BR,OAAO,CAACQ,OAAO,GAAG,IAAI;IACxB,CAAC;EACH,CAAC,EAAE,CAACH,cAAc,EAAER,EAAE,EAAED,KAAK,EAAEQ,YAAY,CAAC,CAAC;;EAE7C;EACAZ,kBAAkB,CAACO,GAAG,EAAEI,aAAa,CAAC;;EAEtC;EACA,MAAMM,gBAAgB,GAAGrB,WAAW,CACjCsB,CAAa,IAAK;IACjB,IAAI,CAACV,OAAO,CAACQ,OAAO,EAAE;IACtBF,WAAW,CAACI,CAAC,EAAEV,OAAO,CAACQ,OAAO,CAAC;EACjC,CAAC,EACD,CAACF,WAAW,CACd,CAAC;EACD,MAAMK,iBAAiB,GAAGvB,WAAW,CAClCsB,CAAa,IAAK;IACjB,IAAI,CAACV,OAAO,CAACQ,OAAO,EAAE;IACtBD,YAAY,CAACG,CAAC,EAAEV,OAAO,CAACQ,OAAO,CAAC;EAClC,CAAC,EACD,CAACD,YAAY,CACf,CAAC;EAED,MAAMK,QAAQ,GAAG1B,aAAa,CAAC;IAC7BoB,WAAW,EAAEG,gBAAgB;IAC7BF,YAAY,EAAEI;EAChB,CAAC,CAAC;EAEF,oBAAOxB,KAAA,CAAA0B,aAAA,CAAA1B,KAAA,CAAA2B,QAAA,QAAGhB,QAAQ,CAAC;IAAEC,GAAG;IAAEE,KAAK;IAAEW;EAAS,CAAC,CAAI,CAAC;AAClD,CAAC;AAED,eAAejB,SAAS"}
|
package/dist/esm/Droppable.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React, { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
2
1
|
import useMemoObject from '@os-design/use-memo-object';
|
|
2
|
+
import React, { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
3
3
|
import NodeList from './utils/NodeList';
|
|
4
4
|
import useDragAndDrop from './utils/useDragAndDrop';
|
|
5
5
|
import { DroppableContext } from './utils/useDroppable';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Droppable.js","names":["React","useCallback","useEffect","useMemo","useRef","
|
|
1
|
+
{"version":3,"file":"Droppable.js","names":["useMemoObject","React","useCallback","useEffect","useMemo","useRef","NodeList","useDragAndDrop","DroppableContext","useGeneratedId","Droppable","renderDraggedNode","id","horizontal","children","ref","innerRef","generatedId","droppableId","listRef","current","registerList","deregisterList","onMouseDown","onTouchStart","listId","registerNode","props","add","deregisterNode","node","remove","mouseDownHandler","e","touchStartHandler","droppableContext","createElement","Provider","value"],"sources":["../../src/Droppable.tsx"],"sourcesContent":["import useMemoObject from '@os-design/use-memo-object';\n\nimport React, {\n MouseEvent,\n RefObject,\n TouchEvent,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n} from 'react';\nimport NodeList, {\n ExistingNode,\n NodeProps,\n RenderDraggedNode,\n} from './utils/NodeList';\nimport useDragAndDrop from './utils/useDragAndDrop';\nimport { DroppableContext } from './utils/useDroppable';\nimport useGeneratedId from './utils/useGeneratedId';\n\nexport interface DroppableChildrenProps {\n /**\n * The reference to the list.\n * If a virtual list is used, pass it to the outerRef prop.\n */\n ref: RefObject<HTMLDivElement>;\n /**\n * The reference to the container inside the virtual list.\n * Pass it to the innerRef prop.\n */\n innerRef: RefObject<HTMLDivElement>;\n}\n\nexport interface DroppableProps {\n /**\n * The function that renders the dragged node.\n */\n renderDraggedNode: RenderDraggedNode;\n /**\n * The ID of the list with draggable nodes.\n * Used to determine in which list the dragged node was dropped.\n * @default undefined\n */\n id?: string;\n /**\n * Whether the list is horizontal.\n * @default false\n */\n horizontal?: boolean;\n /**\n * The function that renders the list with draggable nodes.\n */\n children: (props: DroppableChildrenProps) => React.ReactNode;\n}\n\nconst Droppable: React.FC<DroppableProps> = ({\n renderDraggedNode,\n id,\n horizontal = false,\n children,\n}) => {\n // The reference to the list\n const ref = useRef<HTMLDivElement>(null);\n // The reference to the container inside the virtual list\n const innerRef = useRef<HTMLDivElement>(null);\n // The unique ID of the list. If no ID was specified, the generated one is used.\n const generatedId = useGeneratedId();\n const droppableId = useMemo(() => id || generatedId, [generatedId, id]);\n // The reference to the list of nodes\n const listRef = useRef(\n new NodeList({\n id: droppableId,\n ref,\n innerRef,\n horizontal,\n renderDraggedNode,\n })\n );\n\n // Update the ID of the list if it changes\n useEffect(() => {\n listRef.current.id = droppableId;\n }, [droppableId]);\n\n // Update the list orientation if it changes.\n // There is no need to check the order of the nodes in the list because it will be the same.\n useEffect(() => {\n listRef.current.horizontal = horizontal;\n }, [horizontal]);\n\n // Update the callback that renders the dragged node if it changes\n useEffect(() => {\n listRef.current.renderDraggedNode = renderDraggedNode;\n }, [renderDraggedNode]);\n\n const { registerList, deregisterList, onMouseDown, onTouchStart } =\n useDragAndDrop();\n\n // Register the list in the store\n useEffect(() => {\n registerList(listRef.current);\n const listId = listRef.current.id;\n return () => deregisterList(listId);\n }, [deregisterList, registerList]);\n\n const registerNode = useCallback(\n (props: NodeProps) => listRef.current.add(props),\n []\n );\n const deregisterNode = useCallback((node: ExistingNode) => {\n listRef.current.remove(node);\n }, []);\n\n // Handlers that determine whether a user clicks on the node\n const mouseDownHandler = useCallback(\n (e: MouseEvent, node: ExistingNode) => {\n onMouseDown(e, listRef.current, node);\n },\n [onMouseDown]\n );\n const touchStartHandler = useCallback(\n (e: TouchEvent, node: ExistingNode) => {\n onTouchStart(e, listRef.current, node);\n },\n [onTouchStart]\n );\n\n const droppableContext = useMemoObject({\n registerNode,\n deregisterNode,\n onMouseDown: mouseDownHandler,\n onTouchStart: touchStartHandler,\n });\n\n return (\n <DroppableContext.Provider value={droppableContext}>\n {(children as Function)({ ref, innerRef })}\n </DroppableContext.Provider>\n );\n};\n\nexport default Droppable;\n"],"mappings":"AAAA,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SAAS"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListStore.js","names":["ListStore","constructor","lists","add","list","push","remove","id","index","findIndex","item","splice","findByPosition","x","y","find","current","ref","rect","getBoundingClientRect","width","height"],"sources":["../../../src/utils/ListStore.ts"],"sourcesContent":["import NodeList from './NodeList';\n\n/**\n * Stores all the lists where the draggable items is located.\n */\nclass ListStore {\n private lists: NodeList[];\n\n public constructor() {\n this.lists = [];\n }\n\n /**\n * Adds a new list to the store.\n */\n public add(list: NodeList) {\n this.lists.push(list);\n }\n\n /**\n * Removes the list from the store.\n */\n public remove(id: string) {\n const index = this.lists.findIndex((item) => item.id === id);\n if (index === -1) return;\n this.lists.splice(index, 1);\n }\n\n /**\n * Returns the list in which the position is located.\n */\n public findByPosition(x: number, y: number) {\n return this.lists.find((list) => {\n const { current } = list.ref;\n if (!current) return false;\n const rect = current.getBoundingClientRect();\n return (\n x >= rect.x &&\n x <= rect.x + rect.width &&\n y >= rect.y &&\n y <= rect.y + rect.height\n );\n });\n }\n}\n\nexport default ListStore;\n"],"mappings":"AAEA;AACA;AACA;AACA,MAAMA,SAAS,CAAC;EAGPC,
|
|
1
|
+
{"version":3,"file":"ListStore.js","names":["ListStore","constructor","lists","add","list","push","remove","id","index","findIndex","item","splice","findByPosition","x","y","find","current","ref","rect","getBoundingClientRect","width","height"],"sources":["../../../src/utils/ListStore.ts"],"sourcesContent":["import NodeList from './NodeList';\n\n/**\n * Stores all the lists where the draggable items is located.\n */\nclass ListStore {\n private lists: NodeList[];\n\n public constructor() {\n this.lists = [];\n }\n\n /**\n * Adds a new list to the store.\n */\n public add(list: NodeList) {\n this.lists.push(list);\n }\n\n /**\n * Removes the list from the store.\n */\n public remove(id: string) {\n const index = this.lists.findIndex((item) => item.id === id);\n if (index === -1) return;\n this.lists.splice(index, 1);\n }\n\n /**\n * Returns the list in which the position is located.\n */\n public findByPosition(x: number, y: number) {\n return this.lists.find((list) => {\n const { current } = list.ref;\n if (!current) return false;\n const rect = current.getBoundingClientRect();\n return (\n x >= rect.x &&\n x <= rect.x + rect.width &&\n y >= rect.y &&\n y <= rect.y + rect.height\n );\n });\n }\n}\n\nexport default ListStore;\n"],"mappings":"AAEA;AACA;AACA;AACA,MAAMA,SAAS,CAAC;EAGPC,WAAWA,CAAA,EAAG;IAAA,KAFbC,KAAK;IAGX,IAAI,CAACA,KAAK,GAAG,EAAE;EACjB;;EAEA;AACF;AACA;EACSC,GAAGA,CAACC,IAAc,EAAE;IACzB,IAAI,CAACF,KAAK,CAACG,IAAI,CAACD,IAAI,CAAC;EACvB;;EAEA;AACF;AACA;EACSE,MAAMA,CAACC,EAAU,EAAE;IACxB,MAAMC,KAAK,GAAG,IAAI,CAACN,KAAK,CAACO,SAAS,CAAEC,IAAI,IAAKA,IAAI,CAACH,EAAE,KAAKA,EAAE,CAAC;IAC5D,IAAIC,KAAK,KAAK,CAAC,CAAC,EAAE;IAClB,IAAI,CAACN,KAAK,CAACS,MAAM,CAACH,KAAK,EAAE,CAAC,CAAC;EAC7B;;EAEA;AACF;AACA;EACSI,cAAcA,CAACC,CAAS,EAAEC,CAAS,EAAE;IAC1C,OAAO,IAAI,CAACZ,KAAK,CAACa,IAAI,CAAEX,IAAI,IAAK;MAC/B,MAAM;QAAEY;MAAQ,CAAC,GAAGZ,IAAI,CAACa,GAAG;MAC5B,IAAI,CAACD,OAAO,EAAE,OAAO,KAAK;MAC1B,MAAME,IAAI,GAAGF,OAAO,CAACG,qBAAqB,CAAC,CAAC;MAC5C,OACEN,CAAC,IAAIK,IAAI,CAACL,CAAC,IACXA,CAAC,IAAIK,IAAI,CAACL,CAAC,GAAGK,IAAI,CAACE,KAAK,IACxBN,CAAC,IAAII,IAAI,CAACJ,CAAC,IACXA,CAAC,IAAII,IAAI,CAACJ,CAAC,GAAGI,IAAI,CAACG,MAAM;IAE7B,CAAC,CAAC;EACJ;AACF;AAEA,eAAerB,SAAS"}
|
|
@@ -1,53 +1,42 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any,no-param-reassign,prefer-destructuring,no-constant-condition */
|
|
2
|
-
|
|
3
|
-
// [prev, next, ref, setStyle, index, id]
|
|
4
|
-
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any,no-param-reassign,prefer-destructuring,no-constant-condition */ // [prev, next, ref, setStyle, index, id]
|
|
5
2
|
/**
|
|
6
3
|
* Stores all the draggable items in the list.
|
|
7
4
|
* The structure of the doubly linked list is used.
|
|
8
5
|
*/
|
|
9
6
|
class NodeList {
|
|
10
|
-
/**
|
|
11
|
-
* The ID of the list.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* The ref to the list.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* The inner ref to the list.
|
|
20
|
-
* Used by the virtual list.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Whether the list is horizontal.
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* The callback that renders the dragged node.
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* The head of draggable nodes.
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* The tail of draggable nodes.
|
|
37
|
-
*/
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Listeners of node addition events.
|
|
41
|
-
*/
|
|
42
|
-
|
|
43
7
|
constructor(props) {
|
|
8
|
+
/**
|
|
9
|
+
* The ID of the list.
|
|
10
|
+
*/
|
|
44
11
|
this.id = void 0;
|
|
12
|
+
/**
|
|
13
|
+
* The ref to the list.
|
|
14
|
+
*/
|
|
45
15
|
this.ref = void 0;
|
|
16
|
+
/**
|
|
17
|
+
* The inner ref to the list.
|
|
18
|
+
* Used by the virtual list.
|
|
19
|
+
*/
|
|
46
20
|
this.innerRef = void 0;
|
|
21
|
+
/**
|
|
22
|
+
* Whether the list is horizontal.
|
|
23
|
+
*/
|
|
47
24
|
this.horizontal = void 0;
|
|
25
|
+
/**
|
|
26
|
+
* The callback that renders the dragged node.
|
|
27
|
+
*/
|
|
48
28
|
this.renderDraggedNode = void 0;
|
|
29
|
+
/**
|
|
30
|
+
* The head of draggable nodes.
|
|
31
|
+
*/
|
|
49
32
|
this.head = void 0;
|
|
33
|
+
/**
|
|
34
|
+
* The tail of draggable nodes.
|
|
35
|
+
*/
|
|
50
36
|
this.tail = void 0;
|
|
37
|
+
/**
|
|
38
|
+
* Listeners of node addition events.
|
|
39
|
+
*/
|
|
51
40
|
this.listeners = void 0;
|
|
52
41
|
this.id = props.id;
|
|
53
42
|
this.ref = props.ref;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeList.js","names":["NodeList","constructor","props","id","ref","innerRef","horizontal","renderDraggedNode","head","tail","listeners","getHead","getTail","addToTheBeginning","setStyle","index","next","addToTheEnd","prev","addAfter","node","add","forEach","listener","headIndex","tailIndex","nextIndex","remove","addListener","callback","push","removeListener","findIndex","splice"],"sources":["../../../src/utils/NodeList.ts"],"sourcesContent":["import React, { CSSProperties, RefObject } from 'react';\n\n/* eslint-disable @typescript-eslint/no-explicit-any,no-param-reassign,prefer-destructuring,no-constant-condition */\n\n// [prev, next, ref, setStyle, index, id]\nexport type Node =\n | [Node, Node, RefObject<any>, (style: CSSProperties) => void, number, string]\n | null;\n\nexport type ExistingNode = Exclude<Node, null>;\n\nexport interface NodeProps {\n ref: React.MutableRefObject<any>;\n setStyle: (style: CSSProperties) => void;\n index: number;\n id: string;\n}\n\ninterface RenderDraggedNodeProps {\n /**\n * The index of the dragged node.\n */\n index: number;\n /**\n * The ID of the dragged node.\n */\n id: string;\n /**\n * The style of the dragged node with position.\n */\n style: CSSProperties;\n}\n\nexport type RenderDraggedNode = (\n props: RenderDraggedNodeProps\n) => React.ReactNode;\n\ninterface InitProps {\n id: string;\n ref: RefObject<HTMLDivElement>;\n innerRef: RefObject<HTMLDivElement>;\n horizontal: boolean;\n renderDraggedNode: RenderDraggedNode;\n}\n\n/**\n * Stores all the draggable items in the list.\n * The structure of the doubly linked list is used.\n */\nclass NodeList {\n /**\n * The ID of the list.\n */\n public id: string;\n\n /**\n * The ref to the list.\n */\n public ref: RefObject<HTMLDivElement>;\n\n /**\n * The inner ref to the list.\n * Used by the virtual list.\n */\n public innerRef: RefObject<HTMLDivElement>;\n\n /**\n * Whether the list is horizontal.\n */\n public horizontal: boolean;\n\n /**\n * The callback that renders the dragged node.\n */\n public renderDraggedNode: RenderDraggedNode;\n\n /**\n * The head of draggable nodes.\n */\n private head: Node;\n\n /**\n * The tail of draggable nodes.\n */\n private tail: Node;\n\n /**\n * Listeners of node addition events.\n */\n private listeners: Array<(props: NodeProps) => void>;\n\n public constructor(props: InitProps) {\n this.id = props.id;\n this.ref = props.ref;\n this.innerRef = props.innerRef;\n this.horizontal = props.horizontal;\n this.renderDraggedNode = props.renderDraggedNode;\n this.head = null;\n this.tail = null;\n this.listeners = [];\n }\n\n public getHead() {\n return this.head;\n }\n\n public getTail() {\n return this.tail;\n }\n\n /**\n * Adds the node to the beginning.\n * TL: O(1).\n */\n private addToTheBeginning(props: NodeProps): ExistingNode {\n this.head = [\n null,\n this.head,\n props.ref,\n props.setStyle,\n props.index,\n props.id,\n ];\n const [, next] = this.head;\n if (next) next[0] = this.head; // Set the prev cursor of the next element\n if (!this.tail) this.tail = this.head;\n return this.head;\n }\n\n /**\n * Adds the node to the end.\n * TL: O(1).\n */\n private addToTheEnd(props: NodeProps): ExistingNode {\n this.tail = [\n this.tail,\n null,\n props.ref,\n props.setStyle,\n props.index,\n props.id,\n ];\n const [prev] = this.tail;\n if (prev) prev[1] = this.tail; // Set the next cursor of the prev element\n if (!this.head) this.head = this.tail;\n return this.tail;\n }\n\n /**\n * Adds the node after the specified one.\n * TL: O(1).\n */\n private static addAfter(node: ExistingNode, props: NodeProps): ExistingNode {\n node[1] = [node, node[1], props.ref, props.setStyle, props.index, props.id];\n if (node[1][1]) node[1][1][0] = node[1];\n return node[1];\n }\n\n /**\n * Adds a new node depends on its position.\n * Called when a new node is mounted.\n * TL: O(1) – add to the beginning or to the end, O(n) – add to the middle.\n */\n public add(props: NodeProps): ExistingNode {\n const { index } = props;\n\n // Run listeners\n this.listeners.forEach((listener) => listener(props));\n\n // Add the first node to the beginning\n if (!this.head || !this.tail) {\n return this.addToTheBeginning(props);\n }\n\n // Add the node to the beginning if it is located above the first one\n const [, , , , headIndex] = this.head;\n if (index < headIndex) {\n return this.addToTheBeginning(props);\n }\n\n // Add the node to the end if it is located below the last one\n const [, , , , tailIndex] = this.tail;\n if (index === tailIndex) {\n // The tail is the blank node\n const [prev] = this.tail;\n if (prev) {\n this.tail[4] += 1;\n return NodeList.addAfter(prev, props);\n }\n }\n if (index > tailIndex) {\n return this.addToTheEnd(props);\n }\n\n // Add the node after the one that is located above the current one\n let node = this.head;\n while (true) {\n const [, next] = node;\n if (!next) break;\n const [, , , , nextIndex] = next;\n if (index < nextIndex) break;\n node = next;\n }\n return NodeList.addAfter(node, props);\n }\n\n /**\n * Removes the existing node.\n * Called when the node is unmounted.\n * TL: O(1).\n */\n public remove(node: ExistingNode) {\n const [prev, next] = node;\n if (!prev && !next) {\n this.head = null;\n this.tail = null;\n return;\n }\n if (!prev && next) {\n next[0] = null;\n this.head = next;\n return;\n }\n if (prev && !next) {\n prev[1] = null;\n this.tail = prev;\n return;\n }\n if (prev && next) {\n prev[1] = next;\n next[0] = prev;\n }\n }\n\n public addListener(callback: (props: NodeProps) => void) {\n this.listeners.push(callback);\n }\n\n public removeListener(callback: (props: NodeProps) => void) {\n const index = this.listeners.findIndex((listener) => listener === callback);\n this.listeners.splice(index, 1);\n }\n}\n\nexport default NodeList;\n"],"mappings":"AAEA;;AAEA;;AAyCA;AACA;AACA;AACA;AACA,MAAMA,QAAQ,CAAC;EACb;AACF;AACA;;EAGE;AACF;AACA;;EAGE;AACF;AACA;AACA;;EAGE;AACF;AACA;;EAGE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I,EAAE;MACjBA,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI;MACd,IAAI,CAACR,IAAI,GAAGQ,IAAI;MAChB;IACF;IACA,IAAIE,IAAI,IAAI,CAACF,IAAI,EAAE;MACjBE,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI;MACd,IAAI,CAACT,IAAI,GAAGS,IAAI;MAChB;IACF;IACA,IAAIA,IAAI,IAAIF,IAAI,EAAE;MAChBE,IAAI,CAAC,CAAC,CAAC,GAAGF,IAAI;MACdA,IAAI,CAAC,CAAC,CAAC,GAAGE,IAAI;IAChB;EACF;EAEOU,WAAW,CAACC,QAAoC,EAAE;IACvD,IAAI,CAACnB,SAAS,CAACoB,IAAI,CAACD,QAAQ,CAAC;EAC/B;EAEOE,cAAc,CAACF,QAAoC,EAAE;IAC1D,MAAMd,KAAK,GAAG,IAAI,CAACL,SAAS,CAACsB,SAAS,CAAET,QAAQ,IAAKA,QAAQ,KAAKM,QAAQ,CAAC;IAC3E,IAAI,CAACnB,SAAS,CAACuB,MAAM,CAAClB,KAAK,EAAE,CAAC,CAAC;EACjC;AACF;AAEA,eAAef,QAAQ"}
|
|
1
|
+
{"version":3,"file":"NodeList.js","names":["NodeList","constructor","props","id","ref","innerRef","horizontal","renderDraggedNode","head","tail","listeners","getHead","getTail","addToTheBeginning","setStyle","index","next","addToTheEnd","prev","addAfter","node","add","forEach","listener","headIndex","tailIndex","nextIndex","remove","addListener","callback","push","removeListener","findIndex","splice"],"sources":["../../../src/utils/NodeList.ts"],"sourcesContent":["import React, { CSSProperties, RefObject } from 'react';\n\n/* eslint-disable @typescript-eslint/no-explicit-any,no-param-reassign,prefer-destructuring,no-constant-condition */\n\n// [prev, next, ref, setStyle, index, id]\nexport type Node =\n | [Node, Node, RefObject<any>, (style: CSSProperties) => void, number, string]\n | null;\n\nexport type ExistingNode = Exclude<Node, null>;\n\nexport interface NodeProps {\n ref: React.MutableRefObject<any>;\n setStyle: (style: CSSProperties) => void;\n index: number;\n id: string;\n}\n\ninterface RenderDraggedNodeProps {\n /**\n * The index of the dragged node.\n */\n index: number;\n /**\n * The ID of the dragged node.\n */\n id: string;\n /**\n * The style of the dragged node with position.\n */\n style: CSSProperties;\n}\n\nexport type RenderDraggedNode = (\n props: RenderDraggedNodeProps\n) => React.ReactNode;\n\ninterface InitProps {\n id: string;\n ref: RefObject<HTMLDivElement>;\n innerRef: RefObject<HTMLDivElement>;\n horizontal: boolean;\n renderDraggedNode: RenderDraggedNode;\n}\n\n/**\n * Stores all the draggable items in the list.\n * The structure of the doubly linked list is used.\n */\nclass NodeList {\n /**\n * The ID of the list.\n */\n public id: string;\n\n /**\n * The ref to the list.\n */\n public ref: RefObject<HTMLDivElement>;\n\n /**\n * The inner ref to the list.\n * Used by the virtual list.\n */\n public innerRef: RefObject<HTMLDivElement>;\n\n /**\n * Whether the list is horizontal.\n */\n public horizontal: boolean;\n\n /**\n * The callback that renders the dragged node.\n */\n public renderDraggedNode: RenderDraggedNode;\n\n /**\n * The head of draggable nodes.\n */\n private head: Node;\n\n /**\n * The tail of draggable nodes.\n */\n private tail: Node;\n\n /**\n * Listeners of node addition events.\n */\n private listeners: Array<(props: NodeProps) => void>;\n\n public constructor(props: InitProps) {\n this.id = props.id;\n this.ref = props.ref;\n this.innerRef = props.innerRef;\n this.horizontal = props.horizontal;\n this.renderDraggedNode = props.renderDraggedNode;\n this.head = null;\n this.tail = null;\n this.listeners = [];\n }\n\n public getHead() {\n return this.head;\n }\n\n public getTail() {\n return this.tail;\n }\n\n /**\n * Adds the node to the beginning.\n * TL: O(1).\n */\n private addToTheBeginning(props: NodeProps): ExistingNode {\n this.head = [\n null,\n this.head,\n props.ref,\n props.setStyle,\n props.index,\n props.id,\n ];\n const [, next] = this.head;\n if (next) next[0] = this.head; // Set the prev cursor of the next element\n if (!this.tail) this.tail = this.head;\n return this.head;\n }\n\n /**\n * Adds the node to the end.\n * TL: O(1).\n */\n private addToTheEnd(props: NodeProps): ExistingNode {\n this.tail = [\n this.tail,\n null,\n props.ref,\n props.setStyle,\n props.index,\n props.id,\n ];\n const [prev] = this.tail;\n if (prev) prev[1] = this.tail; // Set the next cursor of the prev element\n if (!this.head) this.head = this.tail;\n return this.tail;\n }\n\n /**\n * Adds the node after the specified one.\n * TL: O(1).\n */\n private static addAfter(node: ExistingNode, props: NodeProps): ExistingNode {\n node[1] = [node, node[1], props.ref, props.setStyle, props.index, props.id];\n if (node[1][1]) node[1][1][0] = node[1];\n return node[1];\n }\n\n /**\n * Adds a new node depends on its position.\n * Called when a new node is mounted.\n * TL: O(1) – add to the beginning or to the end, O(n) – add to the middle.\n */\n public add(props: NodeProps): ExistingNode {\n const { index } = props;\n\n // Run listeners\n this.listeners.forEach((listener) => listener(props));\n\n // Add the first node to the beginning\n if (!this.head || !this.tail) {\n return this.addToTheBeginning(props);\n }\n\n // Add the node to the beginning if it is located above the first one\n const [, , , , headIndex] = this.head;\n if (index < headIndex) {\n return this.addToTheBeginning(props);\n }\n\n // Add the node to the end if it is located below the last one\n const [, , , , tailIndex] = this.tail;\n if (index === tailIndex) {\n // The tail is the blank node\n const [prev] = this.tail;\n if (prev) {\n this.tail[4] += 1;\n return NodeList.addAfter(prev, props);\n }\n }\n if (index > tailIndex) {\n return this.addToTheEnd(props);\n }\n\n // Add the node after the one that is located above the current one\n let node = this.head;\n while (true) {\n const [, next] = node;\n if (!next) break;\n const [, , , , nextIndex] = next;\n if (index < nextIndex) break;\n node = next;\n }\n return NodeList.addAfter(node, props);\n }\n\n /**\n * Removes the existing node.\n * Called when the node is unmounted.\n * TL: O(1).\n */\n public remove(node: ExistingNode) {\n const [prev, next] = node;\n if (!prev && !next) {\n this.head = null;\n this.tail = null;\n return;\n }\n if (!prev && next) {\n next[0] = null;\n this.head = next;\n return;\n }\n if (prev && !next) {\n prev[1] = null;\n this.tail = prev;\n return;\n }\n if (prev && next) {\n prev[1] = next;\n next[0] = prev;\n }\n }\n\n public addListener(callback: (props: NodeProps) => void) {\n this.listeners.push(callback);\n }\n\n public removeListener(callback: (props: NodeProps) => void) {\n const index = this.listeners.findIndex((listener) => listener === callback);\n this.listeners.splice(index, 1);\n }\n}\n\nexport default NodeList;\n"],"mappings":"AAEA,qHAEA;AAyCA;AACA;AACA;AACA;AACA,MAAMA,QAAQ,CAAC;EA0CNC,WAAWA,CAACC,KAAgB,EAAE;IAzCrC;AACF;AACA;IAFE,KAGOC,EAAE;IAET;AACF;AACA;IAFE,KAGOC,GAAG;IAEV;AACF;AACA;AACA;IAHE,KAIOC,QAAQ;IAEf;AACF;AACA;IAFE,KAGOC,UAAU;IAEjB;AACF;AACA;IAFE,KAGOC,iBAAiB;IAExB;AACF;AACA;IAFE,KAGQC,IAAI;IAEZ;AACF;AACA;IAFE,KAGQC,IAAI;IAEZ;AACF;AACA;IAFE,KAGQC,SAAS;IAGf,IAAI,CAACP,EAAE,GAAGD,KAAK,CAACC,EAAE;IAClB,IAAI,CAACC,GAAG,GAAGF,KAAK,CAACE,GAAG;IACpB,IAAI,CAACC,QAAQ,GAAGH,KAAK,CAACG,QAAQ;IAC9B,IAAI,CAACC,UAAU,GAAGJ,KAAK,CAACI,UAAU;IAClC,IAAI,CAACC,iBAAiB,GAAGL,KAAK,CAACK,iBAAiB;IAChD,IAAI,CAACC,IAAI,GAAG,IAAI;IAChB,IAAI,CAACC,IAAI,GAAG,IAAI;IAChB,IAAI,CAACC,SAAS,GAAG,EAAE;EACrB;EAEOC,OAAOA,CAAA,EAAG;IACf,OAAO,IAAI,CAACH,IAAI;EAClB;EAEOI,OAAOA,CAAA,EAAG;IACf,OAAO,IAAI,CAACH,IAAI;EAClB;;EAEA;AACF;AACA;AACA;EACUI,iBAAiBA,CAACX,KAAgB,EAAgB;IACxD,IAAI,CAACM,IAAI,GAAG,CACV,IAAI,EACJ,IAAI,CAACA,IAAI,EACTN,KAAK,CAACE,GAAG,EACTF,KAAK,CAACY,QAAQ,EACdZ,KAAK,CAACa,KAAK,EACXb,KAAK,CAACC,EAAE,CACT;IACD,MAAM,GA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A;AACA;EACSyB,MAAMA,CAACP,IAAkB,EAAE;IAChC,MAAM,CAACF,IAAI,EAAEF,IAAI,CAAC,GAAGI,IAAI;IACzB,IAAI,CAACF,IAAI,IAAI,CAACF,IAAI,EAAE;MAClB,IAAI,CAACR,IAAI,GAAG,IAAI;MAChB,IAAI,CAACC,IAAI,GAAG,IAAI;MAChB;IACF;IACA,IAAI,CAACS,IAAI,IAAIF,IAAI,EAAE;MACjBA,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI;MACd,IAAI,CAACR,IAAI,GAAGQ,IAAI;MAChB;IACF;IACA,IAAIE,IAAI,IAAI,CAACF,IAAI,EAAE;MACjBE,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI;MACd,IAAI,CAACT,IAAI,GAAGS,IAAI;MAChB;IACF;IACA,IAAIA,IAAI,IAAIF,IAAI,EAAE;MAChBE,IAAI,CAAC,CAAC,CAAC,GAAGF,IAAI;MACdA,IAAI,CAAC,CAAC,CAAC,GAAGE,IAAI;IAChB;EACF;EAEOU,WAAWA,CAACC,QAAoC,EAAE;IACvD,IAAI,CAACnB,SAAS,CAACoB,IAAI,CAACD,QAAQ,CAAC;EAC/B;EAEOE,cAAcA,CAACF,QAAoC,EAAE;IAC1D,MAAMd,KAAK,GAAG,IAAI,CAACL,SAAS,CAACsB,SAAS,CAAET,QAAQ,IAAKA,QAAQ,KAAKM,QAAQ,CAAC;IAC3E,IAAI,CAACnB,SAAS,CAACuB,MAAM,CAAClB,KAAK,EAAE,CAAC,CAAC;EACjC;AACF;AAEA,eAAef,QAAQ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getNodeRect.js","names":["
|
|
1
|
+
{"version":3,"file":"getNodeRect.js","names":["getElementOffset","getElementScroll","getNodeRect","ref","current","parent","parentElement","width","height","getBoundingClientRect","offsetLeft","offsetTop","scrollLeft","scrollTop","left","top","right","bottom"],"sources":["../../../src/utils/getNodeRect.ts"],"sourcesContent":["import { RefObject } from 'react';\nimport getElementOffset from './getElementOffset';\nimport getElementScroll from './getElementScroll';\n\n/**\n * Computes the bounds of the existing node without considering transforms.\n */\nconst getNodeRect = (ref: RefObject<HTMLElement>) => {\n if (!ref.current) return null;\n\n const parent = ref.current.parentElement;\n const { width, height } = ref.current.getBoundingClientRect();\n const { offsetLeft, offsetTop } = getElementOffset(ref.current);\n const { scrollLeft, scrollTop } = parent\n ? getElementScroll(parent)\n : { scrollLeft: 0, scrollTop: 0 };\n\n const left = offsetLeft - scrollLeft;\n const top = offsetTop - scrollTop;\n\n return {\n left,\n top,\n right: left + width,\n bottom: top + height,\n };\n};\n\nexport default getNodeRect;\n"],"mappings":"AACA,OAAOA,gBAAgB,MAAM,oBAAoB;AACjD,OAAOC,gBAAgB,MAAM,oBAAoB;;AAEjD;AACA;AACA;AACA,MAAMC,WAAW,GAAIC,GAA2B,IAAK;EACnD,IAAI,CAACA,GAAG,CAACC,OAAO,EAAE,OAAO,IAAI;EAE7B,MAAMC,MAAM,GAAGF,GAAG,CAACC,OAAO,CAACE,aAAa;EACxC,MAAM;IAAEC,KAAK;IAAEC;EAAO,CAAC,GAAGL,GAAG,CAACC,OAAO,CAACK,qBAAqB,CAAC,CAAC;EAC7D,MAAM;IAAEC,UAAU;IAAEC;EAAU,CAAC,GAAGX,gBAAgB,CAACG,GAAG,CAACC,OAAO,CAAC;EAC/D,MAAM;IAAEQ,UAAU;IAAEC;EAAU,CAAC,GAAGR,MAAM,GACpCJ,gBAAgB,CAACI,MAAM,CAAC,GACxB;IAAEO,UAAU,EAAE,CAAC;IAAEC,SAAS,EAAE;EAAE,CAAC;EAEnC,MAAMC,IAAI,GAAGJ,UAAU,GAAGE,UAAU;EACpC,MAAMG,GAAG,GAAGJ,SAAS,GAAGE,SAAS;EAEjC,OAAO;IACLC,IAAI;IACJC,GAAG;IACHC,KAAK,EAAEF,IAAI,GAAGP,KAAK;IACnBU,MAAM,EAAEF,GAAG,GAAGP;EAChB,CAAC;AACH,CAAC;AAED,eAAeN,WAAW"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAppendClassName.js","names":["useEffect","useAppendClassName","ref","className","element","current","initClassName","trim"],"sources":["../../../src/utils/useAppendClassName.ts"],"sourcesContent":["import { RefObject, useEffect } from 'react';\n\n/**\n * Adds a new class name to the element.\n */\nconst useAppendClassName = (ref: RefObject<HTMLElement>, className: string) => {\n useEffect(() => {\n const element = ref.current;\n if (!element) return () => {};\n\n const initClassName = element.className;\n element.className = `${initClassName} ${className}`.trim();\n\n return () => {\n element.className = initClassName;\n };\n }, [className, ref]);\n};\n\nexport default useAppendClassName;\n"],"mappings":"AAAA,SAAoBA,SAAS,QAAQ,OAAO;;AAE5C;AACA;AACA;AACA,MAAMC,kBAAkB,
|
|
1
|
+
{"version":3,"file":"useAppendClassName.js","names":["useEffect","useAppendClassName","ref","className","element","current","initClassName","trim"],"sources":["../../../src/utils/useAppendClassName.ts"],"sourcesContent":["import { RefObject, useEffect } from 'react';\n\n/**\n * Adds a new class name to the element.\n */\nconst useAppendClassName = (ref: RefObject<HTMLElement>, className: string) => {\n useEffect(() => {\n const element = ref.current;\n if (!element) return () => {};\n\n const initClassName = element.className;\n element.className = `${initClassName} ${className}`.trim();\n\n return () => {\n element.className = initClassName;\n };\n }, [className, ref]);\n};\n\nexport default useAppendClassName;\n"],"mappings":"AAAA,SAAoBA,SAAS,QAAQ,OAAO;;AAE5C;AACA;AACA;AACA,MAAMC,kBAAkB,GAAGA,CAACC,GAA2B,EAAEC,SAAiB,KAAK;EAC7EH,SAAS,CAAC,MAAM;IACd,MAAMI,OAAO,GAAGF,GAAG,CAACG,OAAO;IAC3B,IAAI,CAACD,OAAO,EAAE,OAAO,MAAM,CAAC,CAAC;IAE7B,MAAME,aAAa,GAAGF,OAAO,CAACD,SAAS;IACvCC,OAAO,CAACD,SAAS,GAAI,GAAEG,aAAc,IAAGH,SAAU,EAAC,CAACI,IAAI,CAAC,CAAC;IAE1D,OAAO,MAAM;MACXH,OAAO,CAACD,SAAS,GAAGG,aAAa;IACnC,CAAC;EACH,CAAC,EAAE,CAACH,SAAS,EAAED,GAAG,CAAC,CAAC;AACtB,CAAC;AAED,eAAeD,kBAAkB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBlankNode.js","names":["useCallback","useEffect","useRef","useBlankNode","props","draggedNode","targetList","initDraggedNodeRect","initDraggedNodeRectRef","blankNode","current","ref","list","initWidth","initHeight","div","document","createElement","style","width","height","minWidth","minHeight","parent","innerList","innerRef","getBoundingClientRect","position","left","horizontal","top","appendChild","tail","getTail","node","add","setStyle","index","id","removeBlankNode","blank","remove","blankNodeRef","parentElement","removeChild"],"sources":["../../../src/utils/useBlankNode.ts"],"sourcesContent":["import { useCallback, useEffect, useRef } from 'react';\nimport NodeList, { ExistingNode } from './NodeList';\n\ninterface InitSize {\n initWidth: number;\n initHeight: number;\n}\n\ninterface DraggedNode {\n list: NodeList;\n}\n\ninterface UseBlankNodeProps {\n draggedNode: DraggedNode | null;\n targetList: NodeList | null;\n initDraggedNodeRect: InitSize | null;\n}\n\ninterface BlankNode {\n list: NodeList;\n node: ExistingNode;\n}\n\n/**\n * Appends the blank node to the list to increase the height of it.\n * Used when the dragged node is located inside another list.\n */\nconst useBlankNode = (props: UseBlankNodeProps) => {\n const { draggedNode, targetList, initDraggedNodeRect } = props;\n const initDraggedNodeRectRef = useRef(initDraggedNodeRect);\n const blankNode = useRef<BlankNode | null>(null);\n\n useEffect(() => {\n initDraggedNodeRectRef.current = initDraggedNodeRect;\n }, [initDraggedNodeRect]);\n\n useEffect(() => {\n if (\n !draggedNode ||\n !targetList ||\n !targetList.ref.current ||\n draggedNode.list === targetList ||\n !initDraggedNodeRectRef.current\n ) {\n return;\n }\n\n // Create a new blank div\n const { initWidth, initHeight } = initDraggedNodeRectRef.current;\n const div = document.createElement('div');\n div.style.width = `${initWidth}px`;\n div.style.height = `${initHeight}px`;\n div.style.minWidth = `${initWidth}px`;\n div.style.minHeight = `${initHeight}px`;\n\n let parent = targetList.ref.current;\n const innerList = targetList.innerRef.current;\n\n // The inner ref used only in the virtual list\n if (innerList) {\n const { width, height } = innerList.getBoundingClientRect();\n div.style.position = 'absolute';\n div.style.left = targetList.horizontal ? `${width}px` : '0px';\n div.style.top = targetList.horizontal ? '0px' : `${height}px`;\n parent = innerList;\n }\n\n // Append the blank div to increase the height of the list\n parent.appendChild(div);\n\n // Add the blank node to the node list\n const tail = targetList.getTail();\n blankNode.current = {\n list: targetList,\n node: targetList.add({\n ref: { current: div },\n setStyle: () => {},\n index: tail ? tail[4] + 1 : 0,\n id: 'blank',\n }),\n };\n }, [draggedNode, targetList]);\n\n const removeBlankNode = useCallback(() => {\n const blank = blankNode.current;\n if (!blank) return;\n blankNode.current = null;\n blank.list.remove(blank.node);\n const [, , blankNodeRef] = blank.node;\n if (!blank.list.ref.current || !blankNodeRef.current) return;\n const parent = blankNodeRef.current.parentElement;\n if (parent) parent.removeChild(blankNodeRef.current);\n }, []);\n\n // Remove the blank node if the dragged node has been dropped\n useEffect(() => {\n if (!draggedNode) return () => {};\n return () => removeBlankNode();\n }, [draggedNode, removeBlankNode]);\n\n return removeBlankNode;\n};\n\nexport default useBlankNode;\n"],"mappings":"AAAA,SAASA,WAAW,EAAEC,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAuBtD;AACA;AACA;AACA;AACA,MAAMC,YAAY,GAAIC,KAAwB,IAAK;EACjD,MAAM;IAAEC,WAAW;IAAEC,UAAU;IAAEC;EAAoB,CAAC,GAAGH,KAAK;EAC9D,MAAMI,sBAAsB,GAAGN,MAAM,CAACK,mBAAmB,CAAC;EAC1D,MAAME,SAAS,GAAGP,MAAM,CAAmB,IAAI,CAAC;EAEhDD,SAAS,CAAC,MAAM;IACdO,sBAAsB,CAACE,OAAO,GAAGH,mBAAmB;EACtD,CAAC,EAAE,CAACA,mBAAmB,CAAC,CAAC;EAEzBN,SAAS,CAAC,MAAM;IACd,IACE,CAACI,WAAW,IACZ,CAACC,UAAU,IACX,CAACA,UAAU,CAACK,GAAG,CAACD,OAAO,IACvBL,WAAW,CAACO,IAAI,KAAKN,UAAU,IAC/B,CAACE,sBAAsB,CAACE,OAAO,EAC/B;MACA;IACF;;IAEA;IACA,MAAM;MAAEG,SAAS;MAAEC;IAAW,CAAC,GAAGN,sBAAsB,CAACE,OAAO;IAChE,MAAMK,GAAG,GAAGC,QAAQ,CAACC,aAAa,CAAC,KAAK,CAAC;IACzCF,GAAG,CAACG,KAAK,CAACC,KAAK,GAAI,GAAEN,SAAU,IAAG;IAClCE,GAAG,CAACG,KAAK,CAACE,MAAM,GAAI,GAAEN,UAAW,IAAG;IACpCC,GAAG,CAACG,KAAK,CAACG,QAAQ,GAAI,GAAER,SAAU,IAAG;IACrCE,GAAG,CAACG,KAAK,CAACI,SAAS,GAAI,GAAER,UAAW,IAAG;IAEvC,IAAIS,MAAM,GAAGjB,UAAU,CAACK,GAAG,CAACD,OAAO;IACnC,MAAMc,SAAS,GAAGlB,UAAU,CAACmB,QAAQ,CAACf,OAAO;;IAE7C;IACA,IAAIc,SAAS,EAAE;MACb,MAAM;QAAEL,KAAK;QAAEC;MAAO,CAAC,GAAGI,SAAS,CAACE,qBAAqB,
|
|
1
|
+
{"version":3,"file":"useBlankNode.js","names":["useCallback","useEffect","useRef","useBlankNode","props","draggedNode","targetList","initDraggedNodeRect","initDraggedNodeRectRef","blankNode","current","ref","list","initWidth","initHeight","div","document","createElement","style","width","height","minWidth","minHeight","parent","innerList","innerRef","getBoundingClientRect","position","left","horizontal","top","appendChild","tail","getTail","node","add","setStyle","index","id","removeBlankNode","blank","remove","blankNodeRef","parentElement","removeChild"],"sources":["../../../src/utils/useBlankNode.ts"],"sourcesContent":["import { useCallback, useEffect, useRef } from 'react';\nimport NodeList, { ExistingNode } from './NodeList';\n\ninterface InitSize {\n initWidth: number;\n initHeight: number;\n}\n\ninterface DraggedNode {\n list: NodeList;\n}\n\ninterface UseBlankNodeProps {\n draggedNode: DraggedNode | null;\n targetList: NodeList | null;\n initDraggedNodeRect: InitSize | null;\n}\n\ninterface BlankNode {\n list: NodeList;\n node: ExistingNode;\n}\n\n/**\n * Appends the blank node to the list to increase the height of it.\n * Used when the dragged node is located inside another list.\n */\nconst useBlankNode = (props: UseBlankNodeProps) => {\n const { draggedNode, targetList, initDraggedNodeRect } = props;\n const initDraggedNodeRectRef = useRef(initDraggedNodeRect);\n const blankNode = useRef<BlankNode | null>(null);\n\n useEffect(() => {\n initDraggedNodeRectRef.current = initDraggedNodeRect;\n }, [initDraggedNodeRect]);\n\n useEffect(() => {\n if (\n !draggedNode ||\n !targetList ||\n !targetList.ref.current ||\n draggedNode.list === targetList ||\n !initDraggedNodeRectRef.current\n ) {\n return;\n }\n\n // Create a new blank div\n const { initWidth, initHeight } = initDraggedNodeRectRef.current;\n const div = document.createElement('div');\n div.style.width = `${initWidth}px`;\n div.style.height = `${initHeight}px`;\n div.style.minWidth = `${initWidth}px`;\n div.style.minHeight = `${initHeight}px`;\n\n let parent = targetList.ref.current;\n const innerList = targetList.innerRef.current;\n\n // The inner ref used only in the virtual list\n if (innerList) {\n const { width, height } = innerList.getBoundingClientRect();\n div.style.position = 'absolute';\n div.style.left = targetList.horizontal ? `${width}px` : '0px';\n div.style.top = targetList.horizontal ? '0px' : `${height}px`;\n parent = innerList;\n }\n\n // Append the blank div to increase the height of the list\n parent.appendChild(div);\n\n // Add the blank node to the node list\n const tail = targetList.getTail();\n blankNode.current = {\n list: targetList,\n node: targetList.add({\n ref: { current: div },\n setStyle: () => {},\n index: tail ? tail[4] + 1 : 0,\n id: 'blank',\n }),\n };\n }, [draggedNode, targetList]);\n\n const removeBlankNode = useCallback(() => {\n const blank = blankNode.current;\n if (!blank) return;\n blankNode.current = null;\n blank.list.remove(blank.node);\n const [, , blankNodeRef] = blank.node;\n if (!blank.list.ref.current || !blankNodeRef.current) return;\n const parent = blankNodeRef.current.parentElement;\n if (parent) parent.removeChild(blankNodeRef.current);\n }, []);\n\n // Remove the blank node if the dragged node has been dropped\n useEffect(() => {\n if (!draggedNode) return () => {};\n return () => removeBlankNode();\n }, [draggedNode, removeBlankNode]);\n\n return removeBlankNode;\n};\n\nexport default useBlankNode;\n"],"mappings":"AAAA,SAASA,WAAW,EAAEC,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAuBtD;AACA;AACA;AACA;AACA,MAAMC,YAAY,GAAIC,KAAwB,IAAK;EACjD,MAAM;IAAEC,WAAW;IAAEC,UAAU;IAAEC;EAAoB,CAAC,GAAGH,KAAK;EAC9D,MAAMI,sBAAsB,GAAGN,MAAM,CAACK,mBAAmB,CAAC;EAC1D,MAAME,SAAS,GAAGP,MAAM,CAAmB,IAAI,CAAC;EAEhDD,SAAS,CAAC,MAAM;IACdO,sBAAsB,CAACE,OAAO,GAAGH,mBAAmB;EACtD,CAAC,EAAE,CAACA,mBAAmB,CAAC,CAAC;EAEzBN,SAAS,CAAC,MAAM;IACd,IACE,CAACI,WAAW,IACZ,CAACC,UAAU,IACX,CAACA,UAAU,CAACK,GAAG,CAACD,OAAO,IACvBL,WAAW,CAACO,IAAI,KAAKN,UAAU,IAC/B,CAACE,sBAAsB,CAACE,OAAO,EAC/B;MACA;IACF;;IAEA;IACA,MAAM;MAAEG,SAAS;MAAEC;IAAW,CAAC,GAAGN,sBAAsB,CAACE,OAAO;IAChE,MAAMK,GAAG,GAAGC,QAAQ,CAACC,aAAa,CAAC,KAAK,CAAC;IACzCF,GAAG,CAACG,KAAK,CAACC,KAAK,GAAI,GAAEN,SAAU,IAAG;IAClCE,GAAG,CAACG,KAAK,CAACE,MAAM,GAAI,GAAEN,UAAW,IAAG;IACpCC,GAAG,CAACG,KAAK,CAACG,QAAQ,GAAI,GAAER,SAAU,IAAG;IACrCE,GAAG,CAACG,KAAK,CAACI,SAAS,GAAI,GAAER,UAAW,IAAG;IAEvC,IAAIS,MAAM,GAAGjB,UAAU,CAACK,GAAG,CAACD,OAAO;IACnC,MAAMc,SAAS,GAAGlB,UAAU,CAACmB,QAA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ACrC,IAAI,CAACM,KAAK,CAAC5B,IAAI,CAACD,GAAG,CAACD,OAAO,IAAI,CAACgC,YAAY,CAAChC,OAAO,EAAE;IACtD,MAAMa,MAAM,GAAGmB,YAAY,CAAChC,OAAO,CAACiC,aAAa;IACjD,IAAIpB,MAAM,EAAEA,MAAM,CAACqB,WAAW,CAACF,YAAY,CAAChC,OAAO,CAAC;EACtD,CAAC,EAAE,EAAE,CAAC;;EAEN;EACAT,SAAS,CAAC,MAAM;IACd,IAAI,CAACI,WAAW,EAAE,OAAO,MAAM,CAAC,CAAC;IACjC,OAAO,MAAMkC,eAAe,CAAC,CAAC;EAChC,CAAC,EAAE,CAAClC,WAAW,EAAEkC,eAAe,CAAC,CAAC;EAElC,OAAOA,eAAe;AACxB,CAAC;AAED,eAAepC,YAAY"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDragAndDrop.js","names":["React","useContext","DragAndDropContext","createContext","registerList","deregisterList","onMouseDown","onTouchStart","nodeClassName","useDragAndDrop"],"sources":["../../../src/utils/useDragAndDrop.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"useDragAndDrop.js","names":["React","useContext","DragAndDropContext","createContext","registerList","deregisterList","onMouseDown","onTouchStart","nodeClassName","useDragAndDrop"],"sources":["../../../src/utils/useDragAndDrop.ts"],"sourcesContent":["import { Position } from '@os-design/use-drag';\nimport React, { MouseEvent, TouchEvent, useContext } from 'react';\nimport NodeList, { ExistingNode } from './NodeList';\n\nexport interface SetDraggedNodeProps {\n list: NodeList;\n node: ExistingNode;\n position: Position;\n}\n\ntype NodeEventHandler<T> = (e: T, list: NodeList, node: ExistingNode) => void;\n\ninterface DragAndDropContextProps {\n registerList: (list: NodeList) => void;\n deregisterList: (id: string) => void;\n onMouseDown: NodeEventHandler<MouseEvent>;\n onTouchStart: NodeEventHandler<TouchEvent>;\n nodeClassName: string;\n}\n\nexport const DragAndDropContext = React.createContext<DragAndDropContextProps>({\n registerList: () => {},\n deregisterList: () => {},\n onMouseDown: () => {},\n onTouchStart: () => {},\n nodeClassName: '',\n});\n\nconst useDragAndDrop = (): DragAndDropContextProps =>\n useContext(DragAndDropContext);\n\nexport default useDragAndDrop;\n"],"mappings":"AACA,OAAOA,KAAK,IAA4BC,UAAU,QAAQ,OAAO;AAmBjE,OAAO,MAAMC,kBAAkB,gBAAGF,KAAK,CAACG,aAAa,CAA0B;EAC7EC,YAAY,EAAEA,CAAA,KAAM,CAAC,CAAC;EACtBC,cAAc,EAAEA,CAAA,KAAM,CAAC,CAAC;EACxBC,WAAW,EAAEA,CAAA,KAAM,CAAC,CAAC;EACrBC,YAAY,EAAEA,CAAA,KAAM,CAAC,CAAC;EACtBC,aAAa,EAAE;AACjB,CAAC,CAAC;AAEF,MAAMC,cAAc,GAAGA,CAAA,KACrBR,UAAU,CAACC,kBAAkB,CAAC;AAEhC,eAAeO,cAAc"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
2
|
-
import useThrottle from '@os-design/use-throttle';
|
|
3
1
|
import useEvent from '@os-design/use-event';
|
|
2
|
+
import useThrottle from '@os-design/use-throttle';
|
|
3
|
+
import { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
4
4
|
import getElementScroll from './getElementScroll';
|
|
5
|
-
import
|
|
5
|
+
import getNodeRect from './getNodeRect';
|
|
6
|
+
import useBlankNode from './useBlankNode';
|
|
7
|
+
import useGetNodeStyle from './useGetNodeStyle';
|
|
6
8
|
import useInitRect from './useInitRect';
|
|
7
9
|
import useInitScrollOffset from './useInitScrollOffset';
|
|
8
|
-
import useGetNodeStyle from './useGetNodeStyle';
|
|
9
10
|
import useMoveNode from './useMoveNode';
|
|
10
|
-
import
|
|
11
|
-
import useBlankNode from './useBlankNode';
|
|
11
|
+
import useTargetList from './useTargetList';
|
|
12
12
|
const HIDDEN_NODE_STYLE = {
|
|
13
13
|
opacity: 0,
|
|
14
14
|
pointerEvents: 'none'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDragEffect.js","names":["useCallback","useEffect","useMemo","useRef","useThrottle","useEvent","getElementScroll","useTargetList","useInitRect","useInitScrollOffset","useGetNodeStyle","useMoveNode","getNodeRect","useBlankNode","HIDDEN_NODE_STYLE","opacity","pointerEvents","createEmptyNode","prev","next","current","useDragEffect","props","draggedNode","cursorPosition","listStoreRef","onDragEnd","targetRef","targetNodeRef","onDragEndRef","initDraggedNodeRect","node","undefined","initDraggedNodeListScrollOffset","list","ref","position","x","y","initWidth","initHeight","targetList","getNodeStyle","moveNode","setTargetNode","nodeIndex","nodeId","listId","id","index","clearTargetNode","getDraggedNodePos","initX","initY","initScrollLeft","initScrollTop","scrollLeft","scrollTop","getDraggedNodePosRef","draggedNodeSetStyle","removeBlankNode","updateTargetNode","prevTargetNode","startNode","direction","destination","isAnotherList","tail","getTail","axis","horizontal","prevTargetNodeRef","draggedNodePos","isDraggingUp","head","getHead","prevTargetNodeRect","startRectProp","isMoveUp","throttledUpdateTargetNode","window","draggedNodeIndex","targetNode","nodeSetStyle","targetNodeIndex","targetNodeSetStyle","update","nodeProps","setStyle","addListener","removeListener","target","draggedNodeId","dragged"],"sources":["../../../src/utils/useDragEffect.ts"],"sourcesContent":["import { Position } from '@os-design/use-drag';\nimport {\n CSSProperties,\n RefObject,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n} from 'react';\nimport useThrottle from '@os-design/use-throttle';\nimport useEvent from '@os-design/use-event';\nimport NodeList, { ExistingNode, Node, NodeProps } from './NodeList';\nimport ListStore from './ListStore';\nimport getElementScroll from './getElementScroll';\nimport useTargetList from './useTargetList';\nimport useInitRect from './useInitRect';\nimport useInitScrollOffset from './useInitScrollOffset';\nimport useGetNodeStyle from './useGetNodeStyle';\nimport useMoveNode from './useMoveNode';\nimport getNodeRect from './getNodeRect';\nimport useBlankNode from './useBlankNode';\n\nexport interface DraggedNode {\n list: NodeList;\n node: ExistingNode;\n position: Position;\n}\n\ninterface TargetNode {\n list: NodeList;\n node: ExistingNode;\n}\n\nexport interface ItemLocation {\n listId: string;\n index: number;\n id: string;\n}\n\nexport type DragEndHandler = (\n dragged: ItemLocation,\n target: ItemLocation\n) => void;\n\ninterface UseDragEffectProps {\n draggedNode: DraggedNode | null;\n cursorPosition: Position;\n listStoreRef: RefObject<ListStore>;\n onDragEnd: DragEndHandler;\n}\n\nconst HIDDEN_NODE_STYLE: CSSProperties = {\n opacity: 0,\n pointerEvents: 'none',\n};\n\nconst createEmptyNode = ({\n prev = null,\n next = null,\n}: {\n prev?: Node;\n next?: Node;\n}): ExistingNode => [prev, next, { current: null }, () => {}, -1, 'id'];\n\n/* eslint-disable no-constant-condition */\n\nconst useDragEffect = (props: UseDragEffectProps) => {\n const { draggedNode, cursorPosition, listStoreRef, onDragEnd } = props;\n\n const targetRef = useRef<ItemLocation | null>(null);\n const targetNodeRef = useRef<TargetNode | null>(draggedNode);\n\n useEffect(() => {\n targetNodeRef.current = draggedNode;\n }, [draggedNode]);\n\n const onDragEndRef = useRef(onDragEnd);\n useEffect(() => {\n onDragEndRef.current = onDragEnd;\n }, [onDragEnd]);\n\n // The initial bounds of the dragged node.\n // We can't read the bounds of the dragged node on the fly because the node can be unmounted in the virtual list.\n const initDraggedNodeRect = useInitRect(\n draggedNode ? draggedNode.node[2] : undefined\n );\n\n // The initial scroll position of the list where the dragged node is located.\n // Used to detect the actual position of the dragged node. The purpose is the same as with initDraggedNodeRect.\n const initDraggedNodeListScrollOffset = useInitScrollOffset(\n draggedNode ? draggedNode.list.ref : undefined\n );\n\n // The central position of the dragged node\n const position = useMemo(() => {\n if (!draggedNode || !initDraggedNodeRect) return null;\n const { x, y } = cursorPosition;\n const { initWidth, initHeight } = initDraggedNodeRect;\n return {\n x: x - draggedNode.position.x + initWidth / 2,\n y: y - draggedNode.position.y + initHeight / 2,\n };\n }, [cursorPosition, draggedNode, initDraggedNodeRect]);\n\n // The list in which the cursor is located\n const targetList = useTargetList(position, listStoreRef);\n\n // Returns the style for moving the node in the specified direction\n const getNodeStyle = useGetNodeStyle(initDraggedNodeRect);\n\n // Moves the node up or down\n const moveNode = useMoveNode({ position, draggedNode, getNodeStyle });\n\n const setTargetNode = useCallback((list: NodeList, node: ExistingNode) => {\n const [, , , , nodeIndex, nodeId] = node;\n targetNodeRef.current = { list, node };\n targetRef.current = {\n listId: list.id,\n index: nodeIndex,\n id: nodeId,\n };\n }, []);\n\n const clearTargetNode = useCallback(() => {\n targetNodeRef.current = null;\n targetRef.current = null;\n }, []);\n\n // Returns the central position of the dragged node in the list\n const getDraggedNodePos = useCallback(() => {\n if (\n !targetList ||\n !targetList.ref.current ||\n !initDraggedNodeRect ||\n !initDraggedNodeListScrollOffset\n ) {\n return null;\n }\n const { initX, initY, initWidth, initHeight } = initDraggedNodeRect;\n const { initScrollLeft, initScrollTop } = initDraggedNodeListScrollOffset;\n const { scrollLeft, scrollTop } = getElementScroll(targetList.ref.current);\n return {\n x: initX + initWidth / 2 + initScrollLeft - scrollLeft,\n y: initY + initHeight / 2 + initScrollTop - scrollTop,\n };\n }, [initDraggedNodeListScrollOffset, initDraggedNodeRect, targetList]);\n\n const getDraggedNodePosRef = useRef(getDraggedNodePos);\n useEffect(() => {\n getDraggedNodePosRef.current = getDraggedNodePos;\n }, [getDraggedNodePos]);\n\n // Hide the dragged node\n useEffect(() => {\n if (!draggedNode) return () => {};\n const [, , , draggedNodeSetStyle] = draggedNode.node;\n draggedNodeSetStyle(HIDDEN_NODE_STYLE);\n return () => draggedNodeSetStyle({});\n }, [draggedNode]);\n\n // Append the blank node to the list to increase the height of it.\n // Used when the dragged node is located inside another list.\n const removeBlankNode = useBlankNode({\n draggedNode,\n targetList,\n initDraggedNodeRect,\n });\n\n const updateTargetNode = useCallback(() => {\n if (!draggedNode) return;\n const prevTargetNode = targetNodeRef.current; // The last updated node\n\n // Dragging outside the origin list\n if (\n prevTargetNode &&\n prevTargetNode.list === draggedNode.list &&\n targetList !== draggedNode.list\n ) {\n moveNode({\n list: prevTargetNode.list,\n startNode: prevTargetNode.node,\n direction: 'down',\n destination: 'end',\n });\n clearTargetNode();\n }\n\n // Dragging outside another list\n if (\n prevTargetNode &&\n prevTargetNode.list !== draggedNode.list &&\n targetList !== prevTargetNode.list\n ) {\n moveNode({\n list: prevTargetNode.list,\n startNode: prevTargetNode.node,\n direction: 'down',\n destination: 'end',\n isAnotherList: true,\n });\n removeBlankNode();\n clearTargetNode();\n }\n\n // Dragging inside the origin list\n if (!prevTargetNode && targetList === draggedNode.list) {\n const tail = targetList.getTail();\n if (!tail) return;\n const node = moveNode({\n list: targetList,\n startNode: tail,\n direction: 'up',\n destination: 'cursor',\n });\n setTargetNode(targetList, node);\n return;\n }\n\n // Dragging inside another list\n if (\n targetList &&\n targetList !== draggedNode.list &&\n (!prevTargetNode || prevTargetNode.list !== targetList)\n ) {\n const tail = targetList.getTail();\n if (!tail) return;\n const node = moveNode({\n list: targetList,\n startNode: tail,\n direction: 'up',\n destination: 'cursor',\n isAnotherList: true,\n });\n setTargetNode(targetList, node);\n return;\n }\n\n // Dragging in the origin list\n if (\n prevTargetNode &&\n prevTargetNode.list === draggedNode.list &&\n targetList === draggedNode.list\n ) {\n const axis = targetList.horizontal ? 'x' : 'y';\n const [, , prevTargetNodeRef, ,] = prevTargetNode.node;\n if (!prevTargetNodeRef.current) {\n // The target node was unmounted. It happens when the virtual list is used.\n // If the cursor is above the dragged node, we need to move the nodes down from the tail to the node where\n // the cursor is located. Otherwise, we need to move the nodes up from the head to the node where the cursor\n // is located.\n const draggedNodePos = getDraggedNodePosRef.current();\n if (!position || !draggedNodePos) return;\n const isDraggingUp = position[axis] < draggedNodePos[axis];\n if (isDraggingUp) {\n const tail = targetList.getTail();\n if (!tail || !tail[2].current) return;\n const node = moveNode({\n list: targetList,\n startNode: createEmptyNode({ prev: tail }),\n direction: 'up',\n destination: 'cursor',\n });\n setTargetNode(targetList, node);\n } else {\n const head = targetList.getHead();\n if (!head || !head[2].current) return;\n const node = moveNode({\n list: targetList,\n startNode: createEmptyNode({ next: head }),\n direction: 'down',\n destination: 'cursor',\n });\n setTargetNode(targetList, node);\n }\n return;\n }\n const prevTargetNodeRect = getNodeRect(prevTargetNode.node[2]);\n const startRectProp = targetList.horizontal ? 'left' : 'top';\n if (!position || !prevTargetNodeRect) return;\n const isMoveUp = position[axis] < prevTargetNodeRect[startRectProp];\n const node = isMoveUp\n ? moveNode({\n list: targetList,\n startNode: prevTargetNode.node,\n direction: 'up',\n destination: 'cursor',\n })\n : moveNode({\n list: targetList,\n startNode: prevTargetNode.node,\n direction: 'down',\n destination: 'cursor',\n });\n setTargetNode(targetList, node);\n return;\n }\n\n // Dragging in another list\n if (\n targetList &&\n targetList !== draggedNode.list &&\n prevTargetNode &&\n prevTargetNode.list === targetList\n ) {\n const axis = targetList.horizontal ? 'x' : 'y';\n const prevTargetNodeRect = getNodeRect(prevTargetNode.node[2]);\n const startRectProp = targetList.horizontal ? 'left' : 'top';\n if (!position || !prevTargetNodeRect) return;\n const isMoveUp = position[axis] < prevTargetNodeRect[startRectProp];\n const node = isMoveUp\n ? moveNode({\n list: targetList,\n startNode: prevTargetNode.node,\n direction: 'up',\n destination: 'cursor',\n isAnotherList: true,\n })\n : moveNode({\n list: targetList,\n startNode: prevTargetNode.node,\n direction: 'down',\n destination: 'cursor',\n isAnotherList: true,\n });\n setTargetNode(targetList, node);\n }\n }, [\n draggedNode,\n targetList,\n moveNode,\n clearTargetNode,\n removeBlankNode,\n setTargetNode,\n position,\n ]);\n\n // Update the target node if either the position or the target list has been changed\n useEffect(() => {\n updateTargetNode();\n }, [updateTargetNode]);\n\n // Update the target node if the target list has been scrolled\n const [throttledUpdateTargetNode] = useThrottle(updateTargetNode, 100);\n useEvent(\n (targetList ? targetList.ref : undefined) as unknown as EventTarget,\n 'scroll',\n throttledUpdateTargetNode\n );\n useEvent(window, 'scroll', throttledUpdateTargetNode);\n\n // Reset styles of the affected nodes when the dragged node was dropped\n useEffect(() => {\n if (!draggedNode) return () => {};\n const [, , , , draggedNodeIndex] = draggedNode.node;\n return () => {\n const targetNode = targetNodeRef.current;\n\n // If the dragged node was outside the origin list, reset the styles for the nodes,\n // starting at the tail and ending with the dragged node in the origin list.\n if (!targetNode || targetNode.list !== draggedNode.list) {\n const tail = draggedNode.list.getTail();\n if (tail) {\n let node = tail;\n while (true) {\n const [prev, , , nodeSetStyle, nodeIndex] = node;\n nodeSetStyle({});\n if (!prev || nodeIndex <= draggedNodeIndex) break;\n node = prev;\n }\n }\n }\n\n // If the dragged node was inside another list, reset the styles for the nodes,\n // starting at the tail and ending with the dragged node in the target list.\n if (targetNode && targetNode.list !== draggedNode.list) {\n const tail = targetNode.list.getTail();\n const [, , , , targetNodeIndex] = targetNode.node;\n if (tail) {\n let node = tail;\n while (true) {\n const [prev, , , nodeSetStyle, nodeIndex] = node;\n nodeSetStyle({});\n if (!prev || nodeIndex <= targetNodeIndex) break;\n node = prev;\n }\n }\n }\n\n // If the dragged node was moved inside the origin list, reset the styles for the nodes,\n // starting with target node and ending with the dragged node.\n if (targetNode && targetNode.list === draggedNode.list) {\n const [, , , targetNodeSetStyle, targetNodeIndex] = targetNode.node;\n if (targetNodeIndex > draggedNodeIndex) {\n let { node } = targetNode;\n while (true) {\n const [prev, , , nodeSetStyle, nodeIndex] = node;\n nodeSetStyle({});\n if (!prev || nodeIndex <= draggedNodeIndex) break;\n node = prev;\n }\n } else if (targetNodeIndex < draggedNodeIndex) {\n let { node } = targetNode;\n while (true) {\n const [, next, , nodeSetStyle, nodeIndex] = node;\n nodeSetStyle({});\n if (!next || nodeIndex >= draggedNodeIndex) break;\n node = next;\n }\n } else if (targetNodeIndex === draggedNodeIndex) {\n targetNodeSetStyle({});\n }\n }\n };\n }, [draggedNode]);\n\n // Update the position of the newly mounted nodes in the origin list (used in the virtual list)\n useEffect(() => {\n if (!draggedNode) return () => {};\n const [, , , , draggedNodeIndex] = draggedNode.node;\n\n const update = (nodeProps: NodeProps) => {\n const { setStyle, index } = nodeProps;\n const targetNode = targetNodeRef.current;\n\n // Set the hidden style, if the mounted node is the dragged node\n if (index === draggedNodeIndex) {\n setStyle(HIDDEN_NODE_STYLE);\n return;\n }\n\n // If the dragged node is inside the origin list\n if (targetNode && targetNode.list === draggedNode.list) {\n // Move the mounted node up/down, if it is located between the dragged and target node\n const [, , , , targetNodeIndex] = targetNode.node;\n if (index > draggedNodeIndex && index < targetNodeIndex) {\n setStyle(getNodeStyle('up', targetNode.list.horizontal));\n } else if (index < draggedNodeIndex && index > targetNodeIndex) {\n setStyle(getNodeStyle('down', targetNode.list.horizontal));\n }\n } else if (index > draggedNodeIndex) {\n // Otherwise, move the mounted node up, if it is located below the dragged node\n setStyle(getNodeStyle('up', draggedNode.list.horizontal));\n }\n };\n\n draggedNode.list.addListener(update);\n return () => draggedNode.list.removeListener(update);\n }, [draggedNode, getNodeStyle]);\n\n // Update the position of the newly mounted nodes in the target list (used in the virtual list)\n useEffect(() => {\n if (!draggedNode || !targetList || targetList === draggedNode.list) {\n return () => {};\n }\n\n const update = (nodeProps: NodeProps) => {\n const { setStyle, index } = nodeProps;\n const targetNode = targetNodeRef.current;\n if (!targetNode) return;\n const [, , , , targetNodeIndex] = targetNode.node;\n if (index >= targetNodeIndex) {\n // Move the mounted node down, if it is located below the target node or if it is the target node\n setStyle(getNodeStyle('down', targetList.horizontal));\n }\n };\n\n targetList.addListener(update);\n return () => targetList.removeListener(update);\n }, [draggedNode, getNodeStyle, targetList]);\n\n // Call the onDragEnd callback if the draggedNode was changed to null\n useEffect(() => {\n if (!draggedNode) return () => {};\n return () => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const target = targetRef.current;\n if (!target) return;\n const [, , , , draggedNodeIndex, draggedNodeId] = draggedNode.node;\n const dragged = {\n listId: draggedNode.list.id,\n index: draggedNodeIndex,\n id: draggedNodeId,\n };\n if (dragged.id === target.id && dragged.index === target.index) return;\n onDragEndRef.current(dragged, target);\n };\n }, [draggedNode]);\n};\n\nexport default useDragEffect;\n"],"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K,EAAEgC,gBAAgB;QACvBjC,EAAE,EAAE4C;MACN,CAAC;MACD,IAAIC,OAAO,CAAC7C,EAAE,KAAK2C,MAAM,CAAC3C,EAAE,IAAI6C,OAAO,CAAC5C,KAAK,KAAK0C,MAAM,CAAC1C,KAAK,EAAE;MAChEpB,YAAY,CAACT,OAAO,CAACyE,OAAO,EAAEF,MAAM,CAAC;IACvC,CAAC;EACH,CAAC,EAAE,CAACpE,WAAW,CAAC,CAAC;AACnB,CAAC;AAED,eAAeF,aAAa"}
|
|
1
|
+
{"version":3,"file":"useDragEffect.js","names":["useEvent","useThrottle","useCallback","useEffect","useMemo","useRef","getElementScroll","getNodeRect","useBlankNode","useGetNodeStyle","useInitRect","useInitScrollOffset","useMoveNode","useTargetList","HIDDEN_NODE_STYLE","opacity","pointerEvents","createEmptyNode","prev","next","current","useDragEffect","props","draggedNode","cursorPosition","listStoreRef","onDragEnd","targetRef","targetNodeRef","onDragEndRef","initDraggedNodeRect","node","undefined","initDraggedNodeListScrollOffset","list","ref","position","x","y","initWidth","initHeight","targetList","getNodeStyle","moveNode","setTargetNode","nodeIndex","nodeId","listId","id","index","clearTargetNode","getDraggedNodePos","initX","initY","initScrollLeft","initScrollTop","scrollLeft","scrollTop","getDraggedNodePosRef","draggedNodeSetStyle","removeBlankNode","updateTargetNode","prevTargetNode","startNode","direction","destination","isAnotherList","tail","getTail","axis","horizontal","prevTargetNodeRef","draggedNodePos","isDraggingUp","head","getHead","prevTargetNodeRect","startRectProp","isMoveUp","throttledUpdateTargetNode","window","draggedNodeIndex","targetNode","nodeSetStyle","targetNodeIndex","targetNodeSetStyle","update","nodeProps","setStyle","addListener","removeListener","target","draggedNodeId","dragged"],"sources":["../../../src/utils/useDragEffect.ts"],"sourcesContent":["import { Position } from '@os-design/use-drag';\nimport useEvent from '@os-design/use-event';\nimport useThrottle from '@os-design/use-throttle';\nimport {\n CSSProperties,\n RefObject,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n} from 'react';\nimport ListStore from './ListStore';\nimport NodeList, { ExistingNode, Node, NodeProps } from './NodeList';\nimport getElementScroll from './getElementScroll';\nimport getNodeRect from './getNodeRect';\nimport useBlankNode from './useBlankNode';\nimport useGetNodeStyle from './useGetNodeStyle';\nimport useInitRect from './useInitRect';\nimport useInitScrollOffset from './useInitScrollOffset';\nimport useMoveNode from './useMoveNode';\nimport useTargetList from './useTargetList';\n\nexport interface DraggedNode {\n list: NodeList;\n node: ExistingNode;\n position: Position;\n}\n\ninterface TargetNode {\n list: NodeList;\n node: ExistingNode;\n}\n\nexport interface ItemLocation {\n listId: string;\n index: number;\n id: string;\n}\n\nexport type DragEndHandler = (\n dragged: ItemLocation,\n target: ItemLocation\n) => void;\n\ninterface UseDragEffectProps {\n draggedNode: DraggedNode | null;\n cursorPosition: Position;\n listStoreRef: RefObject<ListStore>;\n onDragEnd: DragEndHandler;\n}\n\nconst HIDDEN_NODE_STYLE: CSSProperties = {\n opacity: 0,\n pointerEvents: 'none',\n};\n\nconst createEmptyNode = ({\n prev = null,\n next = null,\n}: {\n prev?: Node;\n next?: Node;\n}): ExistingNode => [prev, next, { current: null }, () => {}, -1, 'id'];\n\n/* eslint-disable no-constant-condition */\n\nconst useDragEffect = (props: UseDragEffectProps) => {\n const { draggedNode, cursorPosition, listStoreRef, onDragEnd } = props;\n\n const targetRef = useRef<ItemLocation | null>(null);\n const targetNodeRef = useRef<TargetNode | null>(draggedNode);\n\n useEffect(() => {\n targetNodeRef.current = draggedNode;\n }, [draggedNode]);\n\n const onDragEndRef = useRef(onDragEnd);\n useEffect(() => {\n onDragEndRef.current = onDragEnd;\n }, [onDragEnd]);\n\n // The initial bounds of the dragged node.\n // We can't read the bounds of the dragged node on the fly because the node can be unmounted in the virtual list.\n const initDraggedNodeRect = useInitRect(\n draggedNode ? draggedNode.node[2] : undefined\n );\n\n // The initial scroll position of the list where the dragged node is located.\n // Used to detect the actual position of the dragged node. The purpose is the same as with initDraggedNodeRect.\n const initDraggedNodeListScrollOffset = useInitScrollOffset(\n draggedNode ? draggedNode.list.ref : undefined\n );\n\n // The central position of the dragged node\n const position = useMemo(() => {\n if (!draggedNode || !initDraggedNodeRect) return null;\n const { x, y } = cursorPosition;\n const { initWidth, initHeight } = initDraggedNodeRect;\n return {\n x: x - draggedNode.position.x + initWidth / 2,\n y: y - draggedNode.position.y + initHeight / 2,\n };\n }, [cursorPosition, draggedNode, initDraggedNodeRect]);\n\n // The list in which the cursor is located\n const targetList = useTargetList(position, listStoreRef);\n\n // Returns the style for moving the node in the specified direction\n const getNodeStyle = useGetNodeStyle(initDraggedNodeRect);\n\n // Moves the node up or down\n const moveNode = useMoveNode({ position, draggedNode, getNodeStyle });\n\n const setTargetNode = useCallback((list: NodeList, node: ExistingNode) => {\n const [, , , , nodeIndex, nodeId] = node;\n targetNodeRef.current = { list, node };\n targetRef.current = {\n listId: list.id,\n index: nodeIndex,\n id: nodeId,\n };\n }, []);\n\n const clearTargetNode = useCallback(() => {\n targetNodeRef.current = null;\n targetRef.current = null;\n }, []);\n\n // Returns the central position of the dragged node in the list\n const getDraggedNodePos = useCallback(() => {\n if (\n !targetList ||\n !targetList.ref.current ||\n !initDraggedNodeRect ||\n !initDraggedNodeListScrollOffset\n ) {\n return null;\n }\n const { initX, initY, initWidth, initHeight } = initDraggedNodeRect;\n const { initScrollLeft, initScrollTop } = initDraggedNodeListScrollOffset;\n const { scrollLeft, scrollTop } = getElementScroll(targetList.ref.current);\n return {\n x: initX + initWidth / 2 + initScrollLeft - scrollLeft,\n y: initY + initHeight / 2 + initScrollTop - scrollTop,\n };\n }, [initDraggedNodeListScrollOffset, initDraggedNodeRect, targetList]);\n\n const getDraggedNodePosRef = useRef(getDraggedNodePos);\n useEffect(() => {\n getDraggedNodePosRef.current = getDraggedNodePos;\n }, [getDraggedNodePos]);\n\n // Hide the dragged node\n useEffect(() => {\n if (!draggedNode) return () => {};\n const [, , , draggedNodeSetStyle] = draggedNode.node;\n draggedNodeSetStyle(HIDDEN_NODE_STYLE);\n return () => draggedNodeSetStyle({});\n }, [draggedNode]);\n\n // Append the blank node to the list to increase the height of it.\n // Used when the dragged node is located inside another list.\n const removeBlankNode = useBlankNode({\n draggedNode,\n targetList,\n initDraggedNodeRect,\n });\n\n const updateTargetNode = useCallback(() => {\n if (!draggedNode) return;\n const prevTargetNode = targetNodeRef.current; // The last updated node\n\n // Dragging outside the origin list\n if (\n prevTargetNode &&\n prevTargetNode.list === draggedNode.list &&\n targetList !== draggedNode.list\n ) {\n moveNode({\n list: prevTargetNode.list,\n startNode: prevTargetNode.node,\n direction: 'down',\n destination: 'end',\n });\n clearTargetNode();\n }\n\n // Dragging outside another list\n if (\n prevTargetNode &&\n prevTargetNode.list !== draggedNode.list &&\n targetList !== prevTargetNode.list\n ) {\n moveNode({\n list: prevTargetNode.list,\n startNode: prevTargetNode.node,\n direction: 'down',\n destination: 'end',\n isAnotherList: true,\n });\n removeBlankNode();\n clearTargetNode();\n }\n\n // Dragging inside the origin list\n if (!prevTargetNode && targetList === draggedNode.list) {\n const tail = targetList.getTail();\n if (!tail) return;\n const node = moveNode({\n list: targetList,\n startNode: tail,\n direction: 'up',\n destination: 'cursor',\n });\n setTargetNode(targetList, node);\n return;\n }\n\n // Dragging inside another list\n if (\n targetList &&\n targetList !== draggedNode.list &&\n (!prevTargetNode || prevTargetNode.list !== targetList)\n ) {\n const tail = targetList.getTail();\n if (!tail) return;\n const node = moveNode({\n list: targetList,\n startNode: tail,\n direction: 'up',\n destination: 'cursor',\n isAnotherList: true,\n });\n setTargetNode(targetList, node);\n return;\n }\n\n // Dragging in the origin list\n if (\n prevTargetNode &&\n prevTargetNode.list === draggedNode.list &&\n targetList === draggedNode.list\n ) {\n const axis = targetList.horizontal ? 'x' : 'y';\n const [, , prevTargetNodeRef, ,] = prevTargetNode.node;\n if (!prevTargetNodeRef.current) {\n // The target node was unmounted. It happens when the virtual list is used.\n // If the cursor is above the dragged node, we need to move the nodes down from the tail to the node where\n // the cursor is located. Otherwise, we need to move the nodes up from the head to the node where the cursor\n // is located.\n const draggedNodePos = getDraggedNodePosRef.current();\n if (!position || !draggedNodePos) return;\n const isDraggingUp = position[axis] < draggedNodePos[axis];\n if (isDraggingUp) {\n const tail = targetList.getTail();\n if (!tail || !tail[2].current) return;\n const node = moveNode({\n list: targetList,\n startNode: createEmptyNode({ prev: tail }),\n direction: 'up',\n destination: 'cursor',\n });\n setTargetNode(targetList, node);\n } else {\n const head = targetList.getHead();\n if (!head || !head[2].current) return;\n const node = moveNode({\n list: targetList,\n startNode: createEmptyNode({ next: head }),\n direction: 'down',\n destination: 'cursor',\n });\n setTargetNode(targetList, node);\n }\n return;\n }\n const prevTargetNodeRect = getNodeRect(prevTargetNode.node[2]);\n const startRectProp = targetList.horizontal ? 'left' : 'top';\n if (!position || !prevTargetNodeRect) return;\n const isMoveUp = position[axis] < prevTargetNodeRect[startRectProp];\n const node = isMoveUp\n ? moveNode({\n list: targetList,\n startNode: prevTargetNode.node,\n direction: 'up',\n destination: 'cursor',\n })\n : moveNode({\n list: targetList,\n startNode: prevTargetNode.node,\n direction: 'down',\n destination: 'cursor',\n });\n setTargetNode(targetList, node);\n return;\n }\n\n // Dragging in another list\n if (\n targetList &&\n targetList !== draggedNode.list &&\n prevTargetNode &&\n prevTargetNode.list === targetList\n ) {\n const axis = targetList.horizontal ? 'x' : 'y';\n const prevTargetNodeRect = getNodeRect(prevTargetNode.node[2]);\n const startRectProp = targetList.horizontal ? 'left' : 'top';\n if (!position || !prevTargetNodeRect) return;\n const isMoveUp = position[axis] < prevTargetNodeRect[startRectProp];\n const node = isMoveUp\n ? moveNode({\n list: targetList,\n startNode: prevTargetNode.node,\n direction: 'up',\n destination: 'cursor',\n isAnotherList: true,\n })\n : moveNode({\n list: targetList,\n startNode: prevTargetNode.node,\n direction: 'down',\n destination: 'cursor',\n isAnotherList: true,\n });\n setTargetNode(targetList, node);\n }\n }, [\n draggedNode,\n targetList,\n moveNode,\n clearTargetNode,\n removeBlankNode,\n setTargetNode,\n position,\n ]);\n\n // Update the target node if either the position or the target list has been changed\n useEffect(() => {\n updateTargetNode();\n }, [updateTargetNode]);\n\n // Update the target node if the target list has been scrolled\n const [throttledUpdateTargetNode] = useThrottle(updateTargetNode, 100);\n useEvent(\n (targetList ? targetList.ref : undefined) as unknown as EventTarget,\n 'scroll',\n throttledUpdateTargetNode\n );\n useEvent(window, 'scroll', throttledUpdateTargetNode);\n\n // Reset styles of the affected nodes when the dragged node was dropped\n useEffect(() => {\n if (!draggedNode) return () => {};\n const [, , , , draggedNodeIndex] = draggedNode.node;\n return () => {\n const targetNode = targetNodeRef.current;\n\n // If the dragged node was outside the origin list, reset the styles for the nodes,\n // starting at the tail and ending with the dragged node in the origin list.\n if (!targetNode || targetNode.list !== draggedNode.list) {\n const tail = draggedNode.list.getTail();\n if (tail) {\n let node = tail;\n while (true) {\n const [prev, , , nodeSetStyle, nodeIndex] = node;\n nodeSetStyle({});\n if (!prev || nodeIndex <= draggedNodeIndex) break;\n node = prev;\n }\n }\n }\n\n // If the dragged node was inside another list, reset the styles for the nodes,\n // starting at the tail and ending with the dragged node in the target list.\n if (targetNode && targetNode.list !== draggedNode.list) {\n const tail = targetNode.list.getTail();\n const [, , , , targetNodeIndex] = targetNode.node;\n if (tail) {\n let node = tail;\n while (true) {\n const [prev, , , nodeSetStyle, nodeIndex] = node;\n nodeSetStyle({});\n if (!prev || nodeIndex <= targetNodeIndex) break;\n node = prev;\n }\n }\n }\n\n // If the dragged node was moved inside the origin list, reset the styles for the nodes,\n // starting with target node and ending with the dragged node.\n if (targetNode && targetNode.list === draggedNode.list) {\n const [, , , targetNodeSetStyle, targetNodeIndex] = targetNode.node;\n if (targetNodeIndex > draggedNodeIndex) {\n let { node } = targetNode;\n while (true) {\n const [prev, , , nodeSetStyle, nodeIndex] = node;\n nodeSetStyle({});\n if (!prev || nodeIndex <= draggedNodeIndex) break;\n node = prev;\n }\n } else if (targetNodeIndex < draggedNodeIndex) {\n let { node } = targetNode;\n while (true) {\n const [, next, , nodeSetStyle, nodeIndex] = node;\n nodeSetStyle({});\n if (!next || nodeIndex >= draggedNodeIndex) break;\n node = next;\n }\n } else if (targetNodeIndex === draggedNodeIndex) {\n targetNodeSetStyle({});\n }\n }\n };\n }, [draggedNode]);\n\n // Update the position of the newly mounted nodes in the origin list (used in the virtual list)\n useEffect(() => {\n if (!draggedNode) return () => {};\n const [, , , , draggedNodeIndex] = draggedNode.node;\n\n const update = (nodeProps: NodeProps) => {\n const { setStyle, index } = nodeProps;\n const targetNode = targetNodeRef.current;\n\n // Set the hidden style, if the mounted node is the dragged node\n if (index === draggedNodeIndex) {\n setStyle(HIDDEN_NODE_STYLE);\n return;\n }\n\n // If the dragged node is inside the origin list\n if (targetNode && targetNode.list === draggedNode.list) {\n // Move the mounted node up/down, if it is located between the dragged and target node\n const [, , , , targetNodeIndex] = targetNode.node;\n if (index > draggedNodeIndex && index < targetNodeIndex) {\n setStyle(getNodeStyle('up', targetNode.list.horizontal));\n } else if (index < draggedNodeIndex && index > targetNodeIndex) {\n setStyle(getNodeStyle('down', targetNode.list.horizontal));\n }\n } else if (index > draggedNodeIndex) {\n // Otherwise, move the mounted node up, if it is located below the dragged node\n setStyle(getNodeStyle('up', draggedNode.list.horizontal));\n }\n };\n\n draggedNode.list.addListener(update);\n return () => draggedNode.list.removeListener(update);\n }, [draggedNode, getNodeStyle]);\n\n // Update the position of the newly mounted nodes in the target list (used in the virtual list)\n useEffect(() => {\n if (!draggedNode || !targetList || targetList === draggedNode.list) {\n return () => {};\n }\n\n const update = (nodeProps: NodeProps) => {\n const { setStyle, index } = nodeProps;\n const targetNode = targetNodeRef.current;\n if (!targetNode) return;\n const [, , , , targetNodeIndex] = targetNode.node;\n if (index >= targetNodeIndex) {\n // Move the mounted node down, if it is located below the target node or if it is the target node\n setStyle(getNodeStyle('down', targetList.horizontal));\n }\n };\n\n targetList.addListener(update);\n return () => targetList.removeListener(update);\n }, [draggedNode, getNodeStyle, targetList]);\n\n // Call the onDragEnd callback if the draggedNode was changed to null\n useEffect(() => {\n if (!draggedNode) return () => {};\n return () => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const target = targetRef.current;\n if (!target) return;\n const [, , , , draggedNodeIndex, draggedNodeId] = draggedNode.node;\n const dragged = {\n listId: draggedNode.list.id,\n index: draggedNodeIndex,\n id: draggedNodeId,\n };\n if (dragged.id === target.id && dragged.index === target.index) return;\n onDragEndRef.current(dragged, target);\n };\n }, [draggedNode]);\n};\n\nexport default useDragEffect;\n"],"mappings":"AACA,OAAOA,QAAQ,MAAM,sBAAsB;AAC3C,OAAOC,WAAW,MAAM,yBAAyB;AACjD,SAGEC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,MAAM,QACD,OAAO;AAGd,OAAOC,gBAAgB,MAAM,oBAAoB;AACjD,OAAOC,WAAW,MAAM,eAAe;AACvC,OAAOC,YAAY,MAAM,gBAAgB;AACzC,OAAOC,eAAe,MAAM,mBAAmB;AAC/C,OAAOC,WAAW,MAAM,eAAe;AACvC,OAAOC,mBAAmB,MAAM,uBAAuB;AACvD,OAAOC,WAAW,MAAM,eAAe;AACvC,OAAOC,aAAa,MAAM,iBAAiB;AA+B3C,MAAMC,iBAAgC,GAAG;EACvCC,OAAO,EAAE,CAAC;EACVC,aAAa,EAAE;AACjB,CAAC;AAED,MAAMC,eAAe,GAAGA,CAAC;EACvBC,IAAI,GAAG,IAAI;EACXC,IAAI,GAAG;AAIT,CAAC,KAAmB,CAACD,IAAI,EAAEC,IAAI,EAAE;EAAEC,OAAO,EAAE;AAAK,CAAC,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC;;AAEvE;;AAEA,MAAMC,aAAa,GAAIC,KAAyB,IAAK;EACnD,MAAM;IAAEC,WAAW;IAAEC,cAAc;IAAEC,YAAY;IAAEC;EAAU,CAAC,GAAGJ,KAAK;EAEtE,MAAMK,SAAS,GAAGtB,MAAM,CAAsB,IAAI,CAAC;EACnD,MAAMuB,aAAa,GAAGv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AAU,CAAC,CAAC;;EAE3C;EACAtC,SAAS,CAAC,MAAM;IACd,IAAI,CAACoB,WAAW,EAAE,OAAO,MAAM,CAAC,CAAC;IACjC,OAAO,MAAM;MACX;MACA,MAAMoE,MAAM,GAAGhE,SAAS,CAACP,OAAO;MAChC,IAAI,CAACuE,MAAM,EAAE;MACb,MAAM,MAASV,gBAAgB,EAAEW,aAAa,CAAC,GAAGrE,WAAW,CAACQ,IAAI;MAClE,MAAM8D,OAAO,GAAG;QACd9C,MAAM,EAAExB,WAAW,CAACW,IAAI,CAACc,EAAE;QAC3BC,KAAK,EAAEgC,gBAAgB;QACvBjC,EAAE,EAAE4C;MACN,CAAC;MACD,IAAIC,OAAO,CAAC7C,EAAE,KAAK2C,MAAM,CAAC3C,EAAE,IAAI6C,OAAO,CAAC5C,KAAK,KAAK0C,MAAM,CAAC1C,KAAK,EAAE;MAChEpB,YAAY,CAACT,OAAO,CAACyE,OAAO,EAAEF,MAAM,CAAC;IACvC,CAAC;EACH,CAAC,EAAE,CAACpE,WAAW,CAAC,CAAC;AACnB,CAAC;AAED,eAAeF,aAAa"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDroppable.js","names":["React","useContext","DroppableContext","createContext","registerNode","current","deregisterNode","onMouseDown","onTouchStart","useDroppable"],"sources":["../../../src/utils/useDroppable.ts"],"sourcesContent":["import React, {
|
|
1
|
+
{"version":3,"file":"useDroppable.js","names":["React","useContext","DroppableContext","createContext","registerNode","current","deregisterNode","onMouseDown","onTouchStart","useDroppable"],"sources":["../../../src/utils/useDroppable.ts"],"sourcesContent":["import React, { MouseEvent, TouchEvent, useContext } from 'react';\nimport { ExistingNode, NodeProps } from './NodeList';\n\ninterface DroppableContextProps {\n registerNode: (props: NodeProps) => ExistingNode;\n deregisterNode: (node: ExistingNode) => void;\n onMouseDown: (e: MouseEvent, node: ExistingNode) => void;\n onTouchStart: (e: TouchEvent, node: ExistingNode) => void;\n}\n\nexport const DroppableContext = React.createContext<DroppableContextProps>({\n registerNode: () =>\n [null, null, { current: null }, () => {}, -1, 'id'] as ExistingNode,\n deregisterNode: () => {},\n onMouseDown: () => {},\n onTouchStart: () => {},\n});\n\nconst useDroppable = (): DroppableContextProps => useContext(DroppableContext);\n\nexport default useDroppable;\n"],"mappings":"AAAA,OAAOA,KAAK,IAA4BC,UAAU,QAAQ,OAAO;AAUjE,OAAO,MAAMC,gBAAgB,gBAAGF,KAAK,CAACG,aAAa,CAAwB;EACzEC,YAAY,EAAEA,CAAA,KACZ,CAAC,IAAI,EAAE,IAAI,EAAE;IAAEC,OAAO,EAAE;EAAK,CAAC,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,CAAiB;EACrEC,cAAc,EAAEA,CAAA,KAAM,CAAC,CAAC;EACxBC,WAAW,EAAEA,CAAA,KAAM,CAAC,CAAC;EACrBC,YAAY,EAAEA,CAAA,KAAM,CAAC;AACvB,CAAC,CAAC;AAEF,MAAMC,YAAY,GAAGA,CAAA,KAA6BR,UAAU,CAACC,gBAAgB,CAAC;AAE9E,eAAeO,YAAY"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGeneratedId.js","names":["useMemo","useGeneratedId","Math","random","toString","slice"],"sources":["../../../src/utils/useGeneratedId.ts"],"sourcesContent":["import { useMemo } from 'react';\n\nconst useGeneratedId = () =>\n useMemo(() => Math.random().toString(16).slice(2), []);\n\nexport default useGeneratedId;\n"],"mappings":"AAAA,SAASA,OAAO,QAAQ,OAAO;AAE/B,MAAMC,cAAc,
|
|
1
|
+
{"version":3,"file":"useGeneratedId.js","names":["useMemo","useGeneratedId","Math","random","toString","slice"],"sources":["../../../src/utils/useGeneratedId.ts"],"sourcesContent":["import { useMemo } from 'react';\n\nconst useGeneratedId = () =>\n useMemo(() => Math.random().toString(16).slice(2), []);\n\nexport default useGeneratedId;\n"],"mappings":"AAAA,SAASA,OAAO,QAAQ,OAAO;AAE/B,MAAMC,cAAc,GAAGA,CAAA,KACrBD,OAAO,CAAC,MAAME,IAAI,CAACC,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,EAAE,CAAC,CAACC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;AAExD,eAAeJ,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useInitRect.js","names":["useMemo","useInitRect","ref","current","rect","getBoundingClientRect","initX","x","initY","y","initWidth","width","initHeight","height"],"sources":["../../../src/utils/useInitRect.ts"],"sourcesContent":["import { RefObject, useMemo } from 'react';\n\nconst useInitRect = (ref?: RefObject<HTMLElement>) =>\n useMemo(() => {\n if (!ref || !ref.current) return null;\n\n const rect = ref.current.getBoundingClientRect();\n\n return {\n initX: rect.x,\n initY: rect.y,\n initWidth: rect.width,\n initHeight: rect.height,\n };\n }, [ref]);\n\nexport default useInitRect;\n"],"mappings":"AAAA,SAAoBA,OAAO,QAAQ,OAAO;AAE1C,MAAMC,WAAW,GAAIC,GAA4B,IAC/CF,OAAO,CAAC,MAAM;EACZ,IAAI,CAACE,GAAG,IAAI,CAACA,GAAG,CAACC,OAAO,EAAE,OAAO,IAAI;EAErC,MAAMC,IAAI,GAAGF,GAAG,CAACC,OAAO,CAACE,qBAAqB,
|
|
1
|
+
{"version":3,"file":"useInitRect.js","names":["useMemo","useInitRect","ref","current","rect","getBoundingClientRect","initX","x","initY","y","initWidth","width","initHeight","height"],"sources":["../../../src/utils/useInitRect.ts"],"sourcesContent":["import { RefObject, useMemo } from 'react';\n\nconst useInitRect = (ref?: RefObject<HTMLElement>) =>\n useMemo(() => {\n if (!ref || !ref.current) return null;\n\n const rect = ref.current.getBoundingClientRect();\n\n return {\n initX: rect.x,\n initY: rect.y,\n initWidth: rect.width,\n initHeight: rect.height,\n };\n }, [ref]);\n\nexport default useInitRect;\n"],"mappings":"AAAA,SAAoBA,OAAO,QAAQ,OAAO;AAE1C,MAAMC,WAAW,GAAIC,GAA4B,IAC/CF,OAAO,CAAC,MAAM;EACZ,IAAI,CAACE,GAAG,IAAI,CAACA,GAAG,CAACC,OAAO,EAAE,OAAO,IAAI;EAErC,MAAMC,IAAI,GAAGF,GAAG,CAACC,OAAO,CAACE,qBAAqB,CAAC,CAAC;EAEhD,OAAO;IACLC,KAAK,EAAEF,IAAI,CAACG,CAAC;IACbC,KAAK,EAAEJ,IAAI,CAACK,CAAC;IACbC,SAAS,EAAEN,IAAI,CAACO,KAAK;IACrBC,UAAU,EAAER,IAAI,CAACS;EACnB,CAAC;AACH,CAAC,EAAE,CAACX,GAAG,CAAC,CAAC;AAEX,eAAeD,WAAW"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMoveNode.js","names":["useCallback","getNodeRect","useMoveNode","props","position","draggedNode","getNodeStyle","options","list","startNode","direction","destination","isAnotherList","draggedNodeIndex","node","axis","horizontal","startRectProp","endRectProp","prev","nodeSetStyle","nodeIndex","prevNodeRef","prevNodeSetStyle","prevNodeIndex","prevNodeRect","next","nextNodeRef","nextNodeSetStyle","nextNodeIndex","nextNodeRect"],"sources":["../../../src/utils/useMoveNode.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"useMoveNode.js","names":["useCallback","getNodeRect","useMoveNode","props","position","draggedNode","getNodeStyle","options","list","startNode","direction","destination","isAnotherList","draggedNodeIndex","node","axis","horizontal","startRectProp","endRectProp","prev","nodeSetStyle","nodeIndex","prevNodeRef","prevNodeSetStyle","prevNodeIndex","prevNodeRect","next","nextNodeRef","nextNodeSetStyle","nextNodeIndex","nextNodeRect"],"sources":["../../../src/utils/useMoveNode.ts"],"sourcesContent":["import { Position } from '@os-design/use-drag';\nimport { useCallback } from 'react';\nimport NodeList, { ExistingNode } from './NodeList';\nimport getNodeRect from './getNodeRect';\nimport { NodeStyleGetter } from './useGetNodeStyle';\n\ninterface DraggedNode {\n node: ExistingNode;\n}\n\ninterface UseMoveNodeProps {\n position: Position | null;\n draggedNode: DraggedNode | null;\n getNodeStyle: NodeStyleGetter;\n}\n\ninterface MoveProps {\n list: NodeList;\n startNode: ExistingNode;\n direction: 'up' | 'down';\n destination: 'cursor' | 'end';\n isAnotherList?: boolean;\n}\n\n/* eslint-disable no-constant-condition */\n\nconst useMoveNode = (props: UseMoveNodeProps) => {\n const { position, draggedNode, getNodeStyle } = props;\n\n return useCallback(\n (options: MoveProps) => {\n const {\n list,\n startNode,\n direction,\n destination,\n isAnotherList = false,\n } = options;\n\n if (!draggedNode || !position) return startNode;\n const [, , , , draggedNodeIndex] = draggedNode.node;\n const axis = list.horizontal ? 'x' : 'y';\n const startRectProp = list.horizontal ? 'left' : 'top';\n const endRectProp = list.horizontal ? 'right' : 'bottom';\n let node = startNode;\n\n if (direction === 'up') {\n while (true) {\n const [prev, , , nodeSetStyle, nodeIndex] = node;\n if (!prev) return node;\n\n const [, , prevNodeRef, prevNodeSetStyle, prevNodeIndex] = prev;\n\n if (destination === 'cursor') {\n const prevNodeRect = getNodeRect(prevNodeRef);\n if (prevNodeRect && position[axis] > prevNodeRect[endRectProp]) {\n return node;\n }\n }\n\n if (isAnotherList || prevNodeIndex < draggedNodeIndex) {\n prevNodeSetStyle(getNodeStyle('down', list.horizontal));\n } else if (nodeIndex > draggedNodeIndex) {\n nodeSetStyle(getNodeStyle('init', list.horizontal));\n }\n\n node = prev;\n }\n } else {\n while (true) {\n const [, next, , nodeSetStyle, nodeIndex] = node;\n if (!next) return node;\n\n const [, , nextNodeRef, nextNodeSetStyle, nextNodeIndex] = next;\n\n if (destination === 'cursor') {\n const nextNodeRect = getNodeRect(nextNodeRef);\n if (nextNodeRect && position[axis] < nextNodeRect[startRectProp]) {\n return node;\n }\n }\n\n if (isAnotherList || nodeIndex < draggedNodeIndex) {\n nodeSetStyle(getNodeStyle('init', list.horizontal));\n } else if (nextNodeIndex > draggedNodeIndex) {\n nextNodeSetStyle(getNodeStyle('up', list.horizontal));\n }\n\n node = next;\n }\n }\n },\n [draggedNode, getNodeStyle, position]\n );\n};\n\nexport default useMoveNode;\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AAgB,CAACjB,YAAY,CAAC,MAAM,EAAEE,IAAI,CAACQ,UAAU,CAAC,CAAC;QACzD,CAAC,MAAM,IAAIK,SAAS,GAAGR,gBAAgB,EAAE;UACvCO,YAAY,CAACd,YAAY,CAAC,MAAM,EAAEE,IAAI,CAACQ,UAAU,CAAC,CAAC;QACrD;QAEAF,IAAI,GAAGK,IAAI;MACb;IACF,CAAC,MAAM;MACL,OAAO,IAAI,EAAE;QACX,MAAM,GAAGO,IAAI,GAAIN,YAAY,EAAEC,SAAS,CAAC,GAAGP,IAAI;QAChD,IAAI,CAACY,IAAI,EAAE,OAAOZ,IAAI;QAEtB,MAAM,IAAKa,WAAW,EAAEC,gBAAgB,EAAEC,aAAa,CAAC,GAAGH,IAAI;QAE/D,IAAIf,WAAW,KAAK,QAAQ,EAAE;UAC5B,MAAMmB,YAAY,GAAG7B,WAAW,CAAC0B,WAAW,CAAC;UAC7C,IAAIG,YAAY,IAAI1B,QAAQ,CAACW,IAAI,CAAC,GAAGe,YAAY,CAACb,aAAa,CAAC,EAAE;YAChE,OAAOH,IAAI;UACb;QACF;QAEA,IAAIF,aAAa,IAAIS,SAAS,GAAGR,gBAAgB,EAAE;UACjDO,YAAY,CAACd,YAAY,CAAC,MAAM,EAAEE,IAAI,CAACQ,UAAU,CAAC,CAAC;QACrD,CAAC,MAAM,IAAIa,aAAa,GAAGhB,gBAAgB,EAAE;UAC3Ce,gBAAgB,CAACtB,YAAY,CAAC,IAAI,EAAEE,IAAI,CAACQ,UAAU,CAAC,CAAC;QACvD;QAEAF,IAAI,GAAGY,IAAI;MACb;IACF;EACF,CAAC,EACD,CAACrB,WAAW,EAAEC,YAAY,EAAEF,QAAQ,CACtC,CAAC;AACH,CAAC;AAED,eAAeF,WAAW"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useScrollEventByPoint.js","names":["useCallback","useEffect","useRef","
|
|
1
|
+
{"version":3,"file":"useScrollEventByPoint.js","names":["getScrollableElements","useCallback","useEffect","useRef","compare","prevArr","nextArr","remove","add","forEach","item","includes","push","useScrollEventByPoint","point","listener","listenerRef","current","eventListener","e","elementsRef","scrollableElements","x","y","getTarget","document","body","window","index","indexOf","splice","removeEventListener","addEventListener"],"sources":["../../../src/utils/useScrollEventByPoint.ts"],"sourcesContent":["import { getScrollableElements } from '@os-design/use-auto-scroll';\nimport { useCallback, useEffect, useRef } from 'react';\n\nconst compare = <T>(prevArr: T[], nextArr: T[]) => {\n const remove: T[] = [];\n const add: T[] = [];\n prevArr.forEach((item) => {\n if (!nextArr.includes(item)) remove.push(item);\n });\n nextArr.forEach((item) => {\n if (!prevArr.includes(item)) add.push(item);\n });\n return { remove, add };\n};\n\nexport interface Point {\n x: number;\n y: number;\n}\n\n/**\n * Sets the listener that will be called whenever the scroll event occurs\n * in one of the elements located under the specified point.\n */\nconst useScrollEventByPoint = (\n point: Point | null,\n listener: (e: Event) => void\n) => {\n const listenerRef = useRef(listener);\n useEffect(() => {\n listenerRef.current = listener;\n }, [listener]);\n\n const eventListener = useCallback((e: Event) => listenerRef.current(e), []);\n const elementsRef = useRef<Element[]>([]);\n\n useEffect(() => {\n if (!point) return;\n const scrollableElements = getScrollableElements(point.x, point.y);\n const { remove, add } = compare(elementsRef.current, scrollableElements);\n const getTarget = (item: Element) =>\n item === document.body ? window : item;\n\n remove.forEach((item) => {\n const index = elementsRef.current.indexOf(item);\n if (index >= 0) elementsRef.current.splice(index, 1);\n getTarget(item).removeEventListener('scroll', eventListener);\n });\n add.forEach((item) => {\n elementsRef.current.push(item);\n getTarget(item).addEventListener('scroll', eventListener);\n });\n }, [eventListener, point]);\n};\n\nexport default useScrollEventByPoint;\n"],"mappings":"AAAA,SAASA,qBAAqB,QAAQ,4BAA4B;AAClE,SAASC,WAAW,EAAEC,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAEtD,MAAMC,OAAO,GAAGA,CAAIC,OAAY,EAAEC,OAAY,KAAK;EACjD,MAAMC,MAAW,GAAG,EAAE;EACtB,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,GAAGR,WAAW,CAACH,OAAO,CAACY,OAAO,CAACnB,IAAI,CAAC;MAC/C,IAAIkB,KAAK,IAAI,CAAC,EAAER,WAAW,CAACH,OAAO,CAACa,MAAM,CAACF,KAAK,EAAE,CAAC,CAAC;MACpDJ,SAAS,CAACd,IAAI,CAAC,CAACqB,mBAAmB,CAAC,QAAQ,EAAEb,aAAa,CAAC;IAC9D,CAAC,CAAC;IACFV,GAAG,CAACC,OAAO,CAAEC,IAAI,IAAK;MACpBU,WAAW,CAACH,OAAO,CAACL,IAAI,CAACF,IAAI,CAAC;MAC9Bc,SAAS,CAACd,IAAI,CAAC,CAACsB,gBAAgB,CAAC,QAAQ,EAAEd,aAAa,CAAC;IAC3D,CAAC,CAAC;EACJ,CAAC,EAAE,CAACA,aAAa,EAAEJ,KAAK,CAAC,CAAC;AAC5B,CAAC;AAED,eAAeD,qBAAqB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useCallback, useMemo, useState } from 'react';
|
|
2
1
|
import useThrottle from '@os-design/use-throttle';
|
|
2
|
+
import { useCallback, useMemo, useState } from 'react';
|
|
3
3
|
import useScrollEventByPoint from './useScrollEventByPoint';
|
|
4
4
|
const useTargetList = (position, listStoreRef) => {
|
|
5
5
|
const [number, setNumber] = useState(0);
|