@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
@@ -1,4 +1,5 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any,no-param-reassign,prefer-destructuring,no-constant-condition */
2
+
2
3
  // [prev, next, ref, setStyle, index, id]
3
4
 
4
5
  /**
@@ -38,6 +39,7 @@ class NodeList {
38
39
  /**
39
40
  * Listeners of node addition events.
40
41
  */
42
+
41
43
  constructor(props) {
42
44
  this.id = void 0;
43
45
  this.ref = void 0;
@@ -56,98 +58,87 @@ class NodeList {
56
58
  this.tail = null;
57
59
  this.listeners = [];
58
60
  }
59
-
60
61
  getHead() {
61
62
  return this.head;
62
63
  }
63
-
64
64
  getTail() {
65
65
  return this.tail;
66
66
  }
67
+
67
68
  /**
68
69
  * Adds the node to the beginning.
69
70
  * TL: O(1).
70
71
  */
71
-
72
-
73
72
  addToTheBeginning(props) {
74
73
  this.head = [null, this.head, props.ref, props.setStyle, props.index, props.id];
75
74
  const [, next] = this.head;
76
75
  if (next) next[0] = this.head; // Set the prev cursor of the next element
77
-
78
76
  if (!this.tail) this.tail = this.head;
79
77
  return this.head;
80
78
  }
79
+
81
80
  /**
82
81
  * Adds the node to the end.
83
82
  * TL: O(1).
84
83
  */
85
-
86
-
87
84
  addToTheEnd(props) {
88
85
  this.tail = [this.tail, null, props.ref, props.setStyle, props.index, props.id];
89
86
  const [prev] = this.tail;
90
87
  if (prev) prev[1] = this.tail; // Set the next cursor of the prev element
91
-
92
88
  if (!this.head) this.head = this.tail;
93
89
  return this.tail;
94
90
  }
91
+
95
92
  /**
96
93
  * Adds the node after the specified one.
97
94
  * TL: O(1).
98
95
  */
99
-
100
-
101
96
  static addAfter(node, props) {
102
97
  node[1] = [node, node[1], props.ref, props.setStyle, props.index, props.id];
103
98
  if (node[1][1]) node[1][1][0] = node[1];
104
99
  return node[1];
105
100
  }
101
+
106
102
  /**
107
103
  * Adds a new node depends on its position.
108
104
  * Called when a new node is mounted.
109
105
  * TL: O(1) – add to the beginning or to the end, O(n) – add to the middle.
110
106
  */
111
-
112
-
113
107
  add(props) {
114
108
  const {
115
109
  index
116
- } = props; // Run listeners
110
+ } = props;
117
111
 
118
- this.listeners.forEach(listener => listener(props)); // Add the first node to the beginning
112
+ // Run listeners
113
+ this.listeners.forEach(listener => listener(props));
119
114
 
115
+ // Add the first node to the beginning
120
116
  if (!this.head || !this.tail) {
121
117
  return this.addToTheBeginning(props);
122
- } // Add the node to the beginning if it is located above the first one
123
-
118
+ }
124
119
 
120
+ // Add the node to the beginning if it is located above the first one
125
121
  const [,,,, headIndex] = this.head;
126
-
127
122
  if (index < headIndex) {
128
123
  return this.addToTheBeginning(props);
129
- } // Add the node to the end if it is located below the last one
130
-
124
+ }
131
125
 
126
+ // Add the node to the end if it is located below the last one
132
127
  const [,,,, tailIndex] = this.tail;
133
-
134
128
  if (index === tailIndex) {
135
129
  // The tail is the blank node
136
130
  const [prev] = this.tail;
137
-
138
131
  if (prev) {
139
132
  this.tail[4] += 1;
140
133
  return NodeList.addAfter(prev, props);
141
134
  }
142
135
  }
143
-
144
136
  if (index > tailIndex) {
145
137
  return this.addToTheEnd(props);
146
- } // Add the node after the one that is located above the current one
147
-
138
+ }
148
139
 
140
+ // Add the node after the one that is located above the current one
149
141
  let node = this.head;
150
-
151
142
  while (true) {
152
143
  const [, next] = node;
153
144
  if (!next) break;
@@ -155,53 +146,43 @@ class NodeList {
155
146
  if (index < nextIndex) break;
156
147
  node = next;
157
148
  }
158
-
159
149
  return NodeList.addAfter(node, props);
160
150
  }
151
+
161
152
  /**
162
153
  * Removes the existing node.
163
154
  * Called when the node is unmounted.
164
155
  * TL: O(1).
165
156
  */
166
-
167
-
168
157
  remove(node) {
169
158
  const [prev, next] = node;
170
-
171
159
  if (!prev && !next) {
172
160
  this.head = null;
173
161
  this.tail = null;
174
162
  return;
175
163
  }
176
-
177
164
  if (!prev && next) {
178
165
  next[0] = null;
179
166
  this.head = next;
180
167
  return;
181
168
  }
182
-
183
169
  if (prev && !next) {
184
170
  prev[1] = null;
185
171
  this.tail = prev;
186
172
  return;
187
173
  }
188
-
189
174
  if (prev && next) {
190
175
  prev[1] = next;
191
176
  next[0] = prev;
192
177
  }
193
178
  }
194
-
195
179
  addListener(callback) {
196
180
  this.listeners.push(callback);
197
181
  }
198
-
199
182
  removeListener(callback) {
200
183
  const index = this.listeners.findIndex(listener => listener === callback);
201
184
  this.listeners.splice(index, 1);
202
185
  }
203
-
204
186
  }
205
-
206
187
  export default NodeList;
207
188
  //# sourceMappingURL=NodeList.js.map
@@ -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,QAAN,CAAe;EACb;AACF;AACA;;EAGE;AACF;AACA;;EAGE;AACF;AACA;AACA;;EAGE;AACF;AACA;;EAGE;AACF;AACA;;EAGE;AACF;AACA;;EAGE;AACF;AACA;;EAGE;AACF;AACA;EAGSC,WAAW,CAACC,KAAD,EAAmB;IAAA,KAtC9BC,EAsC8B;IAAA,KAjC9BC,GAiC8B;IAAA,KA3B9BC,QA2B8B;IAAA,KAtB9BC,UAsB8B;IAAA,KAjB9BC,iBAiB8B;IAAA,KAZ7BC,IAY6B;IAAA,KAP7BC,IAO6B;IAAA,KAF7BC,SAE6B;IACnC,KAAKP,EAAL,GAAUD,KAAK,CAACC,EAAhB;IACA,KAAKC,GAAL,GAAWF,KAAK,CAACE,GAAjB;IACA,KAAKC,QAAL,GAAgBH,KAAK,CAACG,QAAtB;IACA,KAAKC,UAAL,GAAkBJ,KAAK,CAACI,UAAxB;IACA,KAAKC,iBAAL,GAAyBL,KAAK,CAACK,iBAA/B;IACA,KAAKC,IAAL,GAAY,IAAZ;IACA,KAAKC,IAAL,GAAY,IAAZ;IACA,KAAKC,SAAL,GAAiB,EAAjB;EACD;;EAEMC,OAAO,GAAG;IACf,OAAO,KAAKH,IAAZ;EACD;;EAEMI,OAAO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,SAAT,IAAsBV,IAA5B;MACA,IAAID,KAAK,GAAGW,SAAZ,EAAuB;MACvBN,IAAI,GAAGJ,IAAP;IACD;;IACD,OAAOhB,QAAQ,CAACmB,QAAT,CAAkBC,IAAlB,EAAwBlB,KAAxB,CAAP;EACD;EAED;AACF;AACA;AACA;AACA;;;EACSyB,MAAM,CAACP,IAAD,EAAqB;IAChC,MAAM,CAACF,IAAD,EAAOF,IAAP,IAAeI,IAArB;;IACA,IAAI,CAACF,IAAD,IAAS,CAACF,IAAd,EAAoB;MAClB,KAAKR,IAAL,GAAY,IAAZ;MACA,KAAKC,IAAL,GAAY,IAAZ;MACA;IACD;;IACD,IAAI,CAACS,IAAD,IAASF,IAAb,EAAmB;MACjBA,IAAI,CAAC,CAAD,CAAJ,GAAU,IAAV;MACA,KAAKR,IAAL,GAAYQ,IAAZ;MACA;IACD;;IACD,IAAIE,IAAI,IAAI,CAACF,IAAb,EAAmB;MACjBE,IAAI,CAAC,CAAD,CAAJ,GAAU,IAAV;MACA,KAAKT,IAAL,GAAYS,IAAZ;MACA;IACD;;IACD,IAAIA,IAAI,IAAIF,IAAZ,EAAkB;MAChBE,IAAI,CAAC,CAAD,CAAJ,GAAUF,IAAV;MACAA,IAAI,CAAC,CAAD,CAAJ,GAAUE,IAAV;IACD;EACF;;EAEMU,WAAW,CAACC,QAAD,EAAuC;IACvD,KAAKnB,SAAL,CAAeoB,IAAf,CAAoBD,QAApB;EACD;;EAEME,cAAc,CAACF,QAAD,EAAuC;IAC1D,MAAMd,KAAK,GAAG,KAAKL,SAAL,CAAesB,SAAf,CAA0BT,QAAD,IAAcA,QAAQ,KAAKM,QAApD,CAAd;IACA,KAAKnB,SAAL,CAAeuB,MAAf,CAAsBlB,KAAtB,EAA6B,CAA7B;EACD;;AAhMY;;AAmMf,eAAef,QAAf"}
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;AACF;AACA;;EAGE;AACF;AACA;;EAGE;AACF;AACA;;EAGE;AACF;AACA;;EAGSC,WAAW,CAACC,KAAgB,EAAE;IAAA,KAtC9BC,EAAE;IAAA,KAKFC,GAAG;IAAA,KAMHC,QAAQ;IAAA,KAKRC,UAAU;IAAA,KAKVC,iBAAiB;IAAA,KAKhBC,IAAI;IAAA,KAKJC,IAAI;IAAA,KAKJC,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,I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,IAAKA,QAAQ,KAAKM,QAAQ,CAAC;IAC3E,IAAI,CAACnB,SAAS,CAACuB,MAAM,CAAClB,KAAK,EAAE,CAAC,CAAC;EACjC;AACF;AAEA,eAAef,QAAQ"}
@@ -2,18 +2,15 @@ const getElementOffset = element => {
2
2
  let offsetLeft = 0;
3
3
  let offsetTop = 0;
4
4
  let el = element;
5
-
6
5
  while (el) {
7
6
  offsetLeft += el.offsetLeft;
8
7
  offsetTop += el.offsetTop;
9
8
  el = el.offsetParent;
10
9
  }
11
-
12
10
  return {
13
11
  offsetLeft,
14
12
  offsetTop
15
13
  };
16
14
  };
17
-
18
15
  export default getElementOffset;
19
16
  //# sourceMappingURL=getElementOffset.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getElementOffset.js","names":["getElementOffset","element","offsetLeft","offsetTop","el","offsetParent"],"sources":["../../../src/utils/getElementOffset.ts"],"sourcesContent":["const getElementOffset = (element: HTMLElement) => {\n let offsetLeft = 0;\n let offsetTop = 0;\n let el: HTMLElement | null = element;\n while (el) {\n offsetLeft += el.offsetLeft;\n offsetTop += el.offsetTop;\n el = el.offsetParent as HTMLElement;\n }\n return { offsetLeft, offsetTop };\n};\n\nexport default getElementOffset;\n"],"mappings":"AAAA,MAAMA,gBAAgB,GAAIC,OAAD,IAA0B;EACjD,IAAIC,UAAU,GAAG,CAAjB;EACA,IAAIC,SAAS,GAAG,CAAhB;EACA,IAAIC,EAAsB,GAAGH,OAA7B;;EACA,OAAOG,EAAP,EAAW;IACTF,UAAU,IAAIE,EAAE,CAACF,UAAjB;IACAC,SAAS,IAAIC,EAAE,CAACD,SAAhB;IACAC,EAAE,GAAGA,EAAE,CAACC,YAAR;EACD;;EACD,OAAO;IAAEH,UAAF;IAAcC;EAAd,CAAP;AACD,CAVD;;AAYA,eAAeH,gBAAf"}
1
+ {"version":3,"file":"getElementOffset.js","names":["getElementOffset","element","offsetLeft","offsetTop","el","offsetParent"],"sources":["../../../src/utils/getElementOffset.ts"],"sourcesContent":["const getElementOffset = (element: HTMLElement) => {\n let offsetLeft = 0;\n let offsetTop = 0;\n let el: HTMLElement | null = element;\n while (el) {\n offsetLeft += el.offsetLeft;\n offsetTop += el.offsetTop;\n el = el.offsetParent as HTMLElement;\n }\n return { offsetLeft, offsetTop };\n};\n\nexport default getElementOffset;\n"],"mappings":"AAAA,MAAMA,gBAAgB,GAAIC,OAAoB,IAAK;EACjD,IAAIC,UAAU,GAAG,CAAC;EAClB,IAAIC,SAAS,GAAG,CAAC;EACjB,IAAIC,EAAsB,GAAGH,OAAO;EACpC,OAAOG,EAAE,EAAE;IACTF,UAAU,IAAIE,EAAE,CAACF,UAAU;IAC3BC,SAAS,IAAIC,EAAE,CAACD,SAAS;IACzBC,EAAE,GAAGA,EAAE,CAACC,YAA2B;EACrC;EACA,OAAO;IAAEH,UAAU;IAAEC;EAAU,CAAC;AAClC,CAAC;AAED,eAAeH,gBAAgB"}
@@ -2,18 +2,15 @@ const getElementScroll = element => {
2
2
  let scrollLeft = 0;
3
3
  let scrollTop = 0;
4
4
  let el = element;
5
-
6
5
  while (el) {
7
6
  scrollLeft += el.scrollLeft;
8
7
  scrollTop += el.scrollTop;
9
8
  el = el.parentElement;
10
9
  }
11
-
12
10
  return {
13
11
  scrollLeft,
14
12
  scrollTop
15
13
  };
16
14
  };
17
-
18
15
  export default getElementScroll;
19
16
  //# sourceMappingURL=getElementScroll.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getElementScroll.js","names":["getElementScroll","element","scrollLeft","scrollTop","el","parentElement"],"sources":["../../../src/utils/getElementScroll.ts"],"sourcesContent":["const getElementScroll = (element: HTMLElement) => {\n let scrollLeft = 0;\n let scrollTop = 0;\n let el: HTMLElement | null = element;\n while (el) {\n scrollLeft += el.scrollLeft;\n scrollTop += el.scrollTop;\n el = el.parentElement;\n }\n return { scrollLeft, scrollTop };\n};\n\nexport default getElementScroll;\n"],"mappings":"AAAA,MAAMA,gBAAgB,GAAIC,OAAD,IAA0B;EACjD,IAAIC,UAAU,GAAG,CAAjB;EACA,IAAIC,SAAS,GAAG,CAAhB;EACA,IAAIC,EAAsB,GAAGH,OAA7B;;EACA,OAAOG,EAAP,EAAW;IACTF,UAAU,IAAIE,EAAE,CAACF,UAAjB;IACAC,SAAS,IAAIC,EAAE,CAACD,SAAhB;IACAC,EAAE,GAAGA,EAAE,CAACC,aAAR;EACD;;EACD,OAAO;IAAEH,UAAF;IAAcC;EAAd,CAAP;AACD,CAVD;;AAYA,eAAeH,gBAAf"}
1
+ {"version":3,"file":"getElementScroll.js","names":["getElementScroll","element","scrollLeft","scrollTop","el","parentElement"],"sources":["../../../src/utils/getElementScroll.ts"],"sourcesContent":["const getElementScroll = (element: HTMLElement) => {\n let scrollLeft = 0;\n let scrollTop = 0;\n let el: HTMLElement | null = element;\n while (el) {\n scrollLeft += el.scrollLeft;\n scrollTop += el.scrollTop;\n el = el.parentElement;\n }\n return { scrollLeft, scrollTop };\n};\n\nexport default getElementScroll;\n"],"mappings":"AAAA,MAAMA,gBAAgB,GAAIC,OAAoB,IAAK;EACjD,IAAIC,UAAU,GAAG,CAAC;EAClB,IAAIC,SAAS,GAAG,CAAC;EACjB,IAAIC,EAAsB,GAAGH,OAAO;EACpC,OAAOG,EAAE,EAAE;IACTF,UAAU,IAAIE,EAAE,CAACF,UAAU;IAC3BC,SAAS,IAAIC,EAAE,CAACD,SAAS;IACzBC,EAAE,GAAGA,EAAE,CAACC,aAAa;EACvB;EACA,OAAO;IAAEH,UAAU;IAAEC;EAAU,CAAC;AAClC,CAAC;AAED,eAAeH,gBAAgB"}
@@ -1,9 +1,9 @@
1
1
  import getElementScroll from './getElementScroll';
2
2
  import getElementOffset from './getElementOffset';
3
+
3
4
  /**
4
5
  * Computes the bounds of the existing node without considering transforms.
5
6
  */
6
-
7
7
  const getNodeRect = ref => {
8
8
  if (!ref.current) return null;
9
9
  const parent = ref.current.parentElement;
@@ -31,6 +31,5 @@ const getNodeRect = ref => {
31
31
  bottom: top + height
32
32
  };
33
33
  };
34
-
35
34
  export default getNodeRect;
36
35
  //# sourceMappingURL=getNodeRect.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getNodeRect.js","names":["getElementScroll","getElementOffset","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 getElementScroll from './getElementScroll';\nimport getElementOffset from './getElementOffset';\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,gBAAP,MAA6B,oBAA7B;AACA,OAAOC,gBAAP,MAA6B,oBAA7B;AAEA;AACA;AACA;;AACA,MAAMC,WAAW,GAAIC,GAAD,IAAiC;EACnD,IAAI,CAACA,GAAG,CAACC,OAAT,EAAkB,OAAO,IAAP;EAElB,MAAMC,MAAM,GAAGF,GAAG,CAACC,OAAJ,CAAYE,aAA3B;EACA,MAAM;IAAEC,KAAF;IAASC;EAAT,IAAoBL,GAAG,CAACC,OAAJ,CAAYK,qBAAZ,EAA1B;EACA,MAAM;IAAEC,UAAF;IAAcC;EAAd,IAA4BV,gBAAgB,CAACE,GAAG,CAACC,OAAL,CAAlD;EACA,MAAM;IAAEQ,UAAF;IAAcC;EAAd,IAA4BR,MAAM,GACpCL,gBAAgB,CAACK,MAAD,CADoB,GAEpC;IAAEO,UAAU,EAAE,CAAd;IAAiBC,SAAS,EAAE;EAA5B,CAFJ;EAIA,MAAMC,IAAI,GAAGJ,UAAU,GAAGE,UAA1B;EACA,MAAMG,GAAG,GAAGJ,SAAS,GAAGE,SAAxB;EAEA,OAAO;IACLC,IADK;IAELC,GAFK;IAGLC,KAAK,EAAEF,IAAI,GAAGP,KAHT;IAILU,MAAM,EAAEF,GAAG,GAAGP;EAJT,CAAP;AAMD,CAnBD;;AAqBA,eAAeN,WAAf"}
1
+ {"version":3,"file":"getNodeRect.js","names":["getElementScroll","getElementOffset","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 getElementScroll from './getElementScroll';\nimport getElementOffset from './getElementOffset';\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,EAAE;EAC7D,MAAM;IAAEC,UAAU;IAAEC;EAAU,CAAC,GAAGV,gBAAgB,CAACE,GAAG,CAACC,OAAO,CAAC;EAC/D,MAAM;IAAEQ,UAAU;IAAEC;EAAU,CAAC,GAAGR,MAAM,GACpCL,gBAAgB,CAACK,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,8 +1,8 @@
1
1
  import { useEffect } from 'react';
2
+
2
3
  /**
3
4
  * Adds a new class name to the element.
4
5
  */
5
-
6
6
  const useAppendClassName = (ref, className) => {
7
7
  useEffect(() => {
8
8
  const element = ref.current;
@@ -14,6 +14,5 @@ const useAppendClassName = (ref, className) => {
14
14
  };
15
15
  }, [className, ref]);
16
16
  };
17
-
18
17
  export default useAppendClassName;
19
18
  //# sourceMappingURL=useAppendClassName.js.map
@@ -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,SAApB,QAAqC,OAArC;AAEA;AACA;AACA;;AACA,MAAMC,kBAAkB,GAAG,CAACC,GAAD,EAA8BC,SAA9B,KAAoD;EAC7EH,SAAS,CAAC,MAAM;IACd,MAAMI,OAAO,GAAGF,GAAG,CAACG,OAApB;IACA,IAAI,CAACD,OAAL,EAAc,OAAO,MAAM,CAAE,CAAf;IAEd,MAAME,aAAa,GAAGF,OAAO,CAACD,SAA9B;IACAC,OAAO,CAACD,SAAR,GAAqB,GAAEG,aAAc,IAAGH,SAAU,EAA9B,CAAgCI,IAAhC,EAApB;IAEA,OAAO,MAAM;MACXH,OAAO,CAACD,SAAR,GAAoBG,aAApB;IACD,CAFD;EAGD,CAVQ,EAUN,CAACH,SAAD,EAAYD,GAAZ,CAVM,CAAT;AAWD,CAZD;;AAcA,eAAeD,kBAAf"}
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,GAAG,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,EAAE;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,5 +1,4 @@
1
1
  import { useCallback, useEffect, useRef } from 'react';
2
-
3
2
  /**
4
3
  * Appends the blank node to the list to increase the height of it.
5
4
  * Used when the dragged node is located inside another list.
@@ -18,9 +17,9 @@ const useBlankNode = props => {
18
17
  useEffect(() => {
19
18
  if (!draggedNode || !targetList || !targetList.ref.current || draggedNode.list === targetList || !initDraggedNodeRectRef.current) {
20
19
  return;
21
- } // Create a new blank div
22
-
20
+ }
23
21
 
22
+ // Create a new blank div
24
23
  const {
25
24
  initWidth,
26
25
  initHeight
@@ -31,8 +30,9 @@ const useBlankNode = props => {
31
30
  div.style.minWidth = `${initWidth}px`;
32
31
  div.style.minHeight = `${initHeight}px`;
33
32
  let parent = targetList.ref.current;
34
- const innerList = targetList.innerRef.current; // The inner ref used only in the virtual list
33
+ const innerList = targetList.innerRef.current;
35
34
 
35
+ // The inner ref used only in the virtual list
36
36
  if (innerList) {
37
37
  const {
38
38
  width,
@@ -42,11 +42,12 @@ const useBlankNode = props => {
42
42
  div.style.left = targetList.horizontal ? `${width}px` : '0px';
43
43
  div.style.top = targetList.horizontal ? '0px' : `${height}px`;
44
44
  parent = innerList;
45
- } // Append the blank div to increase the height of the list
45
+ }
46
46
 
47
+ // Append the blank div to increase the height of the list
48
+ parent.appendChild(div);
47
49
 
48
- parent.appendChild(div); // Add the blank node to the node list
49
-
50
+ // Add the blank node to the node list
50
51
  const tail = targetList.getTail();
51
52
  blankNode.current = {
52
53
  list: targetList,
@@ -69,14 +70,14 @@ const useBlankNode = props => {
69
70
  if (!blank.list.ref.current || !blankNodeRef.current) return;
70
71
  const parent = blankNodeRef.current.parentElement;
71
72
  if (parent) parent.removeChild(blankNodeRef.current);
72
- }, []); // Remove the blank node if the dragged node has been dropped
73
+ }, []);
73
74
 
75
+ // Remove the blank node if the dragged node has been dropped
74
76
  useEffect(() => {
75
77
  if (!draggedNode) return () => {};
76
78
  return () => removeBlankNode();
77
79
  }, [draggedNode, removeBlankNode]);
78
80
  return removeBlankNode;
79
81
  };
80
-
81
82
  export default useBlankNode;
82
83
  //# sourceMappingURL=useBlankNode.js.map
@@ -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,WAAT,EAAsBC,SAAtB,EAAiCC,MAAjC,QAA+C,OAA/C;;AAuBA;AACA;AACA;AACA;AACA,MAAMC,YAAY,GAAIC,KAAD,IAA8B;EACjD,MAAM;IAAEC,WAAF;IAAeC,UAAf;IAA2BC;EAA3B,IAAmDH,KAAzD;EACA,MAAMI,sBAAsB,GAAGN,MAAM,CAACK,mBAAD,CAArC;EACA,MAAME,SAAS,GAAGP,MAAM,CAAmB,IAAnB,CAAxB;EAEAD,SAAS,CAAC,MAAM;IACdO,sBAAsB,CAACE,OAAvB,GAAiCH,mBAAjC;EACD,CAFQ,EAEN,CAACA,mBAAD,CAFM,CAAT;EAIAN,SAAS,CAAC,MAAM;IACd,IACE,CAACI,WAAD,IACA,CAACC,UADD,IAEA,CAACA,UAAU,CAACK,GA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N,UADY;MAElB4B,IAAI,EAAE5B,UAAU,CAAC6B,GAAX,CAAe;QACnBxB,GAAG,EAAE;UAAED,OAAO,EAAEK;QAAX,CADc;QAEnBqB,QAAQ,EAAE,MAAM,CAAE,CAFC;QAGnBC,KAAK,EAAEL,IAAI,GAAGA,IAAI,CAAC,CAAD,CAAJ,GAAU,CAAb,GAAiB,CAHT;QAInBM,EAAE,EAAE;MAJe,CAAf;IAFY,CAApB;EASD,CA7CQ,EA6CN,CAACjC,WAAD,EAAcC,UAAd,CA7CM,CAAT;EA+CA,MAAMiC,eAAe,GAAGvC,WAAW,CAAC,MAAM;IACxC,MAAMwC,KAAK,GAAG/B,SAAS,CAACC,OAAxB;IACA,IAAI,CAAC8B,KAAL,EAAY;IACZ/B,SAAS,CAACC,OAAV,GAAoB,IAApB;IACA8B,KAAK,CAAC5B,IAAN,CAAW6B,MAAX,CAAkBD,KAAK,CAACN,IAAxB;IACA,MAAM,IAAKQ,YAAL,IAAqBF,KAAK,CAACN,IAAjC;IACA,IAAI,CAACM,KAAK,CAAC5B,IAAN,CAAWD,GAAX,CAAeD,OAAhB,IAA2B,CAACgC,YAAY,CAAChC,OAA7C,EAAsD;IACtD,MAAMa,MAAM,GAAGmB,YAAY,CAAChC,OAAb,CAAqBiC,aAApC;IACA,IAAIpB,MAAJ,EAAYA,MAAM,CAACqB,WAAP,CAAmBF,YAAY,CAAChC,OAAhC;EACb,CATkC,EAShC,EATgC,CAAnC,CAxDiD,CAmEjD;;EACAT,SAAS,CAAC,MAAM;IACd,IAAI,CAACI,WAAL,EAAkB,OAAO,MAAM,CAAE,CAAf;IAClB,OAAO,MAAMkC,eAAe,EAA5B;EACD,CAHQ,EAGN,CAAClC,WAAD,EAAckC,eAAd,CAHM,CAAT;EAKA,OAAOA,eAAP;AACD,CA1ED;;AA4EA,eAAepC,YAAf"}
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,QA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;IACH,CAAC;EACH,CAAC,EAAE,CAACjC,WAAW,EAAEC,UAAU,CAAC,CAAC;EAE7B,MAAMiC,eAAe,GAAGvC,WAAW,CAAC,MAAM;IACxC,MAAMwC,KAAK,GAAG/B,SAAS,CAACC,OAAO;IAC/B,IAAI,CAAC8B,KAAK,EAAE;IACZ/B,SAAS,CAACC,OAAO,GAAG,IAAI;IACxB8B,KAAK,CAAC5B,IAAI,CAAC6B,MAAM,CAACD,KAAK,CAACN,IAAI,CAAC;IAC7B,MAAM,IAAKQ,YAAY,CAAC,GAAGF,KAAK,CAACN,IAAI;IACrC,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,EAAE;EAChC,CAAC,EAAE,CAAClC,WAAW,EAAEkC,eAAe,CAAC,CAAC;EAElC,OAAOA,eAAe;AACxB,CAAC;AAED,eAAepC,YAAY"}
@@ -6,8 +6,6 @@ export const DragAndDropContext = /*#__PURE__*/React.createContext({
6
6
  onTouchStart: () => {},
7
7
  nodeClassName: ''
8
8
  });
9
-
10
9
  const useDragAndDrop = () => useContext(DragAndDropContext);
11
-
12
10
  export default useDragAndDrop;
13
11
  //# sourceMappingURL=useDragAndDrop.js.map
@@ -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 React, { useContext, MouseEvent, TouchEvent } from 'react';\nimport { Position } from '@os-design/use-drag';\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":"AAAA,OAAOA,KAAP,IAAgBC,UAAhB,QAA0D,OAA1D;AAoBA,OAAO,MAAMC,kBAAkB,gBAAGF,KAAK,CAACG,aAAN,CAA6C;EAC7EC,YAAY,EAAE,MAAM,CAAE,CADuD;EAE7EC,cAAc,EAAE,MAAM,CAAE,CAFqD;EAG7EC,WAAW,EAAE,MAAM,CAAE,CAHwD;EAI7EC,YAAY,EAAE,MAAM,CAAE,CAJuD;EAK7EC,aAAa,EAAE;AAL8D,CAA7C,CAA3B;;AAQP,MAAMC,cAAc,GAAG,MACrBR,UAAU,CAACC,kBAAD,CADZ;;AAGA,eAAeO,cAAf"}
1
+ {"version":3,"file":"useDragAndDrop.js","names":["React","useContext","DragAndDropContext","createContext","registerList","deregisterList","onMouseDown","onTouchStart","nodeClassName","useDragAndDrop"],"sources":["../../../src/utils/useDragAndDrop.ts"],"sourcesContent":["import React, { useContext, MouseEvent, TouchEvent } from 'react';\nimport { Position } from '@os-design/use-drag';\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":"AAAA,OAAOA,KAAK,IAAIC,UAAU,QAAgC,OAAO;AAoBjE,OAAO,MAAMC,kBAAkB,gBAAGF,KAAK,CAACG,aAAa,CAA0B;EAC7EC,YAAY,EAAE,MAAM,CAAC,CAAC;EACtBC,cAAc,EAAE,MAAM,CAAC,CAAC;EACxBC,WAAW,EAAE,MAAM,CAAC,CAAC;EACrBC,YAAY,EAAE,MAAM,CAAC,CAAC;EACtBC,aAAa,EAAE;AACjB,CAAC,CAAC;AAEF,MAAMC,cAAc,GAAG,MACrBR,UAAU,CAACC,kBAAkB,CAAC;AAEhC,eAAeO,cAAc"}