handsontable 0.0.0-next-95bb75e-20240131 → 0.0.0-next-ffffb2f-20240131

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of handsontable might be problematic. Click here for more details.

package/helpers/moves.js DELETED
@@ -1,86 +0,0 @@
1
- "use strict";
2
-
3
- exports.__esModule = true;
4
- exports.getMoves = getMoves;
5
- require("core-js/modules/es.array.push.js");
6
- /**
7
- * Gets first position where to move element (respecting the fact that some element will be sooner or later
8
- * taken out of the dataset in order to move them).
9
- *
10
- * @param {Array<number>} movedIndexes Sequence of moved indexes for certain axis.
11
- * @param {number} finalIndex Final place where to move rows.
12
- * @param {number} numberOfIndexes Number of indexes in a dataset.
13
- * @returns {number} Index informing where to move the first element.
14
- */
15
- function getMoveLine(movedIndexes, finalIndex, numberOfIndexes) {
16
- const notMovedElements = Array.from(Array(numberOfIndexes).keys()).filter(index => movedIndexes.includes(index) === false);
17
- if (finalIndex === 0) {
18
- var _notMovedElements$fin;
19
- return (_notMovedElements$fin = notMovedElements[finalIndex]) !== null && _notMovedElements$fin !== void 0 ? _notMovedElements$fin : 0; // Moving before the first dataset's element.
20
- }
21
- return notMovedElements[finalIndex - 1] + 1; // Moving before another element.
22
- }
23
-
24
- /**
25
- * Gets initially calculated move positions.
26
- *
27
- * @param {Array<number>} movedIndexes Sequence of moved indexes for certain axis.
28
- * @param {number} moveLine Final place where to move rows.
29
- * @returns {Array<{from: number, to: number}>} Initially calculated move positions.
30
- */
31
- function getInitiallyCalculatedMoves(movedIndexes, moveLine) {
32
- const moves = [];
33
- movedIndexes.forEach(movedIndex => {
34
- const move = {
35
- from: movedIndex,
36
- to: moveLine
37
- };
38
- moves.forEach(previouslyMovedIndex => {
39
- const isMovingFromEndToStart = previouslyMovedIndex.from > previouslyMovedIndex.to;
40
- const isMovingElementBefore = previouslyMovedIndex.to <= move.from;
41
- const isMovingAfterElement = previouslyMovedIndex.from > move.from;
42
- if (isMovingAfterElement && isMovingElementBefore && isMovingFromEndToStart) {
43
- move.from += 1;
44
- }
45
- });
46
-
47
- // Moved element from right to left (or bottom to top).
48
- if (move.from >= moveLine) {
49
- moveLine += 1;
50
- }
51
- moves.push(move);
52
- });
53
- return moves;
54
- }
55
-
56
- /**
57
- * Gets finally calculated move positions (after adjusting).
58
- *
59
- * @param {Array<{from: number, to: number}>} moves Initially calculated move positions.
60
- * @returns {Array<{from: number, to: number}>} Finally calculated move positions (after adjusting).
61
- */
62
- function adjustedCalculatedMoves(moves) {
63
- moves.forEach((move, index) => {
64
- const nextMoved = moves.slice(index + 1);
65
- nextMoved.forEach(nextMovedIndex => {
66
- const isMovingFromStartToEnd = nextMovedIndex.from < nextMovedIndex.to;
67
- if (nextMovedIndex.from > move.from && isMovingFromStartToEnd) {
68
- nextMovedIndex.from -= 1;
69
- }
70
- });
71
- });
72
- return moves;
73
- }
74
-
75
- /**
76
- * Get list of move positions.
77
- *
78
- * @param {Array<number>} movedIndexes Sequence of moved indexes for certain axis.
79
- * @param {number} finalIndex Final place where to move rows.
80
- * @param {number} numberOfIndexes Number of indexes in a dataset.
81
- * @returns {Array<{from: number, to: number}>}
82
- */
83
- function getMoves(movedIndexes, finalIndex, numberOfIndexes) {
84
- const moves = getInitiallyCalculatedMoves(movedIndexes, getMoveLine(movedIndexes, finalIndex, numberOfIndexes));
85
- return adjustedCalculatedMoves(moves);
86
- }
package/helpers/moves.mjs DELETED
@@ -1,82 +0,0 @@
1
- import "core-js/modules/es.array.push.js";
2
- /**
3
- * Gets first position where to move element (respecting the fact that some element will be sooner or later
4
- * taken out of the dataset in order to move them).
5
- *
6
- * @param {Array<number>} movedIndexes Sequence of moved indexes for certain axis.
7
- * @param {number} finalIndex Final place where to move rows.
8
- * @param {number} numberOfIndexes Number of indexes in a dataset.
9
- * @returns {number} Index informing where to move the first element.
10
- */
11
- function getMoveLine(movedIndexes, finalIndex, numberOfIndexes) {
12
- const notMovedElements = Array.from(Array(numberOfIndexes).keys()).filter(index => movedIndexes.includes(index) === false);
13
- if (finalIndex === 0) {
14
- var _notMovedElements$fin;
15
- return (_notMovedElements$fin = notMovedElements[finalIndex]) !== null && _notMovedElements$fin !== void 0 ? _notMovedElements$fin : 0; // Moving before the first dataset's element.
16
- }
17
- return notMovedElements[finalIndex - 1] + 1; // Moving before another element.
18
- }
19
-
20
- /**
21
- * Gets initially calculated move positions.
22
- *
23
- * @param {Array<number>} movedIndexes Sequence of moved indexes for certain axis.
24
- * @param {number} moveLine Final place where to move rows.
25
- * @returns {Array<{from: number, to: number}>} Initially calculated move positions.
26
- */
27
- function getInitiallyCalculatedMoves(movedIndexes, moveLine) {
28
- const moves = [];
29
- movedIndexes.forEach(movedIndex => {
30
- const move = {
31
- from: movedIndex,
32
- to: moveLine
33
- };
34
- moves.forEach(previouslyMovedIndex => {
35
- const isMovingFromEndToStart = previouslyMovedIndex.from > previouslyMovedIndex.to;
36
- const isMovingElementBefore = previouslyMovedIndex.to <= move.from;
37
- const isMovingAfterElement = previouslyMovedIndex.from > move.from;
38
- if (isMovingAfterElement && isMovingElementBefore && isMovingFromEndToStart) {
39
- move.from += 1;
40
- }
41
- });
42
-
43
- // Moved element from right to left (or bottom to top).
44
- if (move.from >= moveLine) {
45
- moveLine += 1;
46
- }
47
- moves.push(move);
48
- });
49
- return moves;
50
- }
51
-
52
- /**
53
- * Gets finally calculated move positions (after adjusting).
54
- *
55
- * @param {Array<{from: number, to: number}>} moves Initially calculated move positions.
56
- * @returns {Array<{from: number, to: number}>} Finally calculated move positions (after adjusting).
57
- */
58
- function adjustedCalculatedMoves(moves) {
59
- moves.forEach((move, index) => {
60
- const nextMoved = moves.slice(index + 1);
61
- nextMoved.forEach(nextMovedIndex => {
62
- const isMovingFromStartToEnd = nextMovedIndex.from < nextMovedIndex.to;
63
- if (nextMovedIndex.from > move.from && isMovingFromStartToEnd) {
64
- nextMovedIndex.from -= 1;
65
- }
66
- });
67
- });
68
- return moves;
69
- }
70
-
71
- /**
72
- * Get list of move positions.
73
- *
74
- * @param {Array<number>} movedIndexes Sequence of moved indexes for certain axis.
75
- * @param {number} finalIndex Final place where to move rows.
76
- * @param {number} numberOfIndexes Number of indexes in a dataset.
77
- * @returns {Array<{from: number, to: number}>}
78
- */
79
- export function getMoves(movedIndexes, finalIndex, numberOfIndexes) {
80
- const moves = getInitiallyCalculatedMoves(movedIndexes, getMoveLine(movedIndexes, finalIndex, numberOfIndexes));
81
- return adjustedCalculatedMoves(moves);
82
- }