@os-design/drag-sort 1.0.13 → 1.0.15

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.
Files changed (88) hide show
  1. package/dist/cjs/DragAndDrop.js +50 -72
  2. package/dist/cjs/DragAndDrop.js.map +1 -1
  3. package/dist/cjs/Draggable.js +19 -36
  4. package/dist/cjs/Draggable.js.map +1 -1
  5. package/dist/cjs/Droppable.js +24 -33
  6. package/dist/cjs/Droppable.js.map +1 -1
  7. package/dist/cjs/index.js +0 -9
  8. package/dist/cjs/index.js.map +1 -1
  9. package/dist/cjs/utils/ListStore.js +4 -13
  10. package/dist/cjs/utils/ListStore.js.map +1 -1
  11. package/dist/cjs/utils/NodeList.js +25 -56
  12. package/dist/cjs/utils/NodeList.js.map +1 -1
  13. package/dist/cjs/utils/getElementOffset.js +0 -4
  14. package/dist/cjs/utils/getElementOffset.js.map +1 -1
  15. package/dist/cjs/utils/getElementScroll.js +0 -4
  16. package/dist/cjs/utils/getElementScroll.js.map +1 -1
  17. package/dist/cjs/utils/getNodeRect.js +9 -18
  18. package/dist/cjs/utils/getNodeRect.js.map +1 -1
  19. package/dist/cjs/utils/useAppendClassName.js +0 -3
  20. package/dist/cjs/utils/useAppendClassName.js.map +1 -1
  21. package/dist/cjs/utils/useBlankNode.js +17 -26
  22. package/dist/cjs/utils/useBlankNode.js.map +1 -1
  23. package/dist/cjs/utils/useDragAndDrop.js +0 -8
  24. package/dist/cjs/utils/useDragAndDrop.js.map +1 -1
  25. package/dist/cjs/utils/useDragEffect.js +104 -163
  26. package/dist/cjs/utils/useDragEffect.js.map +1 -1
  27. package/dist/cjs/utils/useDroppable.js +0 -8
  28. package/dist/cjs/utils/useDroppable.js.map +1 -1
  29. package/dist/cjs/utils/useGeneratedId.js +0 -3
  30. package/dist/cjs/utils/useGeneratedId.js.map +1 -1
  31. package/dist/cjs/utils/useGetNodeStyle.js +0 -3
  32. package/dist/cjs/utils/useGetNodeStyle.js.map +1 -1
  33. package/dist/cjs/utils/useInitRect.js +0 -3
  34. package/dist/cjs/utils/useInitRect.js.map +1 -1
  35. package/dist/cjs/utils/useInitScrollOffset.js +0 -5
  36. package/dist/cjs/utils/useInitScrollOffset.js.map +1 -1
  37. package/dist/cjs/utils/useMoveNode.js +23 -48
  38. package/dist/cjs/utils/useMoveNode.js.map +1 -1
  39. package/dist/cjs/utils/useScrollEventByPoint.js +2 -10
  40. package/dist/cjs/utils/useScrollEventByPoint.js.map +1 -1
  41. package/dist/cjs/utils/useTargetList.js +8 -21
  42. package/dist/cjs/utils/useTargetList.js.map +1 -1
  43. package/dist/cjs/utils/useTransitionStyle.js +2 -5
  44. package/dist/cjs/utils/useTransitionStyle.js.map +1 -1
  45. package/dist/esm/DragAndDrop.js +19 -12
  46. package/dist/esm/DragAndDrop.js.map +1 -1
  47. package/dist/esm/Draggable.js +10 -9
  48. package/dist/esm/Draggable.js.map +1 -1
  49. package/dist/esm/Droppable.js +17 -14
  50. package/dist/esm/Droppable.js.map +1 -1
  51. package/dist/esm/index.js.map +1 -1
  52. package/dist/esm/utils/ListStore.js +3 -8
  53. package/dist/esm/utils/ListStore.js.map +1 -1
  54. package/dist/esm/utils/NodeList.js +17 -36
  55. package/dist/esm/utils/NodeList.js.map +1 -1
  56. package/dist/esm/utils/getElementOffset.js +0 -3
  57. package/dist/esm/utils/getElementOffset.js.map +1 -1
  58. package/dist/esm/utils/getElementScroll.js +0 -3
  59. package/dist/esm/utils/getElementScroll.js.map +1 -1
  60. package/dist/esm/utils/getNodeRect.js +1 -2
  61. package/dist/esm/utils/getNodeRect.js.map +1 -1
  62. package/dist/esm/utils/useAppendClassName.js +1 -2
  63. package/dist/esm/utils/useAppendClassName.js.map +1 -1
  64. package/dist/esm/utils/useBlankNode.js +10 -9
  65. package/dist/esm/utils/useBlankNode.js.map +1 -1
  66. package/dist/esm/utils/useDragAndDrop.js +0 -2
  67. package/dist/esm/utils/useDragAndDrop.js.map +1 -1
  68. package/dist/esm/utils/useDragEffect.js +57 -60
  69. package/dist/esm/utils/useDragEffect.js.map +1 -1
  70. package/dist/esm/utils/useDroppable.js +0 -2
  71. package/dist/esm/utils/useDroppable.js.map +1 -1
  72. package/dist/esm/utils/useGeneratedId.js +0 -2
  73. package/dist/esm/utils/useGeneratedId.js.map +1 -1
  74. package/dist/esm/utils/useGetNodeStyle.js +0 -2
  75. package/dist/esm/utils/useGetNodeStyle.js.map +1 -1
  76. package/dist/esm/utils/useInitRect.js +0 -2
  77. package/dist/esm/utils/useInitRect.js.map +1 -1
  78. package/dist/esm/utils/useInitScrollOffset.js +0 -2
  79. package/dist/esm/utils/useInitScrollOffset.js.map +1 -1
  80. package/dist/esm/utils/useMoveNode.js +1 -11
  81. package/dist/esm/utils/useMoveNode.js.map +1 -1
  82. package/dist/esm/utils/useScrollEventByPoint.js +0 -5
  83. package/dist/esm/utils/useScrollEventByPoint.js.map +1 -1
  84. package/dist/esm/utils/useTargetList.js +2 -3
  85. package/dist/esm/utils/useTargetList.js.map +1 -1
  86. package/dist/esm/utils/useTransitionStyle.js +0 -2
  87. package/dist/esm/utils/useTransitionStyle.js.map +1 -1
  88. package/package.json +11 -11
@@ -13,15 +13,14 @@ const HIDDEN_NODE_STYLE = {
13
13
  opacity: 0,
14
14
  pointerEvents: 'none'
15
15
  };
16
-
17
16
  const createEmptyNode = ({
18
17
  prev = null,
19
18
  next = null
20
19
  }) => [prev, next, {
21
20
  current: null
22
21
  }, () => {}, -1, 'id'];
23
- /* eslint-disable no-constant-condition */
24
22
 
23
+ /* eslint-disable no-constant-condition */
25
24
 
26
25
  const useDragEffect = props => {
27
26
  const {
@@ -38,14 +37,17 @@ const useDragEffect = props => {
38
37
  const onDragEndRef = useRef(onDragEnd);
39
38
  useEffect(() => {
40
39
  onDragEndRef.current = onDragEnd;
41
- }, [onDragEnd]); // The initial bounds of the dragged node.
40
+ }, [onDragEnd]);
41
+
42
+ // The initial bounds of the dragged node.
42
43
  // We can't read the bounds of the dragged node on the fly because the node can be unmounted in the virtual list.
44
+ const initDraggedNodeRect = useInitRect(draggedNode ? draggedNode.node[2] : undefined);
43
45
 
44
- const initDraggedNodeRect = useInitRect(draggedNode ? draggedNode.node[2] : undefined); // The initial scroll position of the list where the dragged node is located.
46
+ // The initial scroll position of the list where the dragged node is located.
45
47
  // Used to detect the actual position of the dragged node. The purpose is the same as with initDraggedNodeRect.
48
+ const initDraggedNodeListScrollOffset = useInitScrollOffset(draggedNode ? draggedNode.list.ref : undefined);
46
49
 
47
- const initDraggedNodeListScrollOffset = useInitScrollOffset(draggedNode ? draggedNode.list.ref : undefined); // The central position of the dragged node
48
-
50
+ // The central position of the dragged node
49
51
  const position = useMemo(() => {
50
52
  if (!draggedNode || !initDraggedNodeRect) return null;
51
53
  const {
@@ -60,12 +62,15 @@ const useDragEffect = props => {
60
62
  x: x - draggedNode.position.x + initWidth / 2,
61
63
  y: y - draggedNode.position.y + initHeight / 2
62
64
  };
63
- }, [cursorPosition, draggedNode, initDraggedNodeRect]); // The list in which the cursor is located
65
+ }, [cursorPosition, draggedNode, initDraggedNodeRect]);
64
66
 
65
- const targetList = useTargetList(position, listStoreRef); // Returns the style for moving the node in the specified direction
67
+ // The list in which the cursor is located
68
+ const targetList = useTargetList(position, listStoreRef);
66
69
 
67
- const getNodeStyle = useGetNodeStyle(initDraggedNodeRect); // Moves the node up or down
70
+ // Returns the style for moving the node in the specified direction
71
+ const getNodeStyle = useGetNodeStyle(initDraggedNodeRect);
68
72
 
73
+ // Moves the node up or down
69
74
  const moveNode = useMoveNode({
70
75
  position,
71
76
  draggedNode,
@@ -86,13 +91,13 @@ const useDragEffect = props => {
86
91
  const clearTargetNode = useCallback(() => {
87
92
  targetNodeRef.current = null;
88
93
  targetRef.current = null;
89
- }, []); // Returns the central position of the dragged node in the list
94
+ }, []);
90
95
 
96
+ // Returns the central position of the dragged node in the list
91
97
  const getDraggedNodePos = useCallback(() => {
92
98
  if (!targetList || !targetList.ref.current || !initDraggedNodeRect || !initDraggedNodeListScrollOffset) {
93
99
  return null;
94
100
  }
95
-
96
101
  const {
97
102
  initX,
98
103
  initY,
@@ -115,16 +120,18 @@ const useDragEffect = props => {
115
120
  const getDraggedNodePosRef = useRef(getDraggedNodePos);
116
121
  useEffect(() => {
117
122
  getDraggedNodePosRef.current = getDraggedNodePos;
118
- }, [getDraggedNodePos]); // Hide the dragged node
123
+ }, [getDraggedNodePos]);
119
124
 
125
+ // Hide the dragged node
120
126
  useEffect(() => {
121
127
  if (!draggedNode) return () => {};
122
128
  const [,,, draggedNodeSetStyle] = draggedNode.node;
123
129
  draggedNodeSetStyle(HIDDEN_NODE_STYLE);
124
130
  return () => draggedNodeSetStyle({});
125
- }, [draggedNode]); // Append the blank node to the list to increase the height of it.
126
- // Used when the dragged node is located inside another list.
131
+ }, [draggedNode]);
127
132
 
133
+ // Append the blank node to the list to increase the height of it.
134
+ // Used when the dragged node is located inside another list.
128
135
  const removeBlankNode = useBlankNode({
129
136
  draggedNode,
130
137
  targetList,
@@ -133,8 +140,8 @@ const useDragEffect = props => {
133
140
  const updateTargetNode = useCallback(() => {
134
141
  if (!draggedNode) return;
135
142
  const prevTargetNode = targetNodeRef.current; // The last updated node
136
- // Dragging outside the origin list
137
143
 
144
+ // Dragging outside the origin list
138
145
  if (prevTargetNode && prevTargetNode.list === draggedNode.list && targetList !== draggedNode.list) {
139
146
  moveNode({
140
147
  list: prevTargetNode.list,
@@ -143,9 +150,9 @@ const useDragEffect = props => {
143
150
  destination: 'end'
144
151
  });
145
152
  clearTargetNode();
146
- } // Dragging outside another list
147
-
153
+ }
148
154
 
155
+ // Dragging outside another list
149
156
  if (prevTargetNode && prevTargetNode.list !== draggedNode.list && targetList !== prevTargetNode.list) {
150
157
  moveNode({
151
158
  list: prevTargetNode.list,
@@ -156,9 +163,9 @@ const useDragEffect = props => {
156
163
  });
157
164
  removeBlankNode();
158
165
  clearTargetNode();
159
- } // Dragging inside the origin list
160
-
166
+ }
161
167
 
168
+ // Dragging inside the origin list
162
169
  if (!prevTargetNode && targetList === draggedNode.list) {
163
170
  const tail = targetList.getTail();
164
171
  if (!tail) return;
@@ -170,9 +177,9 @@ const useDragEffect = props => {
170
177
  });
171
178
  setTargetNode(targetList, node);
172
179
  return;
173
- } // Dragging inside another list
174
-
180
+ }
175
181
 
182
+ // Dragging inside another list
176
183
  if (targetList && targetList !== draggedNode.list && (!prevTargetNode || prevTargetNode.list !== targetList)) {
177
184
  const tail = targetList.getTail();
178
185
  if (!tail) return;
@@ -185,13 +192,12 @@ const useDragEffect = props => {
185
192
  });
186
193
  setTargetNode(targetList, node);
187
194
  return;
188
- } // Dragging in the origin list
189
-
195
+ }
190
196
 
197
+ // Dragging in the origin list
191
198
  if (prevTargetNode && prevTargetNode.list === draggedNode.list && targetList === draggedNode.list) {
192
199
  const axis = targetList.horizontal ? 'x' : 'y';
193
200
  const [,, prevTargetNodeRef,,] = prevTargetNode.node;
194
-
195
201
  if (!prevTargetNodeRef.current) {
196
202
  // The target node was unmounted. It happens when the virtual list is used.
197
203
  // If the cursor is above the dragged node, we need to move the nodes down from the tail to the node where
@@ -200,7 +206,6 @@ const useDragEffect = props => {
200
206
  const draggedNodePos = getDraggedNodePosRef.current();
201
207
  if (!position || !draggedNodePos) return;
202
208
  const isDraggingUp = position[axis] < draggedNodePos[axis];
203
-
204
209
  if (isDraggingUp) {
205
210
  const tail = targetList.getTail();
206
211
  if (!tail || !tail[2].current) return;
@@ -226,10 +231,8 @@ const useDragEffect = props => {
226
231
  });
227
232
  setTargetNode(targetList, node);
228
233
  }
229
-
230
234
  return;
231
235
  }
232
-
233
236
  const prevTargetNodeRect = getNodeRect(prevTargetNode.node[2]);
234
237
  const startRectProp = targetList.horizontal ? 'left' : 'top';
235
238
  if (!position || !prevTargetNodeRect) return;
@@ -247,9 +250,9 @@ const useDragEffect = props => {
247
250
  });
248
251
  setTargetNode(targetList, node);
249
252
  return;
250
- } // Dragging in another list
251
-
253
+ }
252
254
 
255
+ // Dragging in another list
253
256
  if (targetList && targetList !== draggedNode.list && prevTargetNode && prevTargetNode.list === targetList) {
254
257
  const axis = targetList.horizontal ? 'x' : 'y';
255
258
  const prevTargetNodeRect = getNodeRect(prevTargetNode.node[2]);
@@ -271,29 +274,31 @@ const useDragEffect = props => {
271
274
  });
272
275
  setTargetNode(targetList, node);
273
276
  }
274
- }, [draggedNode, targetList, moveNode, clearTargetNode, removeBlankNode, setTargetNode, position]); // Update the target node if either the position or the target list has been changed
277
+ }, [draggedNode, targetList, moveNode, clearTargetNode, removeBlankNode, setTargetNode, position]);
275
278
 
279
+ // Update the target node if either the position or the target list has been changed
276
280
  useEffect(() => {
277
281
  updateTargetNode();
278
- }, [updateTargetNode]); // Update the target node if the target list has been scrolled
282
+ }, [updateTargetNode]);
279
283
 
284
+ // Update the target node if the target list has been scrolled
280
285
  const [throttledUpdateTargetNode] = useThrottle(updateTargetNode, 100);
281
286
  useEvent(targetList ? targetList.ref : undefined, 'scroll', throttledUpdateTargetNode);
282
- useEvent(window, 'scroll', throttledUpdateTargetNode); // Reset styles of the affected nodes when the dragged node was dropped
287
+ useEvent(window, 'scroll', throttledUpdateTargetNode);
283
288
 
289
+ // Reset styles of the affected nodes when the dragged node was dropped
284
290
  useEffect(() => {
285
291
  if (!draggedNode) return () => {};
286
292
  const [,,,, draggedNodeIndex] = draggedNode.node;
287
293
  return () => {
288
- const targetNode = targetNodeRef.current; // If the dragged node was outside the origin list, reset the styles for the nodes,
289
- // starting at the tail and ending with the dragged node in the origin list.
294
+ const targetNode = targetNodeRef.current;
290
295
 
296
+ // If the dragged node was outside the origin list, reset the styles for the nodes,
297
+ // starting at the tail and ending with the dragged node in the origin list.
291
298
  if (!targetNode || targetNode.list !== draggedNode.list) {
292
299
  const tail = draggedNode.list.getTail();
293
-
294
300
  if (tail) {
295
301
  let node = tail;
296
-
297
302
  while (true) {
298
303
  const [prev,,, nodeSetStyle, nodeIndex] = node;
299
304
  nodeSetStyle({});
@@ -301,17 +306,15 @@ const useDragEffect = props => {
301
306
  node = prev;
302
307
  }
303
308
  }
304
- } // If the dragged node was inside another list, reset the styles for the nodes,
305
- // starting at the tail and ending with the dragged node in the target list.
306
-
309
+ }
307
310
 
311
+ // If the dragged node was inside another list, reset the styles for the nodes,
312
+ // starting at the tail and ending with the dragged node in the target list.
308
313
  if (targetNode && targetNode.list !== draggedNode.list) {
309
314
  const tail = targetNode.list.getTail();
310
315
  const [,,,, targetNodeIndex] = targetNode.node;
311
-
312
316
  if (tail) {
313
317
  let node = tail;
314
-
315
318
  while (true) {
316
319
  const [prev,,, nodeSetStyle, nodeIndex] = node;
317
320
  nodeSetStyle({});
@@ -319,18 +322,16 @@ const useDragEffect = props => {
319
322
  node = prev;
320
323
  }
321
324
  }
322
- } // If the dragged node was moved inside the origin list, reset the styles for the nodes,
323
- // starting with target node and ending with the dragged node.
324
-
325
+ }
325
326
 
327
+ // If the dragged node was moved inside the origin list, reset the styles for the nodes,
328
+ // starting with target node and ending with the dragged node.
326
329
  if (targetNode && targetNode.list === draggedNode.list) {
327
330
  const [,,, targetNodeSetStyle, targetNodeIndex] = targetNode.node;
328
-
329
331
  if (targetNodeIndex > draggedNodeIndex) {
330
332
  let {
331
333
  node
332
334
  } = targetNode;
333
-
334
335
  while (true) {
335
336
  const [prev,,, nodeSetStyle, nodeIndex] = node;
336
337
  nodeSetStyle({});
@@ -341,7 +342,6 @@ const useDragEffect = props => {
341
342
  let {
342
343
  node
343
344
  } = targetNode;
344
-
345
345
  while (true) {
346
346
  const [, next,, nodeSetStyle, nodeIndex] = node;
347
347
  nodeSetStyle({});
@@ -353,29 +353,29 @@ const useDragEffect = props => {
353
353
  }
354
354
  }
355
355
  };
356
- }, [draggedNode]); // Update the position of the newly mounted nodes in the origin list (used in the virtual list)
356
+ }, [draggedNode]);
357
357
 
358
+ // Update the position of the newly mounted nodes in the origin list (used in the virtual list)
358
359
  useEffect(() => {
359
360
  if (!draggedNode) return () => {};
360
361
  const [,,,, draggedNodeIndex] = draggedNode.node;
361
-
362
362
  const update = nodeProps => {
363
363
  const {
364
364
  setStyle,
365
365
  index
366
366
  } = nodeProps;
367
- const targetNode = targetNodeRef.current; // Set the hidden style, if the mounted node is the dragged node
367
+ const targetNode = targetNodeRef.current;
368
368
 
369
+ // Set the hidden style, if the mounted node is the dragged node
369
370
  if (index === draggedNodeIndex) {
370
371
  setStyle(HIDDEN_NODE_STYLE);
371
372
  return;
372
- } // If the dragged node is inside the origin list
373
-
373
+ }
374
374
 
375
+ // If the dragged node is inside the origin list
375
376
  if (targetNode && targetNode.list === draggedNode.list) {
376
377
  // Move the mounted node up/down, if it is located between the dragged and target node
377
378
  const [,,,, targetNodeIndex] = targetNode.node;
378
-
379
379
  if (index > draggedNodeIndex && index < targetNodeIndex) {
380
380
  setStyle(getNodeStyle('up', targetNode.list.horizontal));
381
381
  } else if (index < draggedNodeIndex && index > targetNodeIndex) {
@@ -386,16 +386,15 @@ const useDragEffect = props => {
386
386
  setStyle(getNodeStyle('up', draggedNode.list.horizontal));
387
387
  }
388
388
  };
389
-
390
389
  draggedNode.list.addListener(update);
391
390
  return () => draggedNode.list.removeListener(update);
392
- }, [draggedNode, getNodeStyle]); // Update the position of the newly mounted nodes in the target list (used in the virtual list)
391
+ }, [draggedNode, getNodeStyle]);
393
392
 
393
+ // Update the position of the newly mounted nodes in the target list (used in the virtual list)
394
394
  useEffect(() => {
395
395
  if (!draggedNode || !targetList || targetList === draggedNode.list) {
396
396
  return () => {};
397
397
  }
398
-
399
398
  const update = nodeProps => {
400
399
  const {
401
400
  setStyle,
@@ -404,17 +403,16 @@ const useDragEffect = props => {
404
403
  const targetNode = targetNodeRef.current;
405
404
  if (!targetNode) return;
406
405
  const [,,,, targetNodeIndex] = targetNode.node;
407
-
408
406
  if (index >= targetNodeIndex) {
409
407
  // Move the mounted node down, if it is located below the target node or if it is the target node
410
408
  setStyle(getNodeStyle('down', targetList.horizontal));
411
409
  }
412
410
  };
413
-
414
411
  targetList.addListener(update);
415
412
  return () => targetList.removeListener(update);
416
- }, [draggedNode, getNodeStyle, targetList]); // Call the onDragEnd callback if the draggedNode was changed to null
413
+ }, [draggedNode, getNodeStyle, targetList]);
417
414
 
415
+ // Call the onDragEnd callback if the draggedNode was changed to null
418
416
  useEffect(() => {
419
417
  if (!draggedNode) return () => {};
420
418
  return () => {
@@ -432,6 +430,5 @@ const useDragEffect = props => {
432
430
  };
433
431
  }, [draggedNode]);
434
432
  };
435
-
436
433
  export default useDragEffect;
437
434
  //# sourceMappingURL=useDragEffect.js.map
@@ -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"],"mappings":"AACA,SAGEA,WAHF,EAIEC,SAJF,EAKEC,OALF,EAMEC,MANF,QAOO,OAPP;AAQA,OAAOC,WAAP,MAAwB,yBAAxB;AACA,OAAOC,QAAP,MAAqB,sBAArB;AAGA,OAAOC,gBAAP,MAA6B,oBAA7B;AACA,OAAOC,aAAP,MAA0B,iBAA1B;AACA,OAAOC,WAAP,MAAwB,eAAxB;AACA,OAAOC,mBAAP,MAAgC,uBAAhC;AACA,OAAOC,eAAP,MAA4B,mBAA5B;AACA,OAAOC,WAAP,MAAwB,eAAxB;AACA,OAAOC,WAAP,MAAwB,eAAxB;AACA,OAAOC,YAAP,MAAyB,gBAAzB;AA+BA,MAAMC,iBAAgC,GAAG;EACvCC,OAAO,EAAE,CAD8B;EAEvCC,aAAa,EAAE;AAFwB,CAAzC;;AAKA,MAAMC,eAAe,GAAG,CAAC;EACvBC,IAAI,GAAG,IADgB;EAEvBC,IAAI,GAAG;AAFgB,CAAD,KAMJ,CAACD,IAAD,EAAOC,IAAP,EAAa;EAAEC,OAAO,EAAE;AAAX,CAAb,EAAgC,MAAM,CAAE,CAAxC,EAA0C,CAAC,CAA3C,EAA8C,IAA9C,CANpB;AAQA;;;AAEA,MAAMC,aAAa,GAAIC,KAAD,IAA+B;EACnD,MAAM;IAAEC,WAAF;IAAeC,cAAf;IAA+BC,YAA/B;IAA6CC;EAA7C,IAA2DJ,KAAjE;EAEA,MAAMK,SAAS,GAAGxB,MAAM,CAAsB,IAAtB,CAAxB;EACA,MAAMyB,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QAAQ,CAAC9C,YAAY,CAAC,MAAD,EAASD,UAAU,CAAC6B,UAApB,CAAb,CAAR;MACD;IACF,CATD;;IAWA7B,UAAU,CAACgD,WAAX,CAAuBH,MAAvB;IACA,OAAO,MAAM7C,UAAU,CAACiD,cAAX,CAA0BJ,MAA1B,CAAb;EACD,CAlBQ,EAkBN,CAAC/D,WAAD,EAAcmB,YAAd,EAA4BD,UAA5B,CAlBM,CAAT,CAhYmD,CAoZnD;;EACAxC,SAAS,CAAC,MAAM;IACd,IAAI,CAACsB,WAAL,EAAkB,OAAO,MAAM,CAAE,CAAf;IAClB,OAAO,MAAM;MACX;MACA,MAAMoE,MAAM,GAAGhE,SAAS,CAACP,OAAzB;MACA,IAAI,CAACuE,MAAL,EAAa;MACb,MAAM,MAASV,gBAAT,EAA2BW,aAA3B,IAA4CrE,WAAW,CAACQ,IAA9D;MACA,MAAM8D,OAAO,GAAG;QACd9C,MAAM,EAAExB,WAAW,CAACW,IAAZ,CAAiBc,EADX;QAEdC,KAAK,EAAEgC,gBAFO;QAGdjC,EAAE,EAAE4C;MAHU,CAAhB;MAKA,IAAIC,OAAO,CAAC7C,EAAR,KAAe2C,MAAM,CAAC3C,EAAtB,IAA4B6C,OAAO,CAAC5C,KAAR,KAAkB0C,MAAM,CAAC1C,KAAzD,EAAgE;MAChEpB,YAAY,CAACT,OAAb,CAAqByE,OAArB,EAA8BF,MAA9B;IACD,CAZD;EAaD,CAfQ,EAeN,CAACpE,WAAD,CAfM,CAAT;AAgBD,CAraD;;AAuaA,eAAeF,aAAf"}
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"],"mappings":"AACA,SAGEA,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,MAAM,QACD,OAAO;AACd,OAAOC,WAAW,MAAM,yBAAyB;AACjD,OAAOC,QAAQ,MAAM,sBAAsB;AAG3C,OAAOC,gBAAgB,MAAM,oBAAoB;AACjD,OAAOC,aAAa,MAAM,iBAAiB;AAC3C,OAAOC,WAAW,MAAM,eAAe;AACvC,OAAOC,mBAAmB,MAAM,uBAAuB;AACvD,OAAOC,eA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nB,CAAC;AAED,eAAeF,aAAa"}
@@ -7,8 +7,6 @@ export const DroppableContext = /*#__PURE__*/React.createContext({
7
7
  onMouseDown: () => {},
8
8
  onTouchStart: () => {}
9
9
  });
10
-
11
10
  const useDroppable = () => useContext(DroppableContext);
12
-
13
11
  export default useDroppable;
14
12
  //# sourceMappingURL=useDroppable.js.map
@@ -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, { useContext, MouseEvent, TouchEvent } 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,KAAP,IAAgBC,UAAhB,QAA0D,OAA1D;AAUA,OAAO,MAAMC,gBAAgB,gBAAGF,KAAK,CAACG,aAAN,CAA2C;EACzEC,YAAY,EAAE,MACZ,CAAC,IAAD,EAAO,IAAP,EAAa;IAAEC,OAAO,EAAE;EAAX,CAAb,EAAgC,MAAM,CAAE,CAAxC,EAA0C,CAAC,CAA3C,EAA8C,IAA9C,CAFuE;EAGzEC,cAAc,EAAE,MAAM,CAAE,CAHiD;EAIzEC,WAAW,EAAE,MAAM,CAAE,CAJoD;EAKzEC,YAAY,EAAE,MAAM,CAAE;AALmD,CAA3C,CAAzB;;AAQP,MAAMC,YAAY,GAAG,MAA6BR,UAAU,CAACC,gBAAD,CAA5D;;AAEA,eAAeO,YAAf"}
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, { useContext, MouseEvent, TouchEvent } 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,IAAIC,UAAU,QAAgC,OAAO;AAUjE,OAAO,MAAMC,gBAAgB,gBAAGF,KAAK,CAACG,aAAa,CAAwB;EACzEC,YAAY,EAAE,MACZ,CAAC,IAAI,EAAE,IAAI,EAAE;IAAEC,OAAO,EAAE;EAAK,CAAC,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,CAAiB;EACrEC,cAAc,EAAE,MAAM,CAAC,CAAC;EACxBC,WAAW,EAAE,MAAM,CAAC,CAAC;EACrBC,YAAY,EAAE,MAAM,CAAC;AACvB,CAAC,CAAC;AAEF,MAAMC,YAAY,GAAG,MAA6BR,UAAU,CAACC,gBAAgB,CAAC;AAE9E,eAAeO,YAAY"}
@@ -1,6 +1,4 @@
1
1
  import { useMemo } from 'react';
2
-
3
2
  const useGeneratedId = () => useMemo(() => Math.random().toString(16).slice(2), []);
4
-
5
3
  export default useGeneratedId;
6
4
  //# sourceMappingURL=useGeneratedId.js.map
@@ -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,OAAT,QAAwB,OAAxB;;AAEA,MAAMC,cAAc,GAAG,MACrBD,OAAO,CAAC,MAAME,IAAI,CAACC,MAAL,GAAcC,QAAd,CAAuB,EAAvB,EAA2BC,KAA3B,CAAiC,CAAjC,CAAP,EAA4C,EAA5C,CADT;;AAGA,eAAeJ,cAAf"}
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,GAAG,MACrBD,OAAO,CAAC,MAAME,IAAI,CAACC,MAAM,EAAE,CAACC,QAAQ,CAAC,EAAE,CAAC,CAACC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;AAExD,eAAeJ,cAAc"}
@@ -1,5 +1,4 @@
1
1
  import { useCallback, useEffect, useRef } from 'react';
2
-
3
2
  const useGetNodeStyle = size => {
4
3
  const sizeRef = useRef(size);
5
4
  useEffect(() => {
@@ -15,6 +14,5 @@ const useGetNodeStyle = size => {
15
14
  return style;
16
15
  }, []);
17
16
  };
18
-
19
17
  export default useGetNodeStyle;
20
18
  //# sourceMappingURL=useGetNodeStyle.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useGetNodeStyle.js","names":["useCallback","useEffect","useRef","useGetNodeStyle","size","sizeRef","current","type","horizontal","translateFn","sizeProp","sign","style","transform"],"sources":["../../../src/utils/useGetNodeStyle.ts"],"sourcesContent":["import { CSSProperties, useCallback, useEffect, useRef } from 'react';\n\ninterface InitSize {\n initWidth: number;\n initHeight: number;\n}\n\nexport type NodeStyleGetter = (\n type: 'up' | 'down' | 'init',\n horizontal: boolean\n) => CSSProperties;\n\nconst useGetNodeStyle = (size: InitSize | null): NodeStyleGetter => {\n const sizeRef = useRef(size);\n\n useEffect(() => {\n sizeRef.current = size;\n }, [size]);\n\n return useCallback<NodeStyleGetter>((type, horizontal) => {\n if (type === 'init' || !sizeRef.current) return {};\n\n const translateFn = horizontal ? 'translateX' : 'translateY';\n const sizeProp = horizontal ? 'initWidth' : 'initHeight';\n const sign = type === 'down' ? 1 : -1;\n\n const style: CSSProperties = {};\n style.transform = `${translateFn}(${sign * sizeRef.current[sizeProp]}px)`;\n\n return style;\n }, []);\n};\n\nexport default useGetNodeStyle;\n"],"mappings":"AAAA,SAAwBA,WAAxB,EAAqCC,SAArC,EAAgDC,MAAhD,QAA8D,OAA9D;;AAYA,MAAMC,eAAe,GAAIC,IAAD,IAA4C;EAClE,MAAMC,OAAO,GAAGH,MAAM,CAACE,IAAD,CAAtB;EAEAH,SAAS,CAAC,MAAM;IACdI,OAAO,CAACC,OAAR,GAAkBF,IAAlB;EACD,CAFQ,EAEN,CAACA,IAAD,CAFM,CAAT;EAIA,OAAOJ,WAAW,CAAkB,CAACO,IAAD,EAAOC,UAAP,KAAsB;IACxD,IAAID,IAAI,KAAK,MAAT,IAAmB,CAACF,OAAO,CAACC,OAAhC,EAAyC,OAAO,EAAP;IAEzC,MAAMG,WAAW,GAAGD,UAAU,GAAG,YAAH,GAAkB,YAAhD;IACA,MAAME,QAAQ,GAAGF,UAAU,GAAG,WAAH,GAAiB,YAA5C;IACA,MAAMG,IAAI,GAAGJ,IAAI,KAAK,MAAT,GAAkB,CAAlB,GAAsB,CAAC,CAApC;IAEA,MAAMK,KAAoB,GAAG,EAA7B;IACAA,KAAK,CAACC,SAAN,GAAmB,GAAEJ,WAAY,IAAGE,IAAI,GAAGN,OAAO,CAACC,OAAR,CAAgBI,QAAhB,CAA0B,KAArE;IAEA,OAAOE,KAAP;EACD,CAXiB,EAWf,EAXe,CAAlB;AAYD,CAnBD;;AAqBA,eAAeT,eAAf"}
1
+ {"version":3,"file":"useGetNodeStyle.js","names":["useCallback","useEffect","useRef","useGetNodeStyle","size","sizeRef","current","type","horizontal","translateFn","sizeProp","sign","style","transform"],"sources":["../../../src/utils/useGetNodeStyle.ts"],"sourcesContent":["import { CSSProperties, useCallback, useEffect, useRef } from 'react';\n\ninterface InitSize {\n initWidth: number;\n initHeight: number;\n}\n\nexport type NodeStyleGetter = (\n type: 'up' | 'down' | 'init',\n horizontal: boolean\n) => CSSProperties;\n\nconst useGetNodeStyle = (size: InitSize | null): NodeStyleGetter => {\n const sizeRef = useRef(size);\n\n useEffect(() => {\n sizeRef.current = size;\n }, [size]);\n\n return useCallback<NodeStyleGetter>((type, horizontal) => {\n if (type === 'init' || !sizeRef.current) return {};\n\n const translateFn = horizontal ? 'translateX' : 'translateY';\n const sizeProp = horizontal ? 'initWidth' : 'initHeight';\n const sign = type === 'down' ? 1 : -1;\n\n const style: CSSProperties = {};\n style.transform = `${translateFn}(${sign * sizeRef.current[sizeProp]}px)`;\n\n return style;\n }, []);\n};\n\nexport default useGetNodeStyle;\n"],"mappings":"AAAA,SAAwBA,WAAW,EAAEC,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAYrE,MAAMC,eAAe,GAAIC,IAAqB,IAAsB;EAClE,MAAMC,OAAO,GAAGH,MAAM,CAACE,IAAI,CAAC;EAE5BH,SAAS,CAAC,MAAM;IACdI,OAAO,CAACC,OAAO,GAAGF,IAAI;EACxB,CAAC,EAAE,CAACA,IAAI,CAAC,CAAC;EAEV,OAAOJ,WAAW,CAAkB,CAACO,IAAI,EAAEC,UAAU,KAAK;IACxD,IAAID,IAAI,KAAK,MAAM,IAAI,CAACF,OAAO,CAACC,OAAO,EAAE,OAAO,CAAC,CAAC;IAElD,MAAMG,WAAW,GAAGD,UAAU,GAAG,YAAY,GAAG,YAAY;IAC5D,MAAME,QAAQ,GAAGF,UAAU,GAAG,WAAW,GAAG,YAAY;IACxD,MAAMG,IAAI,GAAGJ,IAAI,KAAK,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC;IAErC,MAAMK,KAAoB,GAAG,CAAC,CAAC;IAC/BA,KAAK,CAACC,SAAS,GAAI,GAAEJ,WAAY,IAAGE,IAAI,GAAGN,OAAO,CAACC,OAAO,CAACI,QAAQ,CAAE,KAAI;IAEzE,OAAOE,KAAK;EACd,CAAC,EAAE,EAAE,CAAC;AACR,CAAC;AAED,eAAeT,eAAe"}
@@ -1,5 +1,4 @@
1
1
  import { useMemo } from 'react';
2
-
3
2
  const useInitRect = ref => useMemo(() => {
4
3
  if (!ref || !ref.current) return null;
5
4
  const rect = ref.current.getBoundingClientRect();
@@ -10,6 +9,5 @@ const useInitRect = ref => useMemo(() => {
10
9
  initHeight: rect.height
11
10
  };
12
11
  }, [ref]);
13
-
14
12
  export default useInitRect;
15
13
  //# sourceMappingURL=useInitRect.js.map
@@ -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,OAApB,QAAmC,OAAnC;;AAEA,MAAMC,WAAW,GAAIC,GAAD,IAClBF,OAAO,CAAC,MAAM;EACZ,IAAI,CAACE,GAAD,IAAQ,CAACA,GAAG,CAACC,OAAjB,EAA0B,OAAO,IAAP;EAE1B,MAAMC,IAAI,GAAGF,GAAG,CAACC,OAAJ,CAAYE,qBAAZ,EAAb;EAEA,OAAO;IACLC,KAAK,EAAEF,IAAI,CAACG,CADP;IAELC,KAAK,EAAEJ,IAAI,CAACK,CAFP;IAGLC,SAAS,EAAEN,IAAI,CAACO,KAHX;IAILC,UAAU,EAAER,IAAI,CAACS;EAJZ,CAAP;AAMD,CAXM,EAWJ,CAACX,GAAD,CAXI,CADT;;AAcA,eAAeD,WAAf"}
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,EAAE;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,6 +1,5 @@
1
1
  import { useMemo } from 'react';
2
2
  import getElementScroll from './getElementScroll';
3
-
4
3
  const useInitScrollOffset = ref => useMemo(() => {
5
4
  if (!ref || !ref.current) return null;
6
5
  const scrollOffset = getElementScroll(ref.current);
@@ -9,6 +8,5 @@ const useInitScrollOffset = ref => useMemo(() => {
9
8
  initScrollTop: scrollOffset.scrollTop
10
9
  };
11
10
  }, [ref]);
12
-
13
11
  export default useInitScrollOffset;
14
12
  //# sourceMappingURL=useInitScrollOffset.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useInitScrollOffset.js","names":["useMemo","getElementScroll","useInitScrollOffset","ref","current","scrollOffset","initScrollLeft","scrollLeft","initScrollTop","scrollTop"],"sources":["../../../src/utils/useInitScrollOffset.ts"],"sourcesContent":["import { RefObject, useMemo } from 'react';\nimport getElementScroll from './getElementScroll';\n\nconst useInitScrollOffset = (ref?: RefObject<HTMLElement>) =>\n useMemo(() => {\n if (!ref || !ref.current) return null;\n\n const scrollOffset = getElementScroll(ref.current);\n\n return {\n initScrollLeft: scrollOffset.scrollLeft,\n initScrollTop: scrollOffset.scrollTop,\n };\n }, [ref]);\n\nexport default useInitScrollOffset;\n"],"mappings":"AAAA,SAAoBA,OAApB,QAAmC,OAAnC;AACA,OAAOC,gBAAP,MAA6B,oBAA7B;;AAEA,MAAMC,mBAAmB,GAAIC,GAAD,IAC1BH,OAAO,CAAC,MAAM;EACZ,IAAI,CAACG,GAAD,IAAQ,CAACA,GAAG,CAACC,OAAjB,EAA0B,OAAO,IAAP;EAE1B,MAAMC,YAAY,GAAGJ,gBAAgB,CAACE,GAAG,CAACC,OAAL,CAArC;EAEA,OAAO;IACLE,cAAc,EAAED,YAAY,CAACE,UADxB;IAELC,aAAa,EAAEH,YAAY,CAACI;EAFvB,CAAP;AAID,CATM,EASJ,CAACN,GAAD,CATI,CADT;;AAYA,eAAeD,mBAAf"}
1
+ {"version":3,"file":"useInitScrollOffset.js","names":["useMemo","getElementScroll","useInitScrollOffset","ref","current","scrollOffset","initScrollLeft","scrollLeft","initScrollTop","scrollTop"],"sources":["../../../src/utils/useInitScrollOffset.ts"],"sourcesContent":["import { RefObject, useMemo } from 'react';\nimport getElementScroll from './getElementScroll';\n\nconst useInitScrollOffset = (ref?: RefObject<HTMLElement>) =>\n useMemo(() => {\n if (!ref || !ref.current) return null;\n\n const scrollOffset = getElementScroll(ref.current);\n\n return {\n initScrollLeft: scrollOffset.scrollLeft,\n initScrollTop: scrollOffset.scrollTop,\n };\n }, [ref]);\n\nexport default useInitScrollOffset;\n"],"mappings":"AAAA,SAAoBA,OAAO,QAAQ,OAAO;AAC1C,OAAOC,gBAAgB,MAAM,oBAAoB;AAEjD,MAAMC,mBAAmB,GAAIC,GAA4B,IACvDH,OAAO,CAAC,MAAM;EACZ,IAAI,CAACG,GAAG,IAAI,CAACA,GAAG,CAACC,OAAO,EAAE,OAAO,IAAI;EAErC,MAAMC,YAAY,GAAGJ,gBAAgB,CAACE,GAAG,CAACC,OAAO,CAAC;EAElD,OAAO;IACLE,cAAc,EAAED,YAAY,CAACE,UAAU;IACvCC,aAAa,EAAEH,YAAY,CAACI;EAC9B,CAAC;AACH,CAAC,EAAE,CAACN,GAAG,CAAC,CAAC;AAEX,eAAeD,mBAAmB"}