@elliemae/ds-query-builder 2.3.0-alpha.9 → 2.3.0-next.0
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 +98 -0
- package/cjs/components/AndOrController/AndOrController.js +222 -0
- package/cjs/components/ConditionController/ConditionController.js +100 -0
- package/cjs/components/DisplayOutput/DisplayOutput.js +93 -0
- package/cjs/components/DragContainerController/DragContainerController.js +45 -0
- package/cjs/components/DragControllerRow/DragControllerRow.js +47 -0
- package/cjs/components/FieldControllerRow/FieldControllerRow.js +33 -0
- package/cjs/components/Nestable/Nestable.js +320 -0
- package/cjs/components/Nestable/NestableItem.js +111 -0
- package/cjs/components/Nestable/actions/events.js +166 -0
- package/cjs/components/Nestable/actions/getItemOptions.js +28 -0
- package/cjs/components/Nestable/actions/getPaths.js +124 -0
- package/cjs/components/Nestable/actions/index.js +28 -0
- package/cjs/components/Nestable/actions/moveItem.js +54 -0
- package/cjs/components/Nestable/actions/paths.js +126 -0
- package/cjs/components/Nestable/actions/tryDecreaseDepth.js +35 -0
- package/cjs/components/Nestable/actions/tryIncreaseDepth.js +38 -0
- package/cjs/components/Nestable/index.js +7 -0
- package/cjs/components/QueryBuilderContext/QueryBuilderContext.js +13 -0
- package/cjs/components/QueryBuilderImpl.js +309 -0
- package/cjs/components/QueryBuilderItem/QueryBuilderItem.js +90 -0
- package/cjs/components/QueryBuilderRow/QueryBuilderRow.js +276 -0
- package/cjs/components/ToolBarAnimation/ToolBarAnimation.js +29 -0
- package/cjs/components/format/format.js +33 -0
- package/cjs/components/format/sqlFormat.js +73 -0
- package/cjs/components/format/sqlSafeFormat.js +81 -0
- package/cjs/components/format/xmlFormat.js +73 -0
- package/cjs/components/helpers/actions.js +277 -0
- package/cjs/components/helpers/constants.js +11 -0
- package/cjs/components/helpers/dependencies.js +84 -0
- package/cjs/components/helpers/selectors.js +101 -0
- package/cjs/components/helpers/store.js +177 -0
- package/cjs/components/helpers/types.js +64 -0
- package/cjs/index.js +29 -0
- package/cjs/propTypes.js +97 -0
- package/esm/DSQueryBuilder.js +74 -0
- package/esm/components/AndOrController/AndOrController.js +213 -0
- package/esm/components/ConditionController/ConditionController.js +92 -0
- package/esm/components/DisplayOutput/DisplayOutput.js +87 -0
- package/esm/components/DragContainerController/DragContainerController.js +39 -0
- package/esm/components/DragControllerRow/DragControllerRow.js +39 -0
- package/esm/components/FieldControllerRow/FieldControllerRow.js +27 -0
- package/esm/components/Nestable/Nestable.js +312 -0
- package/esm/components/Nestable/NestableItem.js +103 -0
- package/esm/components/Nestable/actions/events.js +153 -0
- package/{dist/esm → esm}/components/Nestable/actions/getItemOptions.js +11 -7
- package/{dist/esm → esm}/components/Nestable/actions/getPaths.js +43 -17
- package/esm/components/Nestable/actions/index.js +6 -0
- package/esm/components/Nestable/actions/moveItem.js +45 -0
- package/{dist/esm → esm}/components/Nestable/actions/paths.js +47 -19
- package/esm/components/Nestable/actions/tryDecreaseDepth.js +31 -0
- package/{dist/esm → esm}/components/Nestable/actions/tryIncreaseDepth.js +22 -10
- package/esm/components/Nestable/index.js +2 -0
- package/esm/components/QueryBuilderContext/QueryBuilderContext.js +5 -0
- package/esm/components/QueryBuilderImpl.js +301 -0
- package/esm/components/QueryBuilderItem/QueryBuilderItem.js +83 -0
- package/esm/components/QueryBuilderRow/QueryBuilderRow.js +268 -0
- package/esm/components/ToolBarAnimation/ToolBarAnimation.js +20 -0
- package/esm/components/format/format.js +31 -0
- package/esm/components/format/sqlFormat.js +69 -0
- package/esm/components/format/sqlSafeFormat.js +76 -0
- package/esm/components/format/xmlFormat.js +69 -0
- package/esm/components/helpers/actions.js +254 -0
- package/esm/components/helpers/constants.js +5 -0
- package/esm/components/helpers/dependencies.js +60 -0
- package/esm/components/helpers/selectors.js +93 -0
- package/esm/components/helpers/store.js +171 -0
- package/esm/components/helpers/types.js +52 -0
- package/esm/index.js +4 -0
- package/esm/propTypes.js +93 -0
- package/package.json +95 -97
- package/{dist/types → types}/DSQueryBuilder.d.ts +0 -0
- package/{dist/types → types}/components/AndOrController/AndOrController.d.ts +0 -0
- package/{dist/types → types}/components/ConditionController/ConditionController.d.ts +0 -0
- package/{dist/types → types}/components/DisplayOutput/DisplayOutput.d.ts +0 -0
- package/{dist/types → types}/components/DragContainerController/DragContainerController.d.ts +0 -0
- package/{dist/types → types}/components/DragControllerRow/DragControllerRow.d.ts +0 -0
- package/{dist/types → types}/components/FieldControllerRow/FieldControllerRow.d.ts +0 -0
- package/{dist/types → types}/components/Nestable/Nestable.d.ts +0 -0
- package/{dist/types → types}/components/Nestable/NestableItem.d.ts +0 -0
- package/{dist/types → types}/components/Nestable/actions/events.d.ts +0 -0
- package/{dist/types → types}/components/Nestable/actions/getItemOptions.d.ts +0 -0
- package/{dist/types → types}/components/Nestable/actions/getPaths.d.ts +0 -0
- package/{dist/types → types}/components/Nestable/actions/index.d.ts +0 -0
- package/{dist/types → types}/components/Nestable/actions/moveItem.d.ts +0 -0
- package/{dist/types → types}/components/Nestable/actions/paths.d.ts +0 -0
- package/{dist/types → types}/components/Nestable/actions/tryDecreaseDepth.d.ts +0 -0
- package/{dist/types → types}/components/Nestable/actions/tryIncreaseDepth.d.ts +0 -0
- package/{dist/types → types}/components/Nestable/index.d.ts +0 -0
- package/{dist/types → types}/components/QueryBuilderContext/QueryBuilderContext.d.ts +0 -0
- package/{dist/types → types}/components/QueryBuilderImpl.d.ts +0 -0
- package/{dist/types → types}/components/QueryBuilderItem/QueryBuilderItem.d.ts +0 -0
- package/{dist/types → types}/components/QueryBuilderRow/QueryBuilderRow.d.ts +0 -0
- package/{dist/types → types}/components/ToolBarAnimation/ToolBarAnimation.d.ts +0 -0
- package/{dist/types → types}/components/format/format.d.ts +0 -0
- package/{dist/types → types}/components/format/sqlFormat.d.ts +0 -0
- package/{dist/types → types}/components/format/sqlSafeFormat.d.ts +0 -0
- package/{dist/types → types}/components/format/xmlFormat.d.ts +0 -0
- package/{dist/types → types}/components/helpers/actions.d.ts +0 -0
- package/{dist/types → types}/components/helpers/constants.d.ts +0 -0
- package/{dist/types → types}/components/helpers/dependencies.d.ts +0 -0
- package/{dist/types → types}/components/helpers/selectors.d.ts +0 -0
- package/{dist/types → types}/components/helpers/store.d.ts +0 -0
- package/{dist/types → types}/components/helpers/types.d.ts +0 -0
- package/{dist/types → types}/index.d.ts +0 -0
- package/{dist/types → types}/propTypes.d.ts +0 -0
- package/dist/cjs/DSQueryBuilder.js +0 -118
- package/dist/cjs/DSQueryBuilder.js.map +0 -7
- package/dist/cjs/components/AndOrController/AndOrController.js +0 -208
- package/dist/cjs/components/AndOrController/AndOrController.js.map +0 -7
- package/dist/cjs/components/ConditionController/ConditionController.js +0 -116
- package/dist/cjs/components/ConditionController/ConditionController.js.map +0 -7
- package/dist/cjs/components/DisplayOutput/DisplayOutput.js +0 -92
- package/dist/cjs/components/DisplayOutput/DisplayOutput.js.map +0 -7
- package/dist/cjs/components/DragContainerController/DragContainerController.js +0 -65
- package/dist/cjs/components/DragContainerController/DragContainerController.js.map +0 -7
- package/dist/cjs/components/DragControllerRow/DragControllerRow.js +0 -51
- package/dist/cjs/components/DragControllerRow/DragControllerRow.js.map +0 -7
- package/dist/cjs/components/FieldControllerRow/FieldControllerRow.js +0 -55
- package/dist/cjs/components/FieldControllerRow/FieldControllerRow.js.map +0 -7
- package/dist/cjs/components/Nestable/Nestable.js +0 -254
- package/dist/cjs/components/Nestable/Nestable.js.map +0 -7
- package/dist/cjs/components/Nestable/NestableItem.js +0 -119
- package/dist/cjs/components/Nestable/NestableItem.js.map +0 -7
- package/dist/cjs/components/Nestable/actions/events.js +0 -143
- package/dist/cjs/components/Nestable/actions/events.js.map +0 -7
- package/dist/cjs/components/Nestable/actions/getItemOptions.js +0 -49
- package/dist/cjs/components/Nestable/actions/getItemOptions.js.map +0 -7
- package/dist/cjs/components/Nestable/actions/getPaths.js +0 -119
- package/dist/cjs/components/Nestable/actions/getPaths.js.map +0 -7
- package/dist/cjs/components/Nestable/actions/index.js +0 -42
- package/dist/cjs/components/Nestable/actions/index.js.map +0 -7
- package/dist/cjs/components/Nestable/actions/moveItem.js +0 -56
- package/dist/cjs/components/Nestable/actions/moveItem.js.map +0 -7
- package/dist/cjs/components/Nestable/actions/paths.js +0 -119
- package/dist/cjs/components/Nestable/actions/paths.js.map +0 -7
- package/dist/cjs/components/Nestable/actions/tryDecreaseDepth.js +0 -51
- package/dist/cjs/components/Nestable/actions/tryDecreaseDepth.js.map +0 -7
- package/dist/cjs/components/Nestable/actions/tryIncreaseDepth.js +0 -51
- package/dist/cjs/components/Nestable/actions/tryIncreaseDepth.js.map +0 -7
- package/dist/cjs/components/Nestable/index.js +0 -36
- package/dist/cjs/components/Nestable/index.js.map +0 -7
- package/dist/cjs/components/QueryBuilderContext/QueryBuilderContext.js +0 -36
- package/dist/cjs/components/QueryBuilderContext/QueryBuilderContext.js.map +0 -7
- package/dist/cjs/components/QueryBuilderImpl.js +0 -225
- package/dist/cjs/components/QueryBuilderImpl.js.map +0 -7
- package/dist/cjs/components/QueryBuilderItem/QueryBuilderItem.js +0 -92
- package/dist/cjs/components/QueryBuilderItem/QueryBuilderItem.js.map +0 -7
- package/dist/cjs/components/QueryBuilderRow/QueryBuilderRow.js +0 -219
- package/dist/cjs/components/QueryBuilderRow/QueryBuilderRow.js.map +0 -7
- package/dist/cjs/components/ToolBarAnimation/ToolBarAnimation.js +0 -42
- package/dist/cjs/components/ToolBarAnimation/ToolBarAnimation.js.map +0 -7
- package/dist/cjs/components/format/format.js +0 -59
- package/dist/cjs/components/format/format.js.map +0 -7
- package/dist/cjs/components/format/sqlFormat.js +0 -94
- package/dist/cjs/components/format/sqlFormat.js.map +0 -7
- package/dist/cjs/components/format/sqlSafeFormat.js +0 -98
- package/dist/cjs/components/format/sqlSafeFormat.js.map +0 -7
- package/dist/cjs/components/format/xmlFormat.js +0 -94
- package/dist/cjs/components/format/xmlFormat.js.map +0 -7
- package/dist/cjs/components/helpers/actions.js +0 -242
- package/dist/cjs/components/helpers/actions.js.map +0 -7
- package/dist/cjs/components/helpers/constants.js +0 -39
- package/dist/cjs/components/helpers/constants.js.map +0 -7
- package/dist/cjs/components/helpers/dependencies.js +0 -69
- package/dist/cjs/components/helpers/dependencies.js.map +0 -7
- package/dist/cjs/components/helpers/selectors.js +0 -161
- package/dist/cjs/components/helpers/selectors.js.map +0 -7
- package/dist/cjs/components/helpers/store.js +0 -159
- package/dist/cjs/components/helpers/store.js.map +0 -7
- package/dist/cjs/components/helpers/types.js +0 -92
- package/dist/cjs/components/helpers/types.js.map +0 -7
- package/dist/cjs/index.js +0 -36
- package/dist/cjs/index.js.map +0 -7
- package/dist/cjs/propTypes.js +0 -105
- package/dist/cjs/propTypes.js.map +0 -7
- package/dist/esm/DSQueryBuilder.js +0 -105
- package/dist/esm/DSQueryBuilder.js.map +0 -7
- package/dist/esm/components/AndOrController/AndOrController.js +0 -179
- package/dist/esm/components/AndOrController/AndOrController.js.map +0 -7
- package/dist/esm/components/ConditionController/ConditionController.js +0 -87
- package/dist/esm/components/ConditionController/ConditionController.js.map +0 -7
- package/dist/esm/components/DisplayOutput/DisplayOutput.js +0 -63
- package/dist/esm/components/DisplayOutput/DisplayOutput.js.map +0 -7
- package/dist/esm/components/DragContainerController/DragContainerController.js +0 -36
- package/dist/esm/components/DragContainerController/DragContainerController.js.map +0 -7
- package/dist/esm/components/DragControllerRow/DragControllerRow.js +0 -22
- package/dist/esm/components/DragControllerRow/DragControllerRow.js.map +0 -7
- package/dist/esm/components/FieldControllerRow/FieldControllerRow.js +0 -26
- package/dist/esm/components/FieldControllerRow/FieldControllerRow.js.map +0 -7
- package/dist/esm/components/Nestable/Nestable.js +0 -241
- package/dist/esm/components/Nestable/Nestable.js.map +0 -7
- package/dist/esm/components/Nestable/NestableItem.js +0 -90
- package/dist/esm/components/Nestable/NestableItem.js.map +0 -7
- package/dist/esm/components/Nestable/actions/events.js +0 -119
- package/dist/esm/components/Nestable/actions/events.js.map +0 -7
- package/dist/esm/components/Nestable/actions/getItemOptions.js.map +0 -7
- package/dist/esm/components/Nestable/actions/getPaths.js.map +0 -7
- package/dist/esm/components/Nestable/actions/index.js +0 -13
- package/dist/esm/components/Nestable/actions/index.js.map +0 -7
- package/dist/esm/components/Nestable/actions/moveItem.js +0 -27
- package/dist/esm/components/Nestable/actions/moveItem.js.map +0 -7
- package/dist/esm/components/Nestable/actions/paths.js.map +0 -7
- package/dist/esm/components/Nestable/actions/tryDecreaseDepth.js +0 -22
- package/dist/esm/components/Nestable/actions/tryDecreaseDepth.js.map +0 -7
- package/dist/esm/components/Nestable/actions/tryIncreaseDepth.js.map +0 -7
- package/dist/esm/components/Nestable/index.js +0 -7
- package/dist/esm/components/Nestable/index.js.map +0 -7
- package/dist/esm/components/QueryBuilderContext/QueryBuilderContext.js +0 -7
- package/dist/esm/components/QueryBuilderContext/QueryBuilderContext.js.map +0 -7
- package/dist/esm/components/QueryBuilderImpl.js +0 -196
- package/dist/esm/components/QueryBuilderImpl.js.map +0 -7
- package/dist/esm/components/QueryBuilderItem/QueryBuilderItem.js +0 -63
- package/dist/esm/components/QueryBuilderItem/QueryBuilderItem.js.map +0 -7
- package/dist/esm/components/QueryBuilderRow/QueryBuilderRow.js +0 -190
- package/dist/esm/components/QueryBuilderRow/QueryBuilderRow.js.map +0 -7
- package/dist/esm/components/ToolBarAnimation/ToolBarAnimation.js +0 -13
- package/dist/esm/components/ToolBarAnimation/ToolBarAnimation.js.map +0 -7
- package/dist/esm/components/format/format.js +0 -30
- package/dist/esm/components/format/format.js.map +0 -7
- package/dist/esm/components/format/sqlFormat.js +0 -65
- package/dist/esm/components/format/sqlFormat.js.map +0 -7
- package/dist/esm/components/format/sqlSafeFormat.js +0 -69
- package/dist/esm/components/format/sqlSafeFormat.js.map +0 -7
- package/dist/esm/components/format/xmlFormat.js +0 -65
- package/dist/esm/components/format/xmlFormat.js.map +0 -7
- package/dist/esm/components/helpers/actions.js +0 -217
- package/dist/esm/components/helpers/actions.js.map +0 -7
- package/dist/esm/components/helpers/constants.js +0 -10
- package/dist/esm/components/helpers/constants.js.map +0 -7
- package/dist/esm/components/helpers/dependencies.js +0 -40
- package/dist/esm/components/helpers/dependencies.js.map +0 -7
- package/dist/esm/components/helpers/selectors.js +0 -132
- package/dist/esm/components/helpers/selectors.js.map +0 -7
- package/dist/esm/components/helpers/store.js +0 -143
- package/dist/esm/components/helpers/store.js.map +0 -7
- package/dist/esm/components/helpers/types.js +0 -63
- package/dist/esm/components/helpers/types.js.map +0 -7
- package/dist/esm/index.js +0 -7
- package/dist/esm/index.js.map +0 -7
- package/dist/esm/propTypes.js +0 -76
- package/dist/esm/propTypes.js.map +0 -7
|
@@ -0,0 +1,124 @@
|
|
|
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
|
+
|
|
14
|
+
function getRealNextPath(prevPath, nextPath) {
|
|
15
|
+
const {
|
|
16
|
+
childrenProp
|
|
17
|
+
} = this.props;
|
|
18
|
+
const ppLastIndex = prevPath.length - 1;
|
|
19
|
+
const npLastIndex = nextPath.length - 1;
|
|
20
|
+
|
|
21
|
+
if (prevPath.length < nextPath.length) {
|
|
22
|
+
// move into deep
|
|
23
|
+
let wasShifted = false;
|
|
24
|
+
return nextPath.map((nextIndex, i) => {
|
|
25
|
+
if (wasShifted) {
|
|
26
|
+
return i === npLastIndex ? nextIndex + 1 : nextIndex;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (typeof prevPath[i] !== 'number') {
|
|
30
|
+
return nextIndex;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (nextPath[i] > prevPath[i] && i === ppLastIndex) {
|
|
34
|
+
wasShifted = true;
|
|
35
|
+
return nextIndex - 1;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return nextIndex;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (prevPath.length === nextPath.length) {
|
|
43
|
+
// if move bottom + move to item with children => make it a first child instead of swap
|
|
44
|
+
if (nextPath[npLastIndex] > prevPath[npLastIndex]) {
|
|
45
|
+
const target = this.getItemByPath(nextPath);
|
|
46
|
+
|
|
47
|
+
if (target[childrenProp] && target[childrenProp].length && !this.isCollapsed(target)) {
|
|
48
|
+
return nextPath.slice(0, -1).concat(nextPath[npLastIndex] - 1).concat(0);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return nextPath;
|
|
54
|
+
}
|
|
55
|
+
function getPathById(id, items) {
|
|
56
|
+
const {
|
|
57
|
+
childrenProp
|
|
58
|
+
} = this.props;
|
|
59
|
+
let path = [];
|
|
60
|
+
items.every((item, i) => {
|
|
61
|
+
if (item.id === id) {
|
|
62
|
+
path.push(i);
|
|
63
|
+
} else if (item[childrenProp]) {
|
|
64
|
+
const childrenPath = this.getPathById(id, item[childrenProp]);
|
|
65
|
+
|
|
66
|
+
if (childrenPath.length) {
|
|
67
|
+
path = path.concat(i).concat(childrenPath);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return path.length === 0;
|
|
72
|
+
});
|
|
73
|
+
return path;
|
|
74
|
+
}
|
|
75
|
+
function getItemByPath(path, items) {
|
|
76
|
+
const {
|
|
77
|
+
childrenProp
|
|
78
|
+
} = this.props;
|
|
79
|
+
let item = null;
|
|
80
|
+
path.forEach(index => {
|
|
81
|
+
const list = item ? item[childrenProp] : items;
|
|
82
|
+
item = list[index];
|
|
83
|
+
});
|
|
84
|
+
return item;
|
|
85
|
+
}
|
|
86
|
+
function getItemDepth(item) {
|
|
87
|
+
const {
|
|
88
|
+
childrenProp
|
|
89
|
+
} = this.props;
|
|
90
|
+
let level = 1;
|
|
91
|
+
|
|
92
|
+
if (item[childrenProp].length > 0) {
|
|
93
|
+
const childrenDepths = item[childrenProp].map(this.getItemDepth);
|
|
94
|
+
level += Math.max(...childrenDepths);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return level;
|
|
98
|
+
}
|
|
99
|
+
function getSplicePath(path) {
|
|
100
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
101
|
+
const splicePath = {};
|
|
102
|
+
const numToRemove = options.numToRemove || 0;
|
|
103
|
+
const itemsToInsert = options.itemsToInsert || [];
|
|
104
|
+
const lastIndex = path.length - 1;
|
|
105
|
+
let currentPath = splicePath;
|
|
106
|
+
path.forEach((index, i) => {
|
|
107
|
+
if (i === lastIndex) {
|
|
108
|
+
currentPath.$splice = [[index, numToRemove, ...itemsToInsert]];
|
|
109
|
+
} else {
|
|
110
|
+
const nextPath = {};
|
|
111
|
+
currentPath[index] = {
|
|
112
|
+
[options.childrenProp]: nextPath
|
|
113
|
+
};
|
|
114
|
+
currentPath = nextPath;
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
return splicePath;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
exports.getItemByPath = getItemByPath;
|
|
121
|
+
exports.getItemDepth = getItemDepth;
|
|
122
|
+
exports.getPathById = getPathById;
|
|
123
|
+
exports.getRealNextPath = getRealNextPath;
|
|
124
|
+
exports.getSplicePath = getSplicePath;
|
|
@@ -0,0 +1,28 @@
|
|
|
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;
|
|
@@ -0,0 +1,54 @@
|
|
|
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
|
+
|
|
36
|
+
const realPathTo = this.getRealNextPath(pathFrom, pathTo);
|
|
37
|
+
const removePath = this.getSplicePath(pathFrom, {
|
|
38
|
+
numToRemove: 1,
|
|
39
|
+
childrenProp
|
|
40
|
+
});
|
|
41
|
+
const insertPath = this.getSplicePath(realPathTo, {
|
|
42
|
+
numToRemove: 0,
|
|
43
|
+
itemsToInsert: [dragItem],
|
|
44
|
+
childrenProp
|
|
45
|
+
});
|
|
46
|
+
items = update__default["default"](items, removePath);
|
|
47
|
+
items = update__default["default"](items, insertPath);
|
|
48
|
+
this.setState(_objectSpread({
|
|
49
|
+
items,
|
|
50
|
+
isDirty: true
|
|
51
|
+
}, extraProps));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
exports.moveItem = moveItem;
|
|
@@ -0,0 +1,126 @@
|
|
|
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
|
+
|
|
14
|
+
function getRealNextPath(prevPath, nextPath) {
|
|
15
|
+
const {
|
|
16
|
+
childrenProp
|
|
17
|
+
} = this.props;
|
|
18
|
+
const ppLastIndex = prevPath.length - 1;
|
|
19
|
+
const npLastIndex = nextPath.length - 1;
|
|
20
|
+
|
|
21
|
+
if (prevPath.length < nextPath.length) {
|
|
22
|
+
// move into deep
|
|
23
|
+
let wasShifted = false;
|
|
24
|
+
return nextPath.map((nextIndex, i) => {
|
|
25
|
+
if (wasShifted) {
|
|
26
|
+
return i === npLastIndex ? nextIndex + 1 : nextIndex;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (typeof prevPath[i] !== 'number') {
|
|
30
|
+
return nextIndex;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (nextPath[i] > prevPath[i] && i === ppLastIndex) {
|
|
34
|
+
wasShifted = true;
|
|
35
|
+
return nextIndex - 1;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return nextIndex;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (prevPath.length === nextPath.length) {
|
|
43
|
+
// if move bottom + move to item with children => make it a first child instead of swap
|
|
44
|
+
if (nextPath[npLastIndex] > prevPath[npLastIndex]) {
|
|
45
|
+
const target = this.getItemByPath(nextPath);
|
|
46
|
+
|
|
47
|
+
if (target[childrenProp] && target[childrenProp].length && !this.isCollapsed(target)) {
|
|
48
|
+
return nextPath.slice(0, -1).concat(nextPath[npLastIndex] - 1).concat(0);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return nextPath;
|
|
54
|
+
}
|
|
55
|
+
function getPathById(id) {
|
|
56
|
+
let items = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getDefaultItems();
|
|
57
|
+
const {
|
|
58
|
+
childrenProp
|
|
59
|
+
} = this.props;
|
|
60
|
+
let path = [];
|
|
61
|
+
items.every((item, i) => {
|
|
62
|
+
if (item.id === id) {
|
|
63
|
+
path.push(i);
|
|
64
|
+
} else if (item[childrenProp]) {
|
|
65
|
+
const childrenPath = this.getPathById(id, item[childrenProp]);
|
|
66
|
+
|
|
67
|
+
if (childrenPath.length) {
|
|
68
|
+
path = path.concat(i).concat(childrenPath);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return path.length === 0;
|
|
73
|
+
});
|
|
74
|
+
return path;
|
|
75
|
+
}
|
|
76
|
+
function getItemByPath(path) {
|
|
77
|
+
let items = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getDefaultItems();
|
|
78
|
+
const {
|
|
79
|
+
childrenProp
|
|
80
|
+
} = this.props;
|
|
81
|
+
let item = null;
|
|
82
|
+
path.forEach(index => {
|
|
83
|
+
const list = item ? item[childrenProp] : items;
|
|
84
|
+
item = list[index];
|
|
85
|
+
});
|
|
86
|
+
return item;
|
|
87
|
+
}
|
|
88
|
+
function getItemDepth(item) {
|
|
89
|
+
const {
|
|
90
|
+
childrenProp
|
|
91
|
+
} = this.props;
|
|
92
|
+
let level = 1;
|
|
93
|
+
|
|
94
|
+
if (item[childrenProp].length > 0) {
|
|
95
|
+
const childrenDepths = item[childrenProp].map(this.getItemDepth);
|
|
96
|
+
level += Math.max(...childrenDepths);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return level;
|
|
100
|
+
}
|
|
101
|
+
function getSplicePath(path) {
|
|
102
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
103
|
+
const splicePath = {};
|
|
104
|
+
const numToRemove = options.numToRemove || 0;
|
|
105
|
+
const itemsToInsert = options.itemsToInsert || [];
|
|
106
|
+
const lastIndex = path.length - 1;
|
|
107
|
+
let currentPath = splicePath;
|
|
108
|
+
path.forEach((index, i) => {
|
|
109
|
+
if (i === lastIndex) {
|
|
110
|
+
currentPath.$splice = [[index, numToRemove, ...itemsToInsert]];
|
|
111
|
+
} else {
|
|
112
|
+
const nextPath = {};
|
|
113
|
+
currentPath[index] = {
|
|
114
|
+
[options.childrenProp]: nextPath
|
|
115
|
+
};
|
|
116
|
+
currentPath = nextPath;
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
return splicePath;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
exports.getItemByPath = getItemByPath;
|
|
123
|
+
exports.getItemDepth = getItemDepth;
|
|
124
|
+
exports.getPathById = getPathById;
|
|
125
|
+
exports.getRealNextPath = getRealNextPath;
|
|
126
|
+
exports.getSplicePath = getSplicePath;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
function tryDecreaseDepth(dragItem) {
|
|
6
|
+
const {
|
|
7
|
+
childrenProp,
|
|
8
|
+
collapsed
|
|
9
|
+
} = this.props;
|
|
10
|
+
const pathFrom = this.getPathById(dragItem.id);
|
|
11
|
+
const itemIndex = pathFrom[pathFrom.length - 1]; // has parent
|
|
12
|
+
|
|
13
|
+
if (pathFrom.length > 1) {
|
|
14
|
+
const parent = this.getItemByPath(pathFrom.slice(0, -1)); // is last (by order) item in array
|
|
15
|
+
|
|
16
|
+
if (itemIndex + 1 === parent[childrenProp].length) {
|
|
17
|
+
const pathTo = pathFrom.slice(0, -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
|
+
|
|
20
|
+
let collapseProps = {};
|
|
21
|
+
|
|
22
|
+
if (collapsed && parent[childrenProp].length === 1) {
|
|
23
|
+
collapseProps = this.onToggleCollapse(parent, true);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
this.moveItem({
|
|
27
|
+
dragItem,
|
|
28
|
+
pathFrom,
|
|
29
|
+
pathTo
|
|
30
|
+
}, collapseProps);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
exports.tryDecreaseDepth = tryDecreaseDepth;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
function tryIncreaseDepth(dragItem) {
|
|
6
|
+
const {
|
|
7
|
+
maxDepth,
|
|
8
|
+
childrenProp,
|
|
9
|
+
collapsed
|
|
10
|
+
} = this.props;
|
|
11
|
+
const pathFrom = this.getPathById(dragItem.id);
|
|
12
|
+
const itemIndex = pathFrom[pathFrom.length - 1];
|
|
13
|
+
const newDepth = pathFrom.length + this.getItemDepth(dragItem); // has previous sibling and isn't at max depth
|
|
14
|
+
|
|
15
|
+
if (itemIndex > 0 && newDepth <= maxDepth) {
|
|
16
|
+
const prevSibling = this.getItemByPath(pathFrom.slice(0, -1).concat(itemIndex - 1)); // previous sibling is not collapsed
|
|
17
|
+
|
|
18
|
+
if (!prevSibling[childrenProp].length || !this.isCollapsed(prevSibling)) {
|
|
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
|
+
|
|
23
|
+
let collapseProps = {};
|
|
24
|
+
|
|
25
|
+
if (collapsed && !prevSibling[childrenProp].length) {
|
|
26
|
+
collapseProps = this.onToggleCollapse(prevSibling, true);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
this.moveItem({
|
|
30
|
+
dragItem,
|
|
31
|
+
pathFrom,
|
|
32
|
+
pathTo
|
|
33
|
+
}, collapseProps);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
exports.tryIncreaseDepth = tryIncreaseDepth;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
|
|
7
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
|
+
|
|
9
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
10
|
+
|
|
11
|
+
const QueryBuilderContext = /*#__PURE__*/React__default["default"].createContext({});
|
|
12
|
+
|
|
13
|
+
exports.QueryBuilderContext = QueryBuilderContext;
|