@elliemae/ds-query-builder 2.2.0-alpha.4 → 3.0.0-next.2
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/cjs/DSQueryBuilder.js +97 -117
- package/cjs/components/AndOrController/AndOrController.js +162 -148
- package/cjs/components/ConditionController/ConditionController.js +72 -88
- package/cjs/components/DisplayOutput/DisplayOutput.js +68 -63
- package/cjs/components/DragContainerController/DragContainerController.js +41 -61
- package/cjs/components/DragControllerRow/DragControllerRow.js +46 -50
- package/cjs/components/FieldControllerRow/FieldControllerRow.js +32 -54
- package/cjs/components/Nestable/Nestable.js +209 -143
- package/cjs/components/Nestable/NestableItem.js +90 -98
- package/cjs/components/Nestable/actions/events.js +95 -72
- package/cjs/components/Nestable/actions/getItemOptions.js +15 -36
- package/cjs/components/Nestable/actions/getPaths.js +51 -46
- package/cjs/components/Nestable/actions/index.js +28 -42
- package/cjs/components/Nestable/actions/moveItem.js +42 -44
- package/cjs/components/Nestable/actions/paths.js +55 -48
- package/cjs/components/Nestable/actions/tryDecreaseDepth.js +23 -39
- package/cjs/components/Nestable/actions/tryIncreaseDepth.js +26 -39
- package/cjs/components/Nestable/index.js +7 -36
- package/cjs/components/QueryBuilderContext/QueryBuilderContext.js +13 -36
- package/cjs/components/QueryBuilderImpl.js +202 -118
- package/cjs/components/QueryBuilderItem/QueryBuilderItem.js +78 -80
- package/cjs/components/QueryBuilderRow/QueryBuilderRow.js +211 -154
- package/cjs/components/ToolBarAnimation/ToolBarAnimation.js +26 -39
- package/cjs/components/format/format.js +22 -48
- package/cjs/components/format/sqlFormat.js +48 -69
- package/cjs/components/format/sqlSafeFormat.js +55 -72
- package/cjs/components/format/xmlFormat.js +50 -71
- package/cjs/components/helpers/actions.js +186 -151
- package/cjs/components/helpers/constants.js +8 -36
- package/cjs/components/helpers/dependencies.js +64 -49
- package/cjs/components/helpers/selectors.js +101 -161
- package/cjs/components/helpers/store.js +104 -86
- package/cjs/components/helpers/types.js +44 -72
- package/cjs/index.js +29 -36
- package/cjs/propTypes.js +94 -102
- package/esm/DSQueryBuilder.js +72 -103
- package/esm/components/AndOrController/AndOrController.js +147 -113
- package/esm/components/ConditionController/ConditionController.js +62 -57
- package/esm/components/DisplayOutput/DisplayOutput.js +59 -31
- package/esm/components/DragContainerController/DragContainerController.js +35 -32
- package/esm/components/DragControllerRow/DragControllerRow.js +38 -21
- package/esm/components/FieldControllerRow/FieldControllerRow.js +26 -25
- package/esm/components/Nestable/Nestable.js +186 -115
- package/esm/components/Nestable/NestableItem.js +82 -69
- package/esm/components/Nestable/actions/events.js +79 -45
- package/esm/components/Nestable/actions/getItemOptions.js +11 -7
- package/esm/components/Nestable/actions/getPaths.js +43 -17
- package/esm/components/Nestable/actions/index.js +6 -13
- package/esm/components/Nestable/actions/moveItem.js +31 -13
- package/esm/components/Nestable/actions/paths.js +47 -19
- package/esm/components/Nestable/actions/tryDecreaseDepth.js +19 -10
- package/esm/components/Nestable/actions/tryIncreaseDepth.js +22 -10
- package/esm/components/Nestable/index.js +2 -7
- package/esm/components/QueryBuilderContext/QueryBuilderContext.js +5 -7
- package/esm/components/QueryBuilderImpl.js +187 -82
- package/esm/components/QueryBuilderItem/QueryBuilderItem.js +70 -50
- package/esm/components/QueryBuilderRow/QueryBuilderRow.js +201 -123
- package/esm/components/ToolBarAnimation/ToolBarAnimation.js +17 -10
- package/esm/components/format/format.js +17 -16
- package/esm/components/format/sqlFormat.js +43 -39
- package/esm/components/format/sqlSafeFormat.js +50 -43
- package/esm/components/format/xmlFormat.js +45 -41
- package/esm/components/helpers/actions.js +160 -123
- package/esm/components/helpers/constants.js +2 -7
- package/esm/components/helpers/dependencies.js +39 -19
- package/esm/components/helpers/selectors.js +93 -132
- package/esm/components/helpers/store.js +82 -54
- package/esm/components/helpers/types.js +33 -44
- package/esm/index.js +4 -7
- package/esm/propTypes.js +72 -55
- package/package.json +12 -12
- package/cjs/DSQueryBuilder.js.map +0 -7
- package/cjs/components/AndOrController/AndOrController.js.map +0 -7
- package/cjs/components/ConditionController/ConditionController.js.map +0 -7
- package/cjs/components/DisplayOutput/DisplayOutput.js.map +0 -7
- package/cjs/components/DragContainerController/DragContainerController.js.map +0 -7
- package/cjs/components/DragControllerRow/DragControllerRow.js.map +0 -7
- package/cjs/components/FieldControllerRow/FieldControllerRow.js.map +0 -7
- package/cjs/components/Nestable/Nestable.js.map +0 -7
- package/cjs/components/Nestable/NestableItem.js.map +0 -7
- package/cjs/components/Nestable/actions/events.js.map +0 -7
- package/cjs/components/Nestable/actions/getItemOptions.js.map +0 -7
- package/cjs/components/Nestable/actions/getPaths.js.map +0 -7
- package/cjs/components/Nestable/actions/index.js.map +0 -7
- package/cjs/components/Nestable/actions/moveItem.js.map +0 -7
- package/cjs/components/Nestable/actions/paths.js.map +0 -7
- package/cjs/components/Nestable/actions/tryDecreaseDepth.js.map +0 -7
- package/cjs/components/Nestable/actions/tryIncreaseDepth.js.map +0 -7
- package/cjs/components/Nestable/index.js.map +0 -7
- package/cjs/components/QueryBuilderContext/QueryBuilderContext.js.map +0 -7
- package/cjs/components/QueryBuilderImpl.js.map +0 -7
- package/cjs/components/QueryBuilderItem/QueryBuilderItem.js.map +0 -7
- package/cjs/components/QueryBuilderRow/QueryBuilderRow.js.map +0 -7
- package/cjs/components/ToolBarAnimation/ToolBarAnimation.js.map +0 -7
- package/cjs/components/format/format.js.map +0 -7
- package/cjs/components/format/sqlFormat.js.map +0 -7
- package/cjs/components/format/sqlSafeFormat.js.map +0 -7
- package/cjs/components/format/xmlFormat.js.map +0 -7
- package/cjs/components/helpers/actions.js.map +0 -7
- package/cjs/components/helpers/constants.js.map +0 -7
- package/cjs/components/helpers/dependencies.js.map +0 -7
- package/cjs/components/helpers/selectors.js.map +0 -7
- package/cjs/components/helpers/store.js.map +0 -7
- package/cjs/components/helpers/types.js.map +0 -7
- package/cjs/index.js.map +0 -7
- package/cjs/propTypes.js.map +0 -7
- package/esm/DSQueryBuilder.js.map +0 -7
- package/esm/components/AndOrController/AndOrController.js.map +0 -7
- package/esm/components/ConditionController/ConditionController.js.map +0 -7
- package/esm/components/DisplayOutput/DisplayOutput.js.map +0 -7
- package/esm/components/DragContainerController/DragContainerController.js.map +0 -7
- package/esm/components/DragControllerRow/DragControllerRow.js.map +0 -7
- package/esm/components/FieldControllerRow/FieldControllerRow.js.map +0 -7
- package/esm/components/Nestable/Nestable.js.map +0 -7
- package/esm/components/Nestable/NestableItem.js.map +0 -7
- package/esm/components/Nestable/actions/events.js.map +0 -7
- package/esm/components/Nestable/actions/getItemOptions.js.map +0 -7
- package/esm/components/Nestable/actions/getPaths.js.map +0 -7
- package/esm/components/Nestable/actions/index.js.map +0 -7
- package/esm/components/Nestable/actions/moveItem.js.map +0 -7
- package/esm/components/Nestable/actions/paths.js.map +0 -7
- package/esm/components/Nestable/actions/tryDecreaseDepth.js.map +0 -7
- package/esm/components/Nestable/actions/tryIncreaseDepth.js.map +0 -7
- package/esm/components/Nestable/index.js.map +0 -7
- package/esm/components/QueryBuilderContext/QueryBuilderContext.js.map +0 -7
- package/esm/components/QueryBuilderImpl.js.map +0 -7
- package/esm/components/QueryBuilderItem/QueryBuilderItem.js.map +0 -7
- package/esm/components/QueryBuilderRow/QueryBuilderRow.js.map +0 -7
- package/esm/components/ToolBarAnimation/ToolBarAnimation.js.map +0 -7
- package/esm/components/format/format.js.map +0 -7
- package/esm/components/format/sqlFormat.js.map +0 -7
- package/esm/components/format/sqlSafeFormat.js.map +0 -7
- package/esm/components/format/xmlFormat.js.map +0 -7
- package/esm/components/helpers/actions.js.map +0 -7
- package/esm/components/helpers/constants.js.map +0 -7
- package/esm/components/helpers/dependencies.js.map +0 -7
- package/esm/components/helpers/selectors.js.map +0 -7
- package/esm/components/helpers/store.js.map +0 -7
- package/esm/components/helpers/types.js.map +0 -7
- package/esm/index.js.map +0 -7
- package/esm/propTypes.js.map +0 -7
|
@@ -1,104 +1,103 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
for (let key of __getOwnPropNames(module2))
|
|
15
|
-
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
16
|
-
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return target;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (module2, isNodeMode) => {
|
|
21
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
|
-
};
|
|
23
|
-
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
-
return (module2, temp) => {
|
|
25
|
-
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
-
};
|
|
27
|
-
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
-
var getPaths_exports = {};
|
|
29
|
-
__export(getPaths_exports, {
|
|
30
|
-
getItemByPath: () => getItemByPath,
|
|
31
|
-
getItemDepth: () => getItemDepth,
|
|
32
|
-
getPathById: () => getPathById,
|
|
33
|
-
getRealNextPath: () => getRealNextPath,
|
|
34
|
-
getSplicePath: () => getSplicePath
|
|
35
|
-
});
|
|
36
|
-
var React = __toESM(require("react"));
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
require('core-js/modules/esnext.async-iterator.map.js');
|
|
6
|
+
require('core-js/modules/esnext.iterator.map.js');
|
|
7
|
+
require('core-js/modules/esnext.async-iterator.every.js');
|
|
8
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
9
|
+
require('core-js/modules/esnext.iterator.every.js');
|
|
10
|
+
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
11
|
+
require('core-js/modules/esnext.iterator.for-each.js');
|
|
12
|
+
require('core-js/modules/web.dom-collections.iterator.js');
|
|
13
|
+
|
|
37
14
|
function getRealNextPath(prevPath, nextPath) {
|
|
38
|
-
const {
|
|
15
|
+
const {
|
|
16
|
+
childrenProp
|
|
17
|
+
} = this.props;
|
|
39
18
|
const ppLastIndex = prevPath.length - 1;
|
|
40
19
|
const npLastIndex = nextPath.length - 1;
|
|
20
|
+
|
|
41
21
|
if (prevPath.length < nextPath.length) {
|
|
22
|
+
// move into deep
|
|
42
23
|
let wasShifted = false;
|
|
43
24
|
return nextPath.map((nextIndex, i) => {
|
|
44
25
|
if (wasShifted) {
|
|
45
26
|
return i === npLastIndex ? nextIndex + 1 : nextIndex;
|
|
46
27
|
}
|
|
47
|
-
|
|
28
|
+
|
|
29
|
+
if (typeof prevPath[i] !== 'number') {
|
|
48
30
|
return nextIndex;
|
|
49
31
|
}
|
|
32
|
+
|
|
50
33
|
if (nextPath[i] > prevPath[i] && i === ppLastIndex) {
|
|
51
34
|
wasShifted = true;
|
|
52
35
|
return nextIndex - 1;
|
|
53
36
|
}
|
|
37
|
+
|
|
54
38
|
return nextIndex;
|
|
55
39
|
});
|
|
56
40
|
}
|
|
41
|
+
|
|
57
42
|
if (prevPath.length === nextPath.length) {
|
|
43
|
+
// if move bottom + move to item with children => make it a first child instead of swap
|
|
58
44
|
if (nextPath[npLastIndex] > prevPath[npLastIndex]) {
|
|
59
45
|
const target = this.getItemByPath(nextPath);
|
|
46
|
+
|
|
60
47
|
if (target[childrenProp] && target[childrenProp].length && !this.isCollapsed(target)) {
|
|
61
48
|
return nextPath.slice(0, -1).concat(nextPath[npLastIndex] - 1).concat(0);
|
|
62
49
|
}
|
|
63
50
|
}
|
|
64
51
|
}
|
|
52
|
+
|
|
65
53
|
return nextPath;
|
|
66
54
|
}
|
|
67
55
|
function getPathById(id, items) {
|
|
68
|
-
const {
|
|
56
|
+
const {
|
|
57
|
+
childrenProp
|
|
58
|
+
} = this.props;
|
|
69
59
|
let path = [];
|
|
70
60
|
items.every((item, i) => {
|
|
71
61
|
if (item.id === id) {
|
|
72
62
|
path.push(i);
|
|
73
63
|
} else if (item[childrenProp]) {
|
|
74
64
|
const childrenPath = this.getPathById(id, item[childrenProp]);
|
|
65
|
+
|
|
75
66
|
if (childrenPath.length) {
|
|
76
67
|
path = path.concat(i).concat(childrenPath);
|
|
77
68
|
}
|
|
78
69
|
}
|
|
70
|
+
|
|
79
71
|
return path.length === 0;
|
|
80
72
|
});
|
|
81
73
|
return path;
|
|
82
74
|
}
|
|
83
75
|
function getItemByPath(path, items) {
|
|
84
|
-
const {
|
|
76
|
+
const {
|
|
77
|
+
childrenProp
|
|
78
|
+
} = this.props;
|
|
85
79
|
let item = null;
|
|
86
|
-
path.forEach(
|
|
80
|
+
path.forEach(index => {
|
|
87
81
|
const list = item ? item[childrenProp] : items;
|
|
88
82
|
item = list[index];
|
|
89
83
|
});
|
|
90
84
|
return item;
|
|
91
85
|
}
|
|
92
86
|
function getItemDepth(item) {
|
|
93
|
-
const {
|
|
87
|
+
const {
|
|
88
|
+
childrenProp
|
|
89
|
+
} = this.props;
|
|
94
90
|
let level = 1;
|
|
91
|
+
|
|
95
92
|
if (item[childrenProp].length > 0) {
|
|
96
93
|
const childrenDepths = item[childrenProp].map(this.getItemDepth);
|
|
97
94
|
level += Math.max(...childrenDepths);
|
|
98
95
|
}
|
|
96
|
+
|
|
99
97
|
return level;
|
|
100
98
|
}
|
|
101
|
-
function getSplicePath(path
|
|
99
|
+
function getSplicePath(path) {
|
|
100
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
102
101
|
const splicePath = {};
|
|
103
102
|
const numToRemove = options.numToRemove || 0;
|
|
104
103
|
const itemsToInsert = options.itemsToInsert || [];
|
|
@@ -109,11 +108,17 @@ function getSplicePath(path, options = {}) {
|
|
|
109
108
|
currentPath.$splice = [[index, numToRemove, ...itemsToInsert]];
|
|
110
109
|
} else {
|
|
111
110
|
const nextPath = {};
|
|
112
|
-
currentPath[index] = {
|
|
111
|
+
currentPath[index] = {
|
|
112
|
+
[options.childrenProp]: nextPath
|
|
113
|
+
};
|
|
113
114
|
currentPath = nextPath;
|
|
114
115
|
}
|
|
115
116
|
});
|
|
116
117
|
return splicePath;
|
|
117
118
|
}
|
|
118
|
-
|
|
119
|
-
|
|
119
|
+
|
|
120
|
+
exports.getItemByPath = getItemByPath;
|
|
121
|
+
exports.getItemDepth = getItemDepth;
|
|
122
|
+
exports.getPathById = getPathById;
|
|
123
|
+
exports.getRealNextPath = getRealNextPath;
|
|
124
|
+
exports.getSplicePath = getSplicePath;
|
|
@@ -1,42 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
__export(actions_exports, {
|
|
30
|
-
moveItem: () => import_moveItem.moveItem,
|
|
31
|
-
tryDecreaseDepth: () => import_tryDecreaseDepth.tryDecreaseDepth,
|
|
32
|
-
tryIncreaseDepth: () => import_tryIncreaseDepth.tryIncreaseDepth
|
|
33
|
-
});
|
|
34
|
-
var React = __toESM(require("react"));
|
|
35
|
-
var import_tryIncreaseDepth = require("./tryIncreaseDepth");
|
|
36
|
-
var import_tryDecreaseDepth = require("./tryDecreaseDepth");
|
|
37
|
-
var import_moveItem = require("./moveItem");
|
|
38
|
-
__reExport(actions_exports, require("./paths"));
|
|
39
|
-
__reExport(actions_exports, require("./events"));
|
|
40
|
-
__reExport(actions_exports, require("./getItemOptions"));
|
|
41
|
-
module.exports = __toCommonJS(actions_exports);
|
|
42
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var tryIncreaseDepth = require('./tryIncreaseDepth.js');
|
|
6
|
+
var tryDecreaseDepth = require('./tryDecreaseDepth.js');
|
|
7
|
+
var moveItem = require('./moveItem.js');
|
|
8
|
+
var paths = require('./paths.js');
|
|
9
|
+
var events = require('./events.js');
|
|
10
|
+
var getItemOptions = require('./getItemOptions.js');
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
exports.tryIncreaseDepth = tryIncreaseDepth.tryIncreaseDepth;
|
|
15
|
+
exports.tryDecreaseDepth = tryDecreaseDepth.tryDecreaseDepth;
|
|
16
|
+
exports.moveItem = moveItem.moveItem;
|
|
17
|
+
exports.getItemByPath = paths.getItemByPath;
|
|
18
|
+
exports.getItemDepth = paths.getItemDepth;
|
|
19
|
+
exports.getPathById = paths.getPathById;
|
|
20
|
+
exports.getRealNextPath = paths.getRealNextPath;
|
|
21
|
+
exports.getSplicePath = paths.getSplicePath;
|
|
22
|
+
exports.onDragEnd = events.onDragEnd;
|
|
23
|
+
exports.onDragStart = events.onDragStart;
|
|
24
|
+
exports.onKeyDown = events.onKeyDown;
|
|
25
|
+
exports.onMouseEnter = events.onMouseEnter;
|
|
26
|
+
exports.onMouseMove = events.onMouseMove;
|
|
27
|
+
exports.onToggleCollapse = events.onToggleCollapse;
|
|
28
|
+
exports.getItemOptions = getItemOptions.getItemOptions;
|
|
@@ -1,39 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
let { items } = this.state;
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
6
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
7
|
+
require('core-js/modules/esnext.iterator.filter.js');
|
|
8
|
+
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
9
|
+
require('core-js/modules/esnext.iterator.for-each.js');
|
|
10
|
+
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
11
|
+
var update = require('react-addons-update');
|
|
12
|
+
|
|
13
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
14
|
+
|
|
15
|
+
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
16
|
+
var update__default = /*#__PURE__*/_interopDefaultLegacy(update);
|
|
17
|
+
|
|
18
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
19
|
+
|
|
20
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
21
|
+
function moveItem(_ref) {
|
|
22
|
+
let {
|
|
23
|
+
dragItem,
|
|
24
|
+
pathFrom,
|
|
25
|
+
pathTo
|
|
26
|
+
} = _ref;
|
|
27
|
+
let extraProps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
28
|
+
const {
|
|
29
|
+
childrenProp
|
|
30
|
+
} = this.props;
|
|
31
|
+
let {
|
|
32
|
+
items
|
|
33
|
+
} = this.state; // the remove action might affect the next position,
|
|
34
|
+
// so update next coordinates accordingly
|
|
35
|
+
|
|
37
36
|
const realPathTo = this.getRealNextPath(pathFrom, pathTo);
|
|
38
37
|
const removePath = this.getSplicePath(pathFrom, {
|
|
39
38
|
numToRemove: 1,
|
|
@@ -44,13 +43,12 @@ function moveItem({ dragItem, pathFrom, pathTo }, extraProps = {}) {
|
|
|
44
43
|
itemsToInsert: [dragItem],
|
|
45
44
|
childrenProp
|
|
46
45
|
});
|
|
47
|
-
items =
|
|
48
|
-
items =
|
|
49
|
-
this.setState({
|
|
46
|
+
items = update__default["default"](items, removePath);
|
|
47
|
+
items = update__default["default"](items, insertPath);
|
|
48
|
+
this.setState(_objectSpread({
|
|
50
49
|
items,
|
|
51
|
-
isDirty: true
|
|
52
|
-
|
|
53
|
-
});
|
|
50
|
+
isDirty: true
|
|
51
|
+
}, extraProps));
|
|
54
52
|
}
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
|
|
54
|
+
exports.moveItem = moveItem;
|
|
@@ -1,104 +1,105 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
for (let key of __getOwnPropNames(module2))
|
|
15
|
-
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
16
|
-
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return target;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (module2, isNodeMode) => {
|
|
21
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
|
-
};
|
|
23
|
-
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
-
return (module2, temp) => {
|
|
25
|
-
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
-
};
|
|
27
|
-
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
-
var paths_exports = {};
|
|
29
|
-
__export(paths_exports, {
|
|
30
|
-
getItemByPath: () => getItemByPath,
|
|
31
|
-
getItemDepth: () => getItemDepth,
|
|
32
|
-
getPathById: () => getPathById,
|
|
33
|
-
getRealNextPath: () => getRealNextPath,
|
|
34
|
-
getSplicePath: () => getSplicePath
|
|
35
|
-
});
|
|
36
|
-
var React = __toESM(require("react"));
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
require('core-js/modules/esnext.async-iterator.map.js');
|
|
6
|
+
require('core-js/modules/esnext.iterator.map.js');
|
|
7
|
+
require('core-js/modules/esnext.async-iterator.every.js');
|
|
8
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
9
|
+
require('core-js/modules/esnext.iterator.every.js');
|
|
10
|
+
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
11
|
+
require('core-js/modules/esnext.iterator.for-each.js');
|
|
12
|
+
require('core-js/modules/web.dom-collections.iterator.js');
|
|
13
|
+
|
|
37
14
|
function getRealNextPath(prevPath, nextPath) {
|
|
38
|
-
const {
|
|
15
|
+
const {
|
|
16
|
+
childrenProp
|
|
17
|
+
} = this.props;
|
|
39
18
|
const ppLastIndex = prevPath.length - 1;
|
|
40
19
|
const npLastIndex = nextPath.length - 1;
|
|
20
|
+
|
|
41
21
|
if (prevPath.length < nextPath.length) {
|
|
22
|
+
// move into deep
|
|
42
23
|
let wasShifted = false;
|
|
43
24
|
return nextPath.map((nextIndex, i) => {
|
|
44
25
|
if (wasShifted) {
|
|
45
26
|
return i === npLastIndex ? nextIndex + 1 : nextIndex;
|
|
46
27
|
}
|
|
47
|
-
|
|
28
|
+
|
|
29
|
+
if (typeof prevPath[i] !== 'number') {
|
|
48
30
|
return nextIndex;
|
|
49
31
|
}
|
|
32
|
+
|
|
50
33
|
if (nextPath[i] > prevPath[i] && i === ppLastIndex) {
|
|
51
34
|
wasShifted = true;
|
|
52
35
|
return nextIndex - 1;
|
|
53
36
|
}
|
|
37
|
+
|
|
54
38
|
return nextIndex;
|
|
55
39
|
});
|
|
56
40
|
}
|
|
41
|
+
|
|
57
42
|
if (prevPath.length === nextPath.length) {
|
|
43
|
+
// if move bottom + move to item with children => make it a first child instead of swap
|
|
58
44
|
if (nextPath[npLastIndex] > prevPath[npLastIndex]) {
|
|
59
45
|
const target = this.getItemByPath(nextPath);
|
|
46
|
+
|
|
60
47
|
if (target[childrenProp] && target[childrenProp].length && !this.isCollapsed(target)) {
|
|
61
48
|
return nextPath.slice(0, -1).concat(nextPath[npLastIndex] - 1).concat(0);
|
|
62
49
|
}
|
|
63
50
|
}
|
|
64
51
|
}
|
|
52
|
+
|
|
65
53
|
return nextPath;
|
|
66
54
|
}
|
|
67
|
-
function getPathById(id
|
|
68
|
-
|
|
55
|
+
function getPathById(id) {
|
|
56
|
+
let items = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getDefaultItems();
|
|
57
|
+
const {
|
|
58
|
+
childrenProp
|
|
59
|
+
} = this.props;
|
|
69
60
|
let path = [];
|
|
70
61
|
items.every((item, i) => {
|
|
71
62
|
if (item.id === id) {
|
|
72
63
|
path.push(i);
|
|
73
64
|
} else if (item[childrenProp]) {
|
|
74
65
|
const childrenPath = this.getPathById(id, item[childrenProp]);
|
|
66
|
+
|
|
75
67
|
if (childrenPath.length) {
|
|
76
68
|
path = path.concat(i).concat(childrenPath);
|
|
77
69
|
}
|
|
78
70
|
}
|
|
71
|
+
|
|
79
72
|
return path.length === 0;
|
|
80
73
|
});
|
|
81
74
|
return path;
|
|
82
75
|
}
|
|
83
|
-
function getItemByPath(path
|
|
84
|
-
|
|
76
|
+
function getItemByPath(path) {
|
|
77
|
+
let items = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getDefaultItems();
|
|
78
|
+
const {
|
|
79
|
+
childrenProp
|
|
80
|
+
} = this.props;
|
|
85
81
|
let item = null;
|
|
86
|
-
path.forEach(
|
|
82
|
+
path.forEach(index => {
|
|
87
83
|
const list = item ? item[childrenProp] : items;
|
|
88
84
|
item = list[index];
|
|
89
85
|
});
|
|
90
86
|
return item;
|
|
91
87
|
}
|
|
92
88
|
function getItemDepth(item) {
|
|
93
|
-
const {
|
|
89
|
+
const {
|
|
90
|
+
childrenProp
|
|
91
|
+
} = this.props;
|
|
94
92
|
let level = 1;
|
|
93
|
+
|
|
95
94
|
if (item[childrenProp].length > 0) {
|
|
96
95
|
const childrenDepths = item[childrenProp].map(this.getItemDepth);
|
|
97
96
|
level += Math.max(...childrenDepths);
|
|
98
97
|
}
|
|
98
|
+
|
|
99
99
|
return level;
|
|
100
100
|
}
|
|
101
|
-
function getSplicePath(path
|
|
101
|
+
function getSplicePath(path) {
|
|
102
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
102
103
|
const splicePath = {};
|
|
103
104
|
const numToRemove = options.numToRemove || 0;
|
|
104
105
|
const itemsToInsert = options.itemsToInsert || [];
|
|
@@ -109,11 +110,17 @@ function getSplicePath(path, options = {}) {
|
|
|
109
110
|
currentPath.$splice = [[index, numToRemove, ...itemsToInsert]];
|
|
110
111
|
} else {
|
|
111
112
|
const nextPath = {};
|
|
112
|
-
currentPath[index] = {
|
|
113
|
+
currentPath[index] = {
|
|
114
|
+
[options.childrenProp]: nextPath
|
|
115
|
+
};
|
|
113
116
|
currentPath = nextPath;
|
|
114
117
|
}
|
|
115
118
|
});
|
|
116
119
|
return splicePath;
|
|
117
120
|
}
|
|
118
|
-
|
|
119
|
-
|
|
121
|
+
|
|
122
|
+
exports.getItemByPath = getItemByPath;
|
|
123
|
+
exports.getItemDepth = getItemDepth;
|
|
124
|
+
exports.getPathById = getPathById;
|
|
125
|
+
exports.getRealNextPath = getRealNextPath;
|
|
126
|
+
exports.getSplicePath = getSplicePath;
|
|
@@ -1,51 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __reExport = (target, module2, copyDefault, desc) => {
|
|
13
|
-
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(module2))
|
|
15
|
-
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
16
|
-
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return target;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (module2, isNodeMode) => {
|
|
21
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
|
-
};
|
|
23
|
-
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
-
return (module2, temp) => {
|
|
25
|
-
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
-
};
|
|
27
|
-
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
-
var tryDecreaseDepth_exports = {};
|
|
29
|
-
__export(tryDecreaseDepth_exports, {
|
|
30
|
-
tryDecreaseDepth: () => tryDecreaseDepth
|
|
31
|
-
});
|
|
32
|
-
var React = __toESM(require("react"));
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
33
5
|
function tryDecreaseDepth(dragItem) {
|
|
34
|
-
const {
|
|
6
|
+
const {
|
|
7
|
+
childrenProp,
|
|
8
|
+
collapsed
|
|
9
|
+
} = this.props;
|
|
35
10
|
const pathFrom = this.getPathById(dragItem.id);
|
|
36
|
-
const itemIndex = pathFrom[pathFrom.length - 1];
|
|
11
|
+
const itemIndex = pathFrom[pathFrom.length - 1]; // has parent
|
|
12
|
+
|
|
37
13
|
if (pathFrom.length > 1) {
|
|
38
|
-
const parent = this.getItemByPath(pathFrom.slice(0, -1));
|
|
14
|
+
const parent = this.getItemByPath(pathFrom.slice(0, -1)); // is last (by order) item in array
|
|
15
|
+
|
|
39
16
|
if (itemIndex + 1 === parent[childrenProp].length) {
|
|
40
17
|
const pathTo = pathFrom.slice(0, -1);
|
|
41
|
-
pathTo[pathTo.length - 1] += 1;
|
|
18
|
+
pathTo[pathTo.length - 1] += 1; // if collapsed by default and is last (by count) item in array remove this node from list of open nodes
|
|
19
|
+
|
|
42
20
|
let collapseProps = {};
|
|
21
|
+
|
|
43
22
|
if (collapsed && parent[childrenProp].length === 1) {
|
|
44
23
|
collapseProps = this.onToggleCollapse(parent, true);
|
|
45
24
|
}
|
|
46
|
-
|
|
25
|
+
|
|
26
|
+
this.moveItem({
|
|
27
|
+
dragItem,
|
|
28
|
+
pathFrom,
|
|
29
|
+
pathTo
|
|
30
|
+
}, collapseProps);
|
|
47
31
|
}
|
|
48
32
|
}
|
|
49
33
|
}
|
|
50
|
-
|
|
51
|
-
|
|
34
|
+
|
|
35
|
+
exports.tryDecreaseDepth = tryDecreaseDepth;
|
|
@@ -1,51 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __reExport = (target, module2, copyDefault, desc) => {
|
|
13
|
-
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(module2))
|
|
15
|
-
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
16
|
-
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return target;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (module2, isNodeMode) => {
|
|
21
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
|
-
};
|
|
23
|
-
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
-
return (module2, temp) => {
|
|
25
|
-
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
-
};
|
|
27
|
-
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
-
var tryIncreaseDepth_exports = {};
|
|
29
|
-
__export(tryIncreaseDepth_exports, {
|
|
30
|
-
tryIncreaseDepth: () => tryIncreaseDepth
|
|
31
|
-
});
|
|
32
|
-
var React = __toESM(require("react"));
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
33
5
|
function tryIncreaseDepth(dragItem) {
|
|
34
|
-
const {
|
|
6
|
+
const {
|
|
7
|
+
maxDepth,
|
|
8
|
+
childrenProp,
|
|
9
|
+
collapsed
|
|
10
|
+
} = this.props;
|
|
35
11
|
const pathFrom = this.getPathById(dragItem.id);
|
|
36
12
|
const itemIndex = pathFrom[pathFrom.length - 1];
|
|
37
|
-
const newDepth = pathFrom.length + this.getItemDepth(dragItem);
|
|
13
|
+
const newDepth = pathFrom.length + this.getItemDepth(dragItem); // has previous sibling and isn't at max depth
|
|
14
|
+
|
|
38
15
|
if (itemIndex > 0 && newDepth <= maxDepth) {
|
|
39
|
-
const prevSibling = this.getItemByPath(pathFrom.slice(0, -1).concat(itemIndex - 1));
|
|
16
|
+
const prevSibling = this.getItemByPath(pathFrom.slice(0, -1).concat(itemIndex - 1)); // previous sibling is not collapsed
|
|
17
|
+
|
|
40
18
|
if (!prevSibling[childrenProp].length || !this.isCollapsed(prevSibling)) {
|
|
41
|
-
const pathTo = pathFrom.slice(0, -1).concat(itemIndex - 1).concat(prevSibling[childrenProp].length);
|
|
19
|
+
const pathTo = pathFrom.slice(0, -1).concat(itemIndex - 1).concat(prevSibling[childrenProp].length); // if collapsed by default
|
|
20
|
+
// and was no children here
|
|
21
|
+
// open this node
|
|
22
|
+
|
|
42
23
|
let collapseProps = {};
|
|
24
|
+
|
|
43
25
|
if (collapsed && !prevSibling[childrenProp].length) {
|
|
44
26
|
collapseProps = this.onToggleCollapse(prevSibling, true);
|
|
45
27
|
}
|
|
46
|
-
|
|
28
|
+
|
|
29
|
+
this.moveItem({
|
|
30
|
+
dragItem,
|
|
31
|
+
pathFrom,
|
|
32
|
+
pathTo
|
|
33
|
+
}, collapseProps);
|
|
47
34
|
}
|
|
48
35
|
}
|
|
49
36
|
}
|
|
50
|
-
|
|
51
|
-
|
|
37
|
+
|
|
38
|
+
exports.tryIncreaseDepth = tryIncreaseDepth;
|