@os-design/drag-sort 1.0.14 → 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.
- package/dist/cjs/DragAndDrop.js +50 -72
- package/dist/cjs/DragAndDrop.js.map +1 -1
- package/dist/cjs/Draggable.js +19 -36
- package/dist/cjs/Draggable.js.map +1 -1
- package/dist/cjs/Droppable.js +24 -33
- package/dist/cjs/Droppable.js.map +1 -1
- package/dist/cjs/index.js +0 -9
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/utils/ListStore.js +4 -13
- package/dist/cjs/utils/ListStore.js.map +1 -1
- package/dist/cjs/utils/NodeList.js +25 -56
- package/dist/cjs/utils/NodeList.js.map +1 -1
- package/dist/cjs/utils/getElementOffset.js +0 -4
- package/dist/cjs/utils/getElementOffset.js.map +1 -1
- package/dist/cjs/utils/getElementScroll.js +0 -4
- package/dist/cjs/utils/getElementScroll.js.map +1 -1
- package/dist/cjs/utils/getNodeRect.js +9 -18
- package/dist/cjs/utils/getNodeRect.js.map +1 -1
- package/dist/cjs/utils/useAppendClassName.js +0 -3
- package/dist/cjs/utils/useAppendClassName.js.map +1 -1
- package/dist/cjs/utils/useBlankNode.js +17 -26
- package/dist/cjs/utils/useBlankNode.js.map +1 -1
- package/dist/cjs/utils/useDragAndDrop.js +0 -8
- package/dist/cjs/utils/useDragAndDrop.js.map +1 -1
- package/dist/cjs/utils/useDragEffect.js +104 -163
- package/dist/cjs/utils/useDragEffect.js.map +1 -1
- package/dist/cjs/utils/useDroppable.js +0 -8
- package/dist/cjs/utils/useDroppable.js.map +1 -1
- package/dist/cjs/utils/useGeneratedId.js +0 -3
- package/dist/cjs/utils/useGeneratedId.js.map +1 -1
- package/dist/cjs/utils/useGetNodeStyle.js +0 -3
- package/dist/cjs/utils/useGetNodeStyle.js.map +1 -1
- package/dist/cjs/utils/useInitRect.js +0 -3
- package/dist/cjs/utils/useInitRect.js.map +1 -1
- package/dist/cjs/utils/useInitScrollOffset.js +0 -5
- package/dist/cjs/utils/useInitScrollOffset.js.map +1 -1
- package/dist/cjs/utils/useMoveNode.js +23 -48
- package/dist/cjs/utils/useMoveNode.js.map +1 -1
- package/dist/cjs/utils/useScrollEventByPoint.js +2 -10
- package/dist/cjs/utils/useScrollEventByPoint.js.map +1 -1
- package/dist/cjs/utils/useTargetList.js +8 -21
- package/dist/cjs/utils/useTargetList.js.map +1 -1
- package/dist/cjs/utils/useTransitionStyle.js +2 -5
- package/dist/cjs/utils/useTransitionStyle.js.map +1 -1
- package/dist/esm/DragAndDrop.js +19 -12
- package/dist/esm/DragAndDrop.js.map +1 -1
- package/dist/esm/Draggable.js +10 -9
- package/dist/esm/Draggable.js.map +1 -1
- package/dist/esm/Droppable.js +17 -14
- package/dist/esm/Droppable.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utils/ListStore.js +3 -8
- package/dist/esm/utils/ListStore.js.map +1 -1
- package/dist/esm/utils/NodeList.js +17 -36
- package/dist/esm/utils/NodeList.js.map +1 -1
- package/dist/esm/utils/getElementOffset.js +0 -3
- package/dist/esm/utils/getElementOffset.js.map +1 -1
- package/dist/esm/utils/getElementScroll.js +0 -3
- package/dist/esm/utils/getElementScroll.js.map +1 -1
- package/dist/esm/utils/getNodeRect.js +1 -2
- package/dist/esm/utils/getNodeRect.js.map +1 -1
- package/dist/esm/utils/useAppendClassName.js +1 -2
- package/dist/esm/utils/useAppendClassName.js.map +1 -1
- package/dist/esm/utils/useBlankNode.js +10 -9
- package/dist/esm/utils/useBlankNode.js.map +1 -1
- package/dist/esm/utils/useDragAndDrop.js +0 -2
- package/dist/esm/utils/useDragAndDrop.js.map +1 -1
- package/dist/esm/utils/useDragEffect.js +57 -60
- package/dist/esm/utils/useDragEffect.js.map +1 -1
- package/dist/esm/utils/useDroppable.js +0 -2
- package/dist/esm/utils/useDroppable.js.map +1 -1
- package/dist/esm/utils/useGeneratedId.js +0 -2
- package/dist/esm/utils/useGeneratedId.js.map +1 -1
- package/dist/esm/utils/useGetNodeStyle.js +0 -2
- package/dist/esm/utils/useGetNodeStyle.js.map +1 -1
- package/dist/esm/utils/useInitRect.js +0 -2
- package/dist/esm/utils/useInitRect.js.map +1 -1
- package/dist/esm/utils/useInitScrollOffset.js +0 -2
- package/dist/esm/utils/useInitScrollOffset.js.map +1 -1
- package/dist/esm/utils/useMoveNode.js +1 -11
- package/dist/esm/utils/useMoveNode.js.map +1 -1
- package/dist/esm/utils/useScrollEventByPoint.js +0 -5
- package/dist/esm/utils/useScrollEventByPoint.js.map +1 -1
- package/dist/esm/utils/useTargetList.js +2 -3
- package/dist/esm/utils/useTargetList.js.map +1 -1
- package/dist/esm/utils/useTransitionStyle.js +0 -2
- package/dist/esm/utils/useTransitionStyle.js.map +1 -1
- package/package.json +11 -11
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["export { default as DragAndDrop } from './DragAndDrop';\nexport { default as Droppable } from './Droppable';\nexport { default as Draggable } from './Draggable';\n\nexport * from './DragAndDrop';\nexport * from './Droppable';\nexport * from './Draggable';\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["export { default as DragAndDrop } from './DragAndDrop';\nexport { default as Droppable } from './Droppable';\nexport { default as Draggable } from './Draggable';\n\nexport * from './DragAndDrop';\nexport * from './Droppable';\nexport * from './Draggable';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAIA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AAHA;AAIA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AAHA;AAIA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AAA4B;AAAA"}
|
|
@@ -4,37 +4,30 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
-
|
|
8
7
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
9
|
-
|
|
10
8
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
11
|
-
|
|
12
9
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
13
|
-
|
|
14
10
|
/**
|
|
15
11
|
* Stores all the lists where the draggable items is located.
|
|
16
|
-
*/
|
|
17
|
-
var ListStore = /*#__PURE__*/function () {
|
|
12
|
+
*/var ListStore = /*#__PURE__*/function () {
|
|
18
13
|
function ListStore() {
|
|
19
14
|
_classCallCheck(this, ListStore);
|
|
20
|
-
|
|
21
15
|
this.lists = void 0;
|
|
22
16
|
this.lists = [];
|
|
23
17
|
}
|
|
18
|
+
|
|
24
19
|
/**
|
|
25
20
|
* Adds a new list to the store.
|
|
26
21
|
*/
|
|
27
|
-
|
|
28
|
-
|
|
29
22
|
_createClass(ListStore, [{
|
|
30
23
|
key: "add",
|
|
31
24
|
value: function add(list) {
|
|
32
25
|
this.lists.push(list);
|
|
33
26
|
}
|
|
27
|
+
|
|
34
28
|
/**
|
|
35
29
|
* Removes the list from the store.
|
|
36
30
|
*/
|
|
37
|
-
|
|
38
31
|
}, {
|
|
39
32
|
key: "remove",
|
|
40
33
|
value: function remove(id) {
|
|
@@ -44,10 +37,10 @@ var ListStore = /*#__PURE__*/function () {
|
|
|
44
37
|
if (index === -1) return;
|
|
45
38
|
this.lists.splice(index, 1);
|
|
46
39
|
}
|
|
40
|
+
|
|
47
41
|
/**
|
|
48
42
|
* Returns the list in which the position is located.
|
|
49
43
|
*/
|
|
50
|
-
|
|
51
44
|
}, {
|
|
52
45
|
key: "findByPosition",
|
|
53
46
|
value: function findByPosition(x, y) {
|
|
@@ -59,10 +52,8 @@ var ListStore = /*#__PURE__*/function () {
|
|
|
59
52
|
});
|
|
60
53
|
}
|
|
61
54
|
}]);
|
|
62
|
-
|
|
63
55
|
return ListStore;
|
|
64
56
|
}();
|
|
65
|
-
|
|
66
57
|
var _default = ListStore;
|
|
67
58
|
exports["default"] = _default;
|
|
68
59
|
//# sourceMappingURL=ListStore.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListStore.js","names":["ListStore","lists","list","push","id","index","findIndex","item","splice","x","y","find","current","ref","rect","getBoundingClientRect","width","height"],"sources":["../../../src/utils/ListStore.ts"],"sourcesContent":["import NodeList from './NodeList';\n\n/**\n * Stores all the lists where the draggable items is located.\n */\nclass ListStore {\n private lists: NodeList[];\n\n public constructor() {\n this.lists = [];\n }\n\n /**\n * Adds a new list to the store.\n */\n public add(list: NodeList) {\n this.lists.push(list);\n }\n\n /**\n * Removes the list from the store.\n */\n public remove(id: string) {\n const index = this.lists.findIndex((item) => item.id === id);\n if (index === -1) return;\n this.lists.splice(index, 1);\n }\n\n /**\n * Returns the list in which the position is located.\n */\n public findByPosition(x: number, y: number) {\n return this.lists.find((list) => {\n const { current } = list.ref;\n if (!current) return false;\n const rect = current.getBoundingClientRect();\n return (\n x >= rect.x &&\n x <= rect.x + rect.width &&\n y >= rect.y &&\n y <= rect.y + rect.height\n );\n });\n }\n}\n\nexport default ListStore;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ListStore.js","names":["ListStore","lists","list","push","id","index","findIndex","item","splice","x","y","find","current","ref","rect","getBoundingClientRect","width","height"],"sources":["../../../src/utils/ListStore.ts"],"sourcesContent":["import NodeList from './NodeList';\n\n/**\n * Stores all the lists where the draggable items is located.\n */\nclass ListStore {\n private lists: NodeList[];\n\n public constructor() {\n this.lists = [];\n }\n\n /**\n * Adds a new list to the store.\n */\n public add(list: NodeList) {\n this.lists.push(list);\n }\n\n /**\n * Removes the list from the store.\n */\n public remove(id: string) {\n const index = this.lists.findIndex((item) => item.id === id);\n if (index === -1) return;\n this.lists.splice(index, 1);\n }\n\n /**\n * Returns the list in which the position is located.\n */\n public findByPosition(x: number, y: number) {\n return this.lists.find((list) => {\n const { current } = list.ref;\n if (!current) return false;\n const rect = current.getBoundingClientRect();\n return (\n x >= rect.x &&\n x <= rect.x + rect.width &&\n y >= rect.y &&\n y <= rect.y + rect.height\n );\n });\n }\n}\n\nexport default ListStore;\n"],"mappings":";;;;;;;;;AAEA;AACA;AACA,GAFA,IAGMA,SAAS;EAGb,qBAAqB;IAAA;IAAA,KAFbC,KAAK;IAGX,IAAI,CAACA,KAAK,GAAG,EAAE;EACjB;;EAEA;AACF;AACA;EAFE;IAAA;IAAA,OAGA,aAAWC,IAAc,EAAE;MACzB,IAAI,CAACD,KAAK,CAACE,IAAI,CAACD,IAAI,CAAC;IACvB;;IAEA;AACF;AACA;EAFE;IAAA;IAAA,OAGA,gBAAcE,EAAU,EAAE;MACxB,IAAMC,KAAK,GAAG,IAAI,CAACJ,KAAK,CAACK,SAAS,CAAC,UAACC,IAAI;QAAA,OAAKA,IAAI,CAACH,EAAE,KAAKA,EAAE;MAAA,EAAC;MAC5D,IAAIC,KAAK,KAAK,CAAC,CAAC,EAAE;MAClB,IAAI,CAACJ,KAAK,CAACO,MAAM,CAACH,KAAK,EAAE,CAAC,CAAC;IAC7B;;IAEA;AACF;AACA;EAFE;IAAA;IAAA,OAGA,wBAAsBI,CAAS,EAAEC,CAAS,EAAE;MAC1C,OAAO,IAAI,CAACT,KAAK,CAACU,IAAI,CAAC,UAACT,IAAI,EAAK;QAC/B,IAAQU,OAAO,GAAKV,IAAI,CAACW,GAAG,CAApBD,OAAO;QACf,IAAI,CAACA,OAAO,EAAE,OAAO,KAAK;QAC1B,IAAME,IAAI,GAAGF,OAAO,CAACG,qBAAqB,EAAE;QAC5C,OACEN,CAAC,IAAIK,IAAI,CAACL,CAAC,IACXA,CAAC,IAAIK,IAAI,CAACL,CAAC,GAAGK,IAAI,CAACE,KAAK,IACxBN,CAAC,IAAII,IAAI,CAACJ,CAAC,IACXA,CAAC,IAAII,IAAI,CAACJ,CAAC,GAAGI,IAAI,CAACG,MAAM;MAE7B,CAAC,CAAC;IACJ;EAAC;EAAA;AAAA;AAAA,eAGYjB,SAAS;AAAA"}
|
|
@@ -4,28 +4,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
-
|
|
8
7
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
9
|
-
|
|
10
8
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
11
|
-
|
|
12
9
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
13
|
-
|
|
14
10
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
15
|
-
|
|
16
11
|
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
17
|
-
|
|
18
12
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
19
|
-
|
|
20
13
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
21
|
-
|
|
22
14
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
23
|
-
|
|
24
15
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
25
|
-
|
|
26
16
|
/* eslint-disable @typescript-eslint/no-explicit-any,no-param-reassign,prefer-destructuring,no-constant-condition */
|
|
27
17
|
// [prev, next, ref, setStyle, index, id]
|
|
28
|
-
|
|
29
18
|
/**
|
|
30
19
|
* Stores all the draggable items in the list.
|
|
31
20
|
* The structure of the doubly linked list is used.
|
|
@@ -63,9 +52,9 @@ var NodeList = /*#__PURE__*/function () {
|
|
|
63
52
|
/**
|
|
64
53
|
* Listeners of node addition events.
|
|
65
54
|
*/
|
|
55
|
+
|
|
66
56
|
function NodeList(props) {
|
|
67
57
|
_classCallCheck(this, NodeList);
|
|
68
|
-
|
|
69
58
|
this.id = void 0;
|
|
70
59
|
this.ref = void 0;
|
|
71
60
|
this.innerRef = void 0;
|
|
@@ -83,7 +72,6 @@ var NodeList = /*#__PURE__*/function () {
|
|
|
83
72
|
this.tail = null;
|
|
84
73
|
this.listeners = [];
|
|
85
74
|
}
|
|
86
|
-
|
|
87
75
|
_createClass(NodeList, [{
|
|
88
76
|
key: "getHead",
|
|
89
77
|
value: function getHead() {
|
|
@@ -94,47 +82,41 @@ var NodeList = /*#__PURE__*/function () {
|
|
|
94
82
|
value: function getTail() {
|
|
95
83
|
return this.tail;
|
|
96
84
|
}
|
|
85
|
+
|
|
97
86
|
/**
|
|
98
87
|
* Adds the node to the beginning.
|
|
99
88
|
* TL: O(1).
|
|
100
89
|
*/
|
|
101
|
-
|
|
102
90
|
}, {
|
|
103
91
|
key: "addToTheBeginning",
|
|
104
92
|
value: function addToTheBeginning(props) {
|
|
105
93
|
this.head = [null, this.head, props.ref, props.setStyle, props.index, props.id];
|
|
106
|
-
|
|
107
94
|
var _this$head = _slicedToArray(this.head, 2),
|
|
108
|
-
|
|
109
|
-
|
|
95
|
+
next = _this$head[1];
|
|
110
96
|
if (next) next[0] = this.head; // Set the prev cursor of the next element
|
|
111
|
-
|
|
112
97
|
if (!this.tail) this.tail = this.head;
|
|
113
98
|
return this.head;
|
|
114
99
|
}
|
|
100
|
+
|
|
115
101
|
/**
|
|
116
102
|
* Adds the node to the end.
|
|
117
103
|
* TL: O(1).
|
|
118
104
|
*/
|
|
119
|
-
|
|
120
105
|
}, {
|
|
121
106
|
key: "addToTheEnd",
|
|
122
107
|
value: function addToTheEnd(props) {
|
|
123
108
|
this.tail = [this.tail, null, props.ref, props.setStyle, props.index, props.id];
|
|
124
|
-
|
|
125
109
|
var _this$tail = _slicedToArray(this.tail, 1),
|
|
126
|
-
|
|
127
|
-
|
|
110
|
+
prev = _this$tail[0];
|
|
128
111
|
if (prev) prev[1] = this.tail; // Set the next cursor of the prev element
|
|
129
|
-
|
|
130
112
|
if (!this.head) this.head = this.tail;
|
|
131
113
|
return this.tail;
|
|
132
114
|
}
|
|
115
|
+
|
|
133
116
|
/**
|
|
134
117
|
* Adds the node after the specified one.
|
|
135
118
|
* TL: O(1).
|
|
136
119
|
*/
|
|
137
|
-
|
|
138
120
|
}, {
|
|
139
121
|
key: "add",
|
|
140
122
|
value:
|
|
@@ -144,93 +126,82 @@ var NodeList = /*#__PURE__*/function () {
|
|
|
144
126
|
* TL: O(1) – add to the beginning or to the end, O(n) – add to the middle.
|
|
145
127
|
*/
|
|
146
128
|
function add(props) {
|
|
147
|
-
var index = props.index;
|
|
129
|
+
var index = props.index;
|
|
148
130
|
|
|
131
|
+
// Run listeners
|
|
149
132
|
this.listeners.forEach(function (listener) {
|
|
150
133
|
return listener(props);
|
|
151
|
-
});
|
|
134
|
+
});
|
|
152
135
|
|
|
136
|
+
// Add the first node to the beginning
|
|
153
137
|
if (!this.head || !this.tail) {
|
|
154
138
|
return this.addToTheBeginning(props);
|
|
155
|
-
}
|
|
156
|
-
|
|
139
|
+
}
|
|
157
140
|
|
|
141
|
+
// Add the node to the beginning if it is located above the first one
|
|
158
142
|
var _this$head2 = _slicedToArray(this.head, 5),
|
|
159
|
-
|
|
160
|
-
|
|
143
|
+
headIndex = _this$head2[4];
|
|
161
144
|
if (index < headIndex) {
|
|
162
145
|
return this.addToTheBeginning(props);
|
|
163
|
-
}
|
|
164
|
-
|
|
146
|
+
}
|
|
165
147
|
|
|
148
|
+
// Add the node to the end if it is located below the last one
|
|
166
149
|
var _this$tail2 = _slicedToArray(this.tail, 5),
|
|
167
|
-
|
|
168
|
-
|
|
150
|
+
tailIndex = _this$tail2[4];
|
|
169
151
|
if (index === tailIndex) {
|
|
170
152
|
// The tail is the blank node
|
|
171
153
|
var _this$tail3 = _slicedToArray(this.tail, 1),
|
|
172
|
-
|
|
173
|
-
|
|
154
|
+
prev = _this$tail3[0];
|
|
174
155
|
if (prev) {
|
|
175
156
|
this.tail[4] += 1;
|
|
176
157
|
return NodeList.addAfter(prev, props);
|
|
177
158
|
}
|
|
178
159
|
}
|
|
179
|
-
|
|
180
160
|
if (index > tailIndex) {
|
|
181
161
|
return this.addToTheEnd(props);
|
|
182
|
-
}
|
|
183
|
-
|
|
162
|
+
}
|
|
184
163
|
|
|
164
|
+
// Add the node after the one that is located above the current one
|
|
185
165
|
var node = this.head;
|
|
186
|
-
|
|
187
166
|
while (true) {
|
|
188
167
|
var _node = node,
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
168
|
+
_node2 = _slicedToArray(_node, 2),
|
|
169
|
+
next = _node2[1];
|
|
192
170
|
if (!next) break;
|
|
193
|
-
|
|
194
171
|
var _next = _slicedToArray(next, 5),
|
|
195
|
-
|
|
196
|
-
|
|
172
|
+
nextIndex = _next[4];
|
|
197
173
|
if (index < nextIndex) break;
|
|
198
174
|
node = next;
|
|
199
175
|
}
|
|
200
|
-
|
|
201
176
|
return NodeList.addAfter(node, props);
|
|
202
177
|
}
|
|
178
|
+
|
|
203
179
|
/**
|
|
204
180
|
* Removes the existing node.
|
|
205
181
|
* Called when the node is unmounted.
|
|
206
182
|
* TL: O(1).
|
|
207
183
|
*/
|
|
208
|
-
|
|
209
184
|
}, {
|
|
210
185
|
key: "remove",
|
|
211
186
|
value: function remove(node) {
|
|
212
187
|
var _node3 = _slicedToArray(node, 2),
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
188
|
+
prev = _node3[0],
|
|
189
|
+
next = _node3[1];
|
|
216
190
|
if (!prev && !next) {
|
|
217
191
|
this.head = null;
|
|
218
192
|
this.tail = null;
|
|
219
193
|
return;
|
|
220
194
|
}
|
|
221
|
-
|
|
222
195
|
if (!prev && next) {
|
|
223
196
|
next[0] = null;
|
|
224
197
|
this.head = next;
|
|
225
198
|
return;
|
|
226
199
|
}
|
|
227
|
-
|
|
228
200
|
if (prev && !next) {
|
|
229
201
|
prev[1] = null;
|
|
230
202
|
this.tail = prev;
|
|
231
203
|
return;
|
|
232
204
|
}
|
|
233
|
-
|
|
234
205
|
if (prev && next) {
|
|
235
206
|
prev[1] = next;
|
|
236
207
|
next[0] = prev;
|
|
@@ -257,10 +228,8 @@ var NodeList = /*#__PURE__*/function () {
|
|
|
257
228
|
return node[1];
|
|
258
229
|
}
|
|
259
230
|
}]);
|
|
260
|
-
|
|
261
231
|
return NodeList;
|
|
262
232
|
}();
|
|
263
|
-
|
|
264
233
|
var _default = NodeList;
|
|
265
234
|
exports["default"] = _default;
|
|
266
235
|
//# sourceMappingURL=NodeList.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeList.js","names":["NodeList","props","id","ref","innerRef","horizontal","renderDraggedNode","head","tail","listeners","setStyle","index","next","prev","forEach","listener","addToTheBeginning","headIndex","tailIndex","addAfter","addToTheEnd","node","nextIndex","callback","push","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;IACMA,Q;EACJ;AACF;AACA;;EAGE;AACF;AACA;;EAGE;AACF;AACA;AACA;;EAGE;AACF;AACA;;EAGE;AACF;AACA;;EAGE;AACF;AACA;;EAGE;AACF;AACA;;EAGE;AACF;AACA;EAGE,kBAAmBC,KAAnB,EAAqC;IAAA;;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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,KAAK,CAACS,QAAjC,EAA2CT,KAAK,CAACU,KAAjD,EAAwDV,KAAK,CAACC,EAA9D,CAAV;MACA,IAAImB,IAAI,CAAC,CAAD,CAAJ,CAAQ,CAAR,CAAJ,EAAgBA,IAAI,CAAC,CAAD,CAAJ,CAAQ,CAAR,EAAW,CAAX,IAAgBA,IAAI,CAAC,CAAD,CAApB;MAChB,OAAOA,IAAI,CAAC,CAAD,CAAX;IACD;;;;;;eAwFYrB,Q"}
|
|
1
|
+
{"version":3,"file":"NodeList.js","names":["NodeList","props","id","ref","innerRef","horizontal","renderDraggedNode","head","tail","listeners","setStyle","index","next","prev","forEach","listener","addToTheBeginning","headIndex","tailIndex","addAfter","addToTheEnd","node","nextIndex","callback","push","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;AAHA,IAIMA,QAAQ;EACZ;AACF;AACA;;EAGE;AACF;AACA;;EAGE;AACF;AACA;AACA;;EAGE;AACF;AACA;;EAGE;AACF;AACA;;EAGE;AACF;AACA;;EAGE;AACF;AACA;;EAGE;AACF;AACA;;EAGE,kBAAmBC,KAAgB,EAAE;IAAA;IAAA,KAtC9BC,EAAE;IAAA,KAKFC,GAAG;IAAA,KAMHC,QAAQ;IAAA,KAKRC,UAAU;IAAA,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AAQ,KAAKQ,QAAQ;MAAA,EAAC;MAC3E,IAAI,CAACd,SAAS,CAACiB,MAAM,CAACf,KAAK,EAAE,CAAC,CAAC;IACjC;EAAC;IAAA;IAAA,OAzFD,kBAAwBU,IAAkB,EAAEpB,KAAgB,EAAgB;MAC1EoB,IAAI,CAAC,CAAC,CAAC,GAAG,CAACA,IAAI,EAAEA,IAAI,CAAC,CAAC,CAAC,EAAEpB,KAAK,CAACE,GAAG,EAAEF,KAAK,CAACS,QAAQ,EAAET,KAAK,CAACU,KAAK,EAAEV,KAAK,CAACC,EAAE,CAAC;MAC3E,IAAImB,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAEA,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAGA,IAAI,CAAC,CAAC,CAAC;MACvC,OAAOA,IAAI,CAAC,CAAC,CAAC;IAChB;EAAC;EAAA;AAAA;AAAA,eAwFYrB,QAAQ;AAAA"}
|
|
@@ -4,24 +4,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
-
|
|
8
7
|
var getElementOffset = function getElementOffset(element) {
|
|
9
8
|
var offsetLeft = 0;
|
|
10
9
|
var offsetTop = 0;
|
|
11
10
|
var el = element;
|
|
12
|
-
|
|
13
11
|
while (el) {
|
|
14
12
|
offsetLeft += el.offsetLeft;
|
|
15
13
|
offsetTop += el.offsetTop;
|
|
16
14
|
el = el.offsetParent;
|
|
17
15
|
}
|
|
18
|
-
|
|
19
16
|
return {
|
|
20
17
|
offsetLeft: offsetLeft,
|
|
21
18
|
offsetTop: offsetTop
|
|
22
19
|
};
|
|
23
20
|
};
|
|
24
|
-
|
|
25
21
|
var _default = getElementOffset;
|
|
26
22
|
exports["default"] = _default;
|
|
27
23
|
//# 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":"
|
|
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,IAAMA,gBAAgB,GAAG,SAAnBA,gBAAgB,CAAIC,OAAoB,EAAK;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,EAAVA,UAAU;IAAEC,SAAS,EAATA;EAAU,CAAC;AAClC,CAAC;AAAC,eAEaH,gBAAgB;AAAA"}
|
|
@@ -4,24 +4,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
-
|
|
8
7
|
var getElementScroll = function getElementScroll(element) {
|
|
9
8
|
var scrollLeft = 0;
|
|
10
9
|
var scrollTop = 0;
|
|
11
10
|
var el = element;
|
|
12
|
-
|
|
13
11
|
while (el) {
|
|
14
12
|
scrollLeft += el.scrollLeft;
|
|
15
13
|
scrollTop += el.scrollTop;
|
|
16
14
|
el = el.parentElement;
|
|
17
15
|
}
|
|
18
|
-
|
|
19
16
|
return {
|
|
20
17
|
scrollLeft: scrollLeft,
|
|
21
18
|
scrollTop: scrollTop
|
|
22
19
|
};
|
|
23
20
|
};
|
|
24
|
-
|
|
25
21
|
var _default = getElementScroll;
|
|
26
22
|
exports["default"] = _default;
|
|
27
23
|
//# 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":"
|
|
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,IAAMA,gBAAgB,GAAG,SAAnBA,gBAAgB,CAAIC,OAAoB,EAAK;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,EAAVA,UAAU;IAAEC,SAAS,EAATA;EAAU,CAAC;AAClC,CAAC;AAAC,eAEaH,gBAAgB;AAAA"}
|
|
@@ -4,35 +4,27 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
-
|
|
8
7
|
var _getElementScroll = _interopRequireDefault(require("./getElementScroll"));
|
|
9
|
-
|
|
10
8
|
var _getElementOffset2 = _interopRequireDefault(require("./getElementOffset"));
|
|
11
|
-
|
|
12
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
|
-
|
|
14
10
|
/**
|
|
15
11
|
* Computes the bounds of the existing node without considering transforms.
|
|
16
12
|
*/
|
|
17
13
|
var getNodeRect = function getNodeRect(ref) {
|
|
18
14
|
if (!ref.current) return null;
|
|
19
15
|
var parent = ref.current.parentElement;
|
|
20
|
-
|
|
21
16
|
var _ref$current$getBound = ref.current.getBoundingClientRect(),
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
width = _ref$current$getBound.width,
|
|
18
|
+
height = _ref$current$getBound.height;
|
|
25
19
|
var _getElementOffset = (0, _getElementOffset2["default"])(ref.current),
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
20
|
+
offsetLeft = _getElementOffset.offsetLeft,
|
|
21
|
+
offsetTop = _getElementOffset.offsetTop;
|
|
29
22
|
var _ref = parent ? (0, _getElementScroll["default"])(parent) : {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
23
|
+
scrollLeft: 0,
|
|
24
|
+
scrollTop: 0
|
|
25
|
+
},
|
|
26
|
+
scrollLeft = _ref.scrollLeft,
|
|
27
|
+
scrollTop = _ref.scrollTop;
|
|
36
28
|
var left = offsetLeft - scrollLeft;
|
|
37
29
|
var top = offsetTop - scrollTop;
|
|
38
30
|
return {
|
|
@@ -42,7 +34,6 @@ var getNodeRect = function getNodeRect(ref) {
|
|
|
42
34
|
bottom: top + height
|
|
43
35
|
};
|
|
44
36
|
};
|
|
45
|
-
|
|
46
37
|
var _default = getNodeRect;
|
|
47
38
|
exports["default"] = _default;
|
|
48
39
|
//# sourceMappingURL=getNodeRect.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getNodeRect.js","names":["getNodeRect","ref","current","parent","parentElement","getBoundingClientRect","width","height","getElementOffset","offsetLeft","offsetTop","getElementScroll","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":"
|
|
1
|
+
{"version":3,"file":"getNodeRect.js","names":["getNodeRect","ref","current","parent","parentElement","getBoundingClientRect","width","height","getElementOffset","offsetLeft","offsetTop","getElementScroll","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;AACA;AAAkD;AAElD;AACA;AACA;AACA,IAAMA,WAAW,GAAG,SAAdA,WAAW,CAAIC,GAA2B,EAAK;EACnD,IAAI,CAACA,GAAG,CAACC,OAAO,EAAE,OAAO,IAAI;EAE7B,IAAMC,MAAM,GAAGF,GAAG,CAACC,OAAO,CAACE,aAAa;EACxC,4BAA0BH,GAAG,CAACC,OAAO,CAACG,qBAAqB,EAAE;IAArDC,KAAK,yBAALA,KAAK;IAAEC,MAAM,yBAANA,MAAM;EACrB,wBAAkC,IAAAC,6BAAgB,EAACP,GAAG,CAACC,OAAO,CAAC;IAAvDO,UAAU,qBAAVA,UAAU;IAAEC,SAAS,qBAATA,SAAS;EAC7B,WAAkCP,MAAM,GACpC,IAAAQ,4BAAgB,EAACR,MAAM,CAAC,GACxB;MAAES,UAAU,EAAE,CAAC;MAAEC,SAAS,EAAE;IAAE,CAAC;IAF3BD,UAAU,QAAVA,UAAU;IAAEC,SAAS,QAATA,SAAS;EAI7B,IAAMC,IAAI,GAAGL,UAAU,GAAGG,UAAU;EACpC,IAAMG,GAAG,GAAGL,SAAS,GAAGG,SAAS;EAEjC,OAAO;IACLC,IAAI,EAAJA,IAAI;IACJC,GAAG,EAAHA,GAAG;IACHC,KAAK,EAAEF,IAAI,GAAGR,KAAK;IACnBW,MAAM,EAAEF,GAAG,GAAGR;EAChB,CAAC;AACH,CAAC;AAAC,eAEaP,WAAW;AAAA"}
|
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
-
|
|
8
7
|
var _react = require("react");
|
|
9
|
-
|
|
10
8
|
/**
|
|
11
9
|
* Adds a new class name to the element.
|
|
12
10
|
*/
|
|
@@ -21,7 +19,6 @@ var useAppendClassName = function useAppendClassName(ref, className) {
|
|
|
21
19
|
};
|
|
22
20
|
}, [className, ref]);
|
|
23
21
|
};
|
|
24
|
-
|
|
25
22
|
var _default = useAppendClassName;
|
|
26
23
|
exports["default"] = _default;
|
|
27
24
|
//# sourceMappingURL=useAppendClassName.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAppendClassName.js","names":["useAppendClassName","ref","className","useEffect","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":"
|
|
1
|
+
{"version":3,"file":"useAppendClassName.js","names":["useAppendClassName","ref","className","useEffect","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;AAEA;AACA;AACA;AACA,IAAMA,kBAAkB,GAAG,SAArBA,kBAAkB,CAAIC,GAA2B,EAAEC,SAAiB,EAAK;EAC7E,IAAAC,gBAAS,EAAC,YAAM;IACd,IAAMC,OAAO,GAAGH,GAAG,CAACI,OAAO;IAC3B,IAAI,CAACD,OAAO,EAAE,OAAO,YAAM,CAAC,CAAC;IAE7B,IAAME,aAAa,GAAGF,OAAO,CAACF,SAAS;IACvCE,OAAO,CAACF,SAAS,GAAG,UAAGI,aAAa,cAAIJ,SAAS,EAAGK,IAAI,EAAE;IAE1D,OAAO,YAAM;MACXH,OAAO,CAACF,SAAS,GAAGI,aAAa;IACnC,CAAC;EACH,CAAC,EAAE,CAACJ,SAAS,EAAED,GAAG,CAAC,CAAC;AACtB,CAAC;AAAC,eAEaD,kBAAkB;AAAA"}
|
|
@@ -4,29 +4,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
-
|
|
8
7
|
var _react = require("react");
|
|
9
|
-
|
|
10
8
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
11
|
-
|
|
12
9
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
13
|
-
|
|
14
10
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
15
|
-
|
|
16
11
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
17
|
-
|
|
18
12
|
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
19
|
-
|
|
20
13
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
21
|
-
|
|
22
14
|
/**
|
|
23
15
|
* Appends the blank node to the list to increase the height of it.
|
|
24
16
|
* Used when the dragged node is located inside another list.
|
|
25
17
|
*/
|
|
26
18
|
var useBlankNode = function useBlankNode(props) {
|
|
27
19
|
var draggedNode = props.draggedNode,
|
|
28
|
-
|
|
29
|
-
|
|
20
|
+
targetList = props.targetList,
|
|
21
|
+
initDraggedNodeRect = props.initDraggedNodeRect;
|
|
30
22
|
var initDraggedNodeRectRef = (0, _react.useRef)(initDraggedNodeRect);
|
|
31
23
|
var blankNode = (0, _react.useRef)(null);
|
|
32
24
|
(0, _react.useEffect)(function () {
|
|
@@ -35,34 +27,35 @@ var useBlankNode = function useBlankNode(props) {
|
|
|
35
27
|
(0, _react.useEffect)(function () {
|
|
36
28
|
if (!draggedNode || !targetList || !targetList.ref.current || draggedNode.list === targetList || !initDraggedNodeRectRef.current) {
|
|
37
29
|
return;
|
|
38
|
-
}
|
|
39
|
-
|
|
30
|
+
}
|
|
40
31
|
|
|
32
|
+
// Create a new blank div
|
|
41
33
|
var _initDraggedNodeRectR = initDraggedNodeRectRef.current,
|
|
42
|
-
|
|
43
|
-
|
|
34
|
+
initWidth = _initDraggedNodeRectR.initWidth,
|
|
35
|
+
initHeight = _initDraggedNodeRectR.initHeight;
|
|
44
36
|
var div = document.createElement('div');
|
|
45
37
|
div.style.width = "".concat(initWidth, "px");
|
|
46
38
|
div.style.height = "".concat(initHeight, "px");
|
|
47
39
|
div.style.minWidth = "".concat(initWidth, "px");
|
|
48
40
|
div.style.minHeight = "".concat(initHeight, "px");
|
|
49
41
|
var parent = targetList.ref.current;
|
|
50
|
-
var innerList = targetList.innerRef.current;
|
|
42
|
+
var innerList = targetList.innerRef.current;
|
|
51
43
|
|
|
44
|
+
// The inner ref used only in the virtual list
|
|
52
45
|
if (innerList) {
|
|
53
46
|
var _innerList$getBoundin = innerList.getBoundingClientRect(),
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
47
|
+
width = _innerList$getBoundin.width,
|
|
48
|
+
height = _innerList$getBoundin.height;
|
|
57
49
|
div.style.position = 'absolute';
|
|
58
50
|
div.style.left = targetList.horizontal ? "".concat(width, "px") : '0px';
|
|
59
51
|
div.style.top = targetList.horizontal ? '0px' : "".concat(height, "px");
|
|
60
52
|
parent = innerList;
|
|
61
|
-
}
|
|
62
|
-
|
|
53
|
+
}
|
|
63
54
|
|
|
64
|
-
|
|
55
|
+
// Append the blank div to increase the height of the list
|
|
56
|
+
parent.appendChild(div);
|
|
65
57
|
|
|
58
|
+
// Add the blank node to the node list
|
|
66
59
|
var tail = targetList.getTail();
|
|
67
60
|
blankNode.current = {
|
|
68
61
|
list: targetList,
|
|
@@ -81,15 +74,14 @@ var useBlankNode = function useBlankNode(props) {
|
|
|
81
74
|
if (!blank) return;
|
|
82
75
|
blankNode.current = null;
|
|
83
76
|
blank.list.remove(blank.node);
|
|
84
|
-
|
|
85
77
|
var _blank$node = _slicedToArray(blank.node, 3),
|
|
86
|
-
|
|
87
|
-
|
|
78
|
+
blankNodeRef = _blank$node[2];
|
|
88
79
|
if (!blank.list.ref.current || !blankNodeRef.current) return;
|
|
89
80
|
var parent = blankNodeRef.current.parentElement;
|
|
90
81
|
if (parent) parent.removeChild(blankNodeRef.current);
|
|
91
|
-
}, []);
|
|
82
|
+
}, []);
|
|
92
83
|
|
|
84
|
+
// Remove the blank node if the dragged node has been dropped
|
|
93
85
|
(0, _react.useEffect)(function () {
|
|
94
86
|
if (!draggedNode) return function () {};
|
|
95
87
|
return function () {
|
|
@@ -98,7 +90,6 @@ var useBlankNode = function useBlankNode(props) {
|
|
|
98
90
|
}, [draggedNode, removeBlankNode]);
|
|
99
91
|
return removeBlankNode;
|
|
100
92
|
};
|
|
101
|
-
|
|
102
93
|
var _default = useBlankNode;
|
|
103
94
|
exports["default"] = _default;
|
|
104
95
|
//# sourceMappingURL=useBlankNode.js.map
|