@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,69 +1,101 @@
|
|
|
1
|
-
import
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.map.js';
|
|
3
|
+
import 'core-js/modules/esnext.async-iterator.every.js';
|
|
4
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.every.js';
|
|
6
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
7
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
8
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
9
|
+
|
|
2
10
|
function getRealNextPath(prevPath, nextPath) {
|
|
3
|
-
const {
|
|
11
|
+
const {
|
|
12
|
+
childrenProp
|
|
13
|
+
} = this.props;
|
|
4
14
|
const ppLastIndex = prevPath.length - 1;
|
|
5
15
|
const npLastIndex = nextPath.length - 1;
|
|
16
|
+
|
|
6
17
|
if (prevPath.length < nextPath.length) {
|
|
18
|
+
// move into deep
|
|
7
19
|
let wasShifted = false;
|
|
8
20
|
return nextPath.map((nextIndex, i) => {
|
|
9
21
|
if (wasShifted) {
|
|
10
22
|
return i === npLastIndex ? nextIndex + 1 : nextIndex;
|
|
11
23
|
}
|
|
12
|
-
|
|
24
|
+
|
|
25
|
+
if (typeof prevPath[i] !== 'number') {
|
|
13
26
|
return nextIndex;
|
|
14
27
|
}
|
|
28
|
+
|
|
15
29
|
if (nextPath[i] > prevPath[i] && i === ppLastIndex) {
|
|
16
30
|
wasShifted = true;
|
|
17
31
|
return nextIndex - 1;
|
|
18
32
|
}
|
|
33
|
+
|
|
19
34
|
return nextIndex;
|
|
20
35
|
});
|
|
21
36
|
}
|
|
37
|
+
|
|
22
38
|
if (prevPath.length === nextPath.length) {
|
|
39
|
+
// if move bottom + move to item with children => make it a first child instead of swap
|
|
23
40
|
if (nextPath[npLastIndex] > prevPath[npLastIndex]) {
|
|
24
41
|
const target = this.getItemByPath(nextPath);
|
|
42
|
+
|
|
25
43
|
if (target[childrenProp] && target[childrenProp].length && !this.isCollapsed(target)) {
|
|
26
44
|
return nextPath.slice(0, -1).concat(nextPath[npLastIndex] - 1).concat(0);
|
|
27
45
|
}
|
|
28
46
|
}
|
|
29
47
|
}
|
|
48
|
+
|
|
30
49
|
return nextPath;
|
|
31
50
|
}
|
|
32
|
-
function getPathById(id
|
|
33
|
-
|
|
51
|
+
function getPathById(id) {
|
|
52
|
+
let items = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getDefaultItems();
|
|
53
|
+
const {
|
|
54
|
+
childrenProp
|
|
55
|
+
} = this.props;
|
|
34
56
|
let path = [];
|
|
35
57
|
items.every((item, i) => {
|
|
36
58
|
if (item.id === id) {
|
|
37
59
|
path.push(i);
|
|
38
60
|
} else if (item[childrenProp]) {
|
|
39
61
|
const childrenPath = this.getPathById(id, item[childrenProp]);
|
|
62
|
+
|
|
40
63
|
if (childrenPath.length) {
|
|
41
64
|
path = path.concat(i).concat(childrenPath);
|
|
42
65
|
}
|
|
43
66
|
}
|
|
67
|
+
|
|
44
68
|
return path.length === 0;
|
|
45
69
|
});
|
|
46
70
|
return path;
|
|
47
71
|
}
|
|
48
|
-
function getItemByPath(path
|
|
49
|
-
|
|
72
|
+
function getItemByPath(path) {
|
|
73
|
+
let items = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getDefaultItems();
|
|
74
|
+
const {
|
|
75
|
+
childrenProp
|
|
76
|
+
} = this.props;
|
|
50
77
|
let item = null;
|
|
51
|
-
path.forEach(
|
|
78
|
+
path.forEach(index => {
|
|
52
79
|
const list = item ? item[childrenProp] : items;
|
|
53
80
|
item = list[index];
|
|
54
81
|
});
|
|
55
82
|
return item;
|
|
56
83
|
}
|
|
57
84
|
function getItemDepth(item) {
|
|
58
|
-
const {
|
|
85
|
+
const {
|
|
86
|
+
childrenProp
|
|
87
|
+
} = this.props;
|
|
59
88
|
let level = 1;
|
|
89
|
+
|
|
60
90
|
if (item[childrenProp].length > 0) {
|
|
61
91
|
const childrenDepths = item[childrenProp].map(this.getItemDepth);
|
|
62
92
|
level += Math.max(...childrenDepths);
|
|
63
93
|
}
|
|
94
|
+
|
|
64
95
|
return level;
|
|
65
96
|
}
|
|
66
|
-
function getSplicePath(path
|
|
97
|
+
function getSplicePath(path) {
|
|
98
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
67
99
|
const splicePath = {};
|
|
68
100
|
const numToRemove = options.numToRemove || 0;
|
|
69
101
|
const itemsToInsert = options.itemsToInsert || [];
|
|
@@ -74,17 +106,13 @@ function getSplicePath(path, options = {}) {
|
|
|
74
106
|
currentPath.$splice = [[index, numToRemove, ...itemsToInsert]];
|
|
75
107
|
} else {
|
|
76
108
|
const nextPath = {};
|
|
77
|
-
currentPath[index] = {
|
|
109
|
+
currentPath[index] = {
|
|
110
|
+
[options.childrenProp]: nextPath
|
|
111
|
+
};
|
|
78
112
|
currentPath = nextPath;
|
|
79
113
|
}
|
|
80
114
|
});
|
|
81
115
|
return splicePath;
|
|
82
116
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
getItemDepth,
|
|
86
|
-
getPathById,
|
|
87
|
-
getRealNextPath,
|
|
88
|
-
getSplicePath
|
|
89
|
-
};
|
|
90
|
-
//# sourceMappingURL=paths.js.map
|
|
117
|
+
|
|
118
|
+
export { getItemByPath, getItemDepth, getPathById, getRealNextPath, getSplicePath };
|
|
@@ -1,22 +1,31 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
1
|
function tryDecreaseDepth(dragItem) {
|
|
3
|
-
const {
|
|
2
|
+
const {
|
|
3
|
+
childrenProp,
|
|
4
|
+
collapsed
|
|
5
|
+
} = this.props;
|
|
4
6
|
const pathFrom = this.getPathById(dragItem.id);
|
|
5
|
-
const itemIndex = pathFrom[pathFrom.length - 1];
|
|
7
|
+
const itemIndex = pathFrom[pathFrom.length - 1]; // has parent
|
|
8
|
+
|
|
6
9
|
if (pathFrom.length > 1) {
|
|
7
|
-
const parent = this.getItemByPath(pathFrom.slice(0, -1));
|
|
10
|
+
const parent = this.getItemByPath(pathFrom.slice(0, -1)); // is last (by order) item in array
|
|
11
|
+
|
|
8
12
|
if (itemIndex + 1 === parent[childrenProp].length) {
|
|
9
13
|
const pathTo = pathFrom.slice(0, -1);
|
|
10
|
-
pathTo[pathTo.length - 1] += 1;
|
|
14
|
+
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
|
|
15
|
+
|
|
11
16
|
let collapseProps = {};
|
|
17
|
+
|
|
12
18
|
if (collapsed && parent[childrenProp].length === 1) {
|
|
13
19
|
collapseProps = this.onToggleCollapse(parent, true);
|
|
14
20
|
}
|
|
15
|
-
|
|
21
|
+
|
|
22
|
+
this.moveItem({
|
|
23
|
+
dragItem,
|
|
24
|
+
pathFrom,
|
|
25
|
+
pathTo
|
|
26
|
+
}, collapseProps);
|
|
16
27
|
}
|
|
17
28
|
}
|
|
18
29
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
};
|
|
22
|
-
//# sourceMappingURL=tryDecreaseDepth.js.map
|
|
30
|
+
|
|
31
|
+
export { tryDecreaseDepth };
|
|
@@ -1,22 +1,34 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
1
|
function tryIncreaseDepth(dragItem) {
|
|
3
|
-
const {
|
|
2
|
+
const {
|
|
3
|
+
maxDepth,
|
|
4
|
+
childrenProp,
|
|
5
|
+
collapsed
|
|
6
|
+
} = this.props;
|
|
4
7
|
const pathFrom = this.getPathById(dragItem.id);
|
|
5
8
|
const itemIndex = pathFrom[pathFrom.length - 1];
|
|
6
|
-
const newDepth = pathFrom.length + this.getItemDepth(dragItem);
|
|
9
|
+
const newDepth = pathFrom.length + this.getItemDepth(dragItem); // has previous sibling and isn't at max depth
|
|
10
|
+
|
|
7
11
|
if (itemIndex > 0 && newDepth <= maxDepth) {
|
|
8
|
-
const prevSibling = this.getItemByPath(pathFrom.slice(0, -1).concat(itemIndex - 1));
|
|
12
|
+
const prevSibling = this.getItemByPath(pathFrom.slice(0, -1).concat(itemIndex - 1)); // previous sibling is not collapsed
|
|
13
|
+
|
|
9
14
|
if (!prevSibling[childrenProp].length || !this.isCollapsed(prevSibling)) {
|
|
10
|
-
const pathTo = pathFrom.slice(0, -1).concat(itemIndex - 1).concat(prevSibling[childrenProp].length);
|
|
15
|
+
const pathTo = pathFrom.slice(0, -1).concat(itemIndex - 1).concat(prevSibling[childrenProp].length); // if collapsed by default
|
|
16
|
+
// and was no children here
|
|
17
|
+
// open this node
|
|
18
|
+
|
|
11
19
|
let collapseProps = {};
|
|
20
|
+
|
|
12
21
|
if (collapsed && !prevSibling[childrenProp].length) {
|
|
13
22
|
collapseProps = this.onToggleCollapse(prevSibling, true);
|
|
14
23
|
}
|
|
15
|
-
|
|
24
|
+
|
|
25
|
+
this.moveItem({
|
|
26
|
+
dragItem,
|
|
27
|
+
pathFrom,
|
|
28
|
+
pathTo
|
|
29
|
+
}, collapseProps);
|
|
16
30
|
}
|
|
17
31
|
}
|
|
18
32
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
};
|
|
22
|
-
//# sourceMappingURL=tryIncreaseDepth.js.map
|
|
33
|
+
|
|
34
|
+
export { tryIncreaseDepth };
|
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
var Nestable_default = Nestable;
|
|
4
|
-
export {
|
|
5
|
-
Nestable_default as default
|
|
6
|
-
};
|
|
7
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import Nestable from './Nestable.js';
|
|
2
|
+
export { default } from './Nestable.js';
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
const QueryBuilderContext =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
};
|
|
7
|
-
//# sourceMappingURL=QueryBuilderContext.js.map
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
const QueryBuilderContext = /*#__PURE__*/React.createContext({});
|
|
4
|
+
|
|
5
|
+
export { QueryBuilderContext };
|
|
@@ -1,127 +1,231 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
6
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
7
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
|
|
8
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
9
|
+
import { Component } from 'react';
|
|
10
|
+
import Nestable from './Nestable/Nestable.js';
|
|
11
|
+
import { QueryBuilderContext } from './QueryBuilderContext/QueryBuilderContext.js';
|
|
12
|
+
import { QB_ADD_FILTER_METHOD_TYPES, QB_GROUP_FILTER_METHOD_TYPES, QB_DRAG_TYPES } from './helpers/types.js';
|
|
13
|
+
import QueryBuilderStore from './helpers/store.js';
|
|
14
|
+
import AndOrController from './AndOrController/AndOrController.js';
|
|
15
|
+
import QueryBuilderItem from './QueryBuilderItem/QueryBuilderItem.js';
|
|
16
|
+
import DisplayOutput from './DisplayOutput/DisplayOutput.js';
|
|
17
|
+
import { jsxs } from 'react/jsx-runtime';
|
|
18
|
+
|
|
19
|
+
const _excluded = ["format"];
|
|
20
|
+
|
|
21
|
+
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; }
|
|
22
|
+
|
|
23
|
+
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(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; }
|
|
24
|
+
|
|
10
25
|
class QueryBuilderImpl extends Component {
|
|
11
26
|
constructor(props) {
|
|
12
27
|
super(props);
|
|
13
28
|
this.isDraggableItem = true;
|
|
29
|
+
|
|
14
30
|
this.onOrderDragAndDrop = (items, item) => {
|
|
15
31
|
const newFilters = this.store.onOrderDragAndDrop(items, item);
|
|
16
|
-
this.sendCall(
|
|
32
|
+
this.sendCall('reOrderOnDragAndDrop', {
|
|
33
|
+
items
|
|
34
|
+
});
|
|
17
35
|
this.sendChange(newFilters);
|
|
18
36
|
};
|
|
19
|
-
|
|
37
|
+
|
|
38
|
+
this.onAddFilterToGroup = idGroup => {
|
|
20
39
|
const newFilters = this.store.addFilter(idGroup);
|
|
21
|
-
this.sendCall(
|
|
40
|
+
this.sendCall('onAddFilterToGroup', {
|
|
41
|
+
idGroup
|
|
42
|
+
});
|
|
22
43
|
this.sendChange(newFilters);
|
|
23
44
|
};
|
|
45
|
+
|
|
24
46
|
this.onAddFilter = (idGroup, idFilter) => {
|
|
25
|
-
const {
|
|
47
|
+
const {
|
|
48
|
+
addFilterMethod
|
|
49
|
+
} = this.props;
|
|
26
50
|
const newFilters = addFilterMethod === QB_ADD_FILTER_METHOD_TYPES.IN_PLACE ? this.store.addFilterNextToFilterId(idGroup, idFilter) : this.onAddFilterToGroup(idGroup);
|
|
27
|
-
this.sendCall(
|
|
51
|
+
this.sendCall('onAddFilter', {
|
|
52
|
+
idGroup,
|
|
53
|
+
idFilter
|
|
54
|
+
});
|
|
28
55
|
this.sendChange(newFilters);
|
|
29
56
|
};
|
|
57
|
+
|
|
30
58
|
this.onAddRuleContainer = (idGroup, idFilter) => {
|
|
31
|
-
const {
|
|
59
|
+
const {
|
|
60
|
+
groupFilterMethod
|
|
61
|
+
} = this.props;
|
|
32
62
|
const newFilters = groupFilterMethod === QB_GROUP_FILTER_METHOD_TYPES.IN_PLACE ? this.store.addRuleContainerInPlace(idGroup, idFilter) : this.store.addRuleContainer(idGroup, idFilter);
|
|
33
|
-
this.sendCall(
|
|
63
|
+
this.sendCall('onAddRuleContainer', {
|
|
64
|
+
idGroup,
|
|
65
|
+
idFilter
|
|
66
|
+
});
|
|
34
67
|
this.sendChange(newFilters);
|
|
35
68
|
};
|
|
36
|
-
|
|
69
|
+
|
|
70
|
+
this.onRemoveFilter = idFilter => {
|
|
37
71
|
const newFilters = this.store.onRemoveFilter(idFilter);
|
|
38
|
-
this.sendCall(
|
|
72
|
+
this.sendCall('onRemoveFilter', {
|
|
73
|
+
idFilter
|
|
74
|
+
});
|
|
39
75
|
this.sendChange(newFilters);
|
|
40
76
|
};
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
|
|
77
|
+
|
|
78
|
+
this.handleFieldChange = data => {
|
|
79
|
+
const {
|
|
80
|
+
fieldsSharedActions
|
|
81
|
+
} = this.props;
|
|
82
|
+
const newFilters = this.store.changeFilter(_objectSpread(_objectSpread({}, data), {}, {
|
|
45
83
|
fieldsSharedActions
|
|
84
|
+
}));
|
|
85
|
+
this.sendCall('handleFieldChange', {
|
|
86
|
+
data
|
|
46
87
|
});
|
|
47
|
-
this.sendCall("handleFieldChange", { data });
|
|
48
88
|
this.sendChange(newFilters);
|
|
49
89
|
};
|
|
90
|
+
|
|
50
91
|
this.handleRuleContainerOperator = (idGroup, value) => {
|
|
51
92
|
const newFilters = this.store.changeGroupOperator(idGroup, value);
|
|
52
|
-
this.sendCall(
|
|
93
|
+
this.sendCall('handleRuleContainerOperator', {
|
|
94
|
+
idGroup,
|
|
95
|
+
value
|
|
96
|
+
});
|
|
53
97
|
this.sendChange(newFilters);
|
|
54
98
|
};
|
|
55
|
-
|
|
99
|
+
|
|
100
|
+
this.handleRuleContainerUnGroup = idGroup => {
|
|
56
101
|
const newFilters = this.store.unGroup(idGroup);
|
|
57
|
-
this.sendCall(
|
|
102
|
+
this.sendCall('handleRuleContainerUnGroup', {
|
|
103
|
+
idGroup
|
|
104
|
+
});
|
|
58
105
|
this.sendChange(newFilters);
|
|
59
106
|
};
|
|
107
|
+
|
|
60
108
|
this.handleDropFilter = (filter, dragTo) => {
|
|
61
|
-
const {
|
|
62
|
-
|
|
109
|
+
const {
|
|
110
|
+
position: oldPosition,
|
|
111
|
+
idGroup,
|
|
112
|
+
idFilter
|
|
113
|
+
} = filter;
|
|
114
|
+
const {
|
|
115
|
+
position: newPosition,
|
|
116
|
+
targetIdGroup
|
|
117
|
+
} = dragTo;
|
|
63
118
|
const newFilters = this.store.reOrderFilter(idFilter, idGroup, oldPosition, newPosition, targetIdGroup);
|
|
64
|
-
this.sendCall(
|
|
119
|
+
this.sendCall('handleDropFilter', {
|
|
120
|
+
filter,
|
|
121
|
+
dragTo
|
|
122
|
+
});
|
|
65
123
|
this.sendChange(newFilters);
|
|
66
124
|
};
|
|
125
|
+
|
|
67
126
|
this.handleDropGroup = (group, dragTo) => {
|
|
68
|
-
const {
|
|
69
|
-
|
|
127
|
+
const {
|
|
128
|
+
position: oldPosition,
|
|
129
|
+
idFilter,
|
|
130
|
+
idGroup
|
|
131
|
+
} = group;
|
|
132
|
+
const {
|
|
133
|
+
position: newPosition,
|
|
134
|
+
targetIdGroup
|
|
135
|
+
} = dragTo;
|
|
70
136
|
const newFilters = this.store.reOrderFilter(idFilter, idGroup, oldPosition, newPosition, targetIdGroup);
|
|
71
|
-
this.sendCall(
|
|
137
|
+
this.sendCall('handleDropGroup', {
|
|
138
|
+
group,
|
|
139
|
+
dragTo
|
|
140
|
+
});
|
|
72
141
|
this.sendChange(newFilters);
|
|
73
142
|
};
|
|
143
|
+
|
|
74
144
|
this.handleDrop = (dragElement, dragTo) => {
|
|
75
|
-
const {
|
|
76
|
-
|
|
77
|
-
|
|
145
|
+
const {
|
|
146
|
+
type
|
|
147
|
+
} = dragElement;
|
|
148
|
+
if (type === QB_DRAG_TYPES.FILTER) return this.handleDropFilter(dragElement, dragTo);
|
|
78
149
|
return this.handleDropGroup(dragElement, dragTo);
|
|
79
150
|
};
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
151
|
+
|
|
152
|
+
this.sendChange = _ref => {
|
|
153
|
+
let {
|
|
154
|
+
format
|
|
155
|
+
} = _ref,
|
|
156
|
+
newFilters = _objectWithoutProperties(_ref, _excluded);
|
|
157
|
+
|
|
158
|
+
this.setState(_objectSpread({
|
|
159
|
+
format
|
|
160
|
+
}, newFilters));
|
|
161
|
+
const {
|
|
162
|
+
onChange
|
|
163
|
+
} = this.props;
|
|
83
164
|
onChange(format, newFilters);
|
|
84
165
|
};
|
|
166
|
+
|
|
85
167
|
this.sendCall = (action, data) => {
|
|
86
|
-
const {
|
|
87
|
-
|
|
88
|
-
|
|
168
|
+
const {
|
|
169
|
+
[action]: callback
|
|
170
|
+
} = this.props;
|
|
171
|
+
if (callback) callback(data);
|
|
89
172
|
};
|
|
90
|
-
|
|
173
|
+
|
|
174
|
+
this.setDraggableItems = drag => {
|
|
91
175
|
this.isDraggableItem = true;
|
|
176
|
+
|
|
92
177
|
try {
|
|
93
178
|
const ua = window.navigator.userAgent;
|
|
94
|
-
const msie = ua.indexOf(
|
|
179
|
+
const msie = ua.indexOf('MSIE '); // eslint-disable-next-line no-useless-escape
|
|
180
|
+
|
|
95
181
|
if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) {
|
|
96
|
-
const {
|
|
182
|
+
const {
|
|
183
|
+
isDraggableItem
|
|
184
|
+
} = this.state;
|
|
185
|
+
|
|
97
186
|
if (drag !== isDraggableItem) {
|
|
98
|
-
this.setState({
|
|
187
|
+
this.setState({
|
|
188
|
+
isDraggableItem: drag
|
|
189
|
+
});
|
|
99
190
|
}
|
|
191
|
+
|
|
100
192
|
this.isDraggableItem = drag;
|
|
101
193
|
}
|
|
102
194
|
} catch (error) {
|
|
103
195
|
this.isDraggableItem = true;
|
|
104
196
|
}
|
|
105
197
|
};
|
|
198
|
+
|
|
106
199
|
this.store = new QueryBuilderStore(props.init, props.format);
|
|
107
200
|
this.state = this.store.getInitialState();
|
|
108
201
|
}
|
|
202
|
+
|
|
109
203
|
static getDerivedStateFromProps(props, state) {
|
|
110
|
-
if (props.init && props.init.step !==
|
|
204
|
+
if (props.init && props.init.step !== undefined && Number.isInteger(props.init.step) && props.init.step !== state.step) {
|
|
111
205
|
const store = new QueryBuilderStore(props.init, props.format);
|
|
112
206
|
QueryBuilderImpl.recalculateStore = store;
|
|
113
207
|
return store.getInitialState();
|
|
114
208
|
}
|
|
209
|
+
|
|
115
210
|
return null;
|
|
116
211
|
}
|
|
212
|
+
|
|
117
213
|
componentDidUpdate() {
|
|
118
214
|
if (QueryBuilderImpl.recalculateStore) {
|
|
119
215
|
this.store = QueryBuilderImpl.recalculateStore;
|
|
120
216
|
QueryBuilderImpl.recalculateStore = null;
|
|
121
217
|
}
|
|
122
218
|
}
|
|
219
|
+
|
|
123
220
|
render() {
|
|
124
|
-
const {
|
|
221
|
+
const {
|
|
222
|
+
mapGroups,
|
|
223
|
+
main,
|
|
224
|
+
mapFilters,
|
|
225
|
+
step,
|
|
226
|
+
items,
|
|
227
|
+
format
|
|
228
|
+
} = this.state;
|
|
125
229
|
const {
|
|
126
230
|
containerProps,
|
|
127
231
|
ruleContainerClassName,
|
|
@@ -131,9 +235,12 @@ class QueryBuilderImpl extends Component {
|
|
|
131
235
|
displayOutputLabel,
|
|
132
236
|
singleRow,
|
|
133
237
|
toolTipZIndex
|
|
134
|
-
} = this.props;
|
|
135
|
-
|
|
136
|
-
|
|
238
|
+
} = this.props; // const { children } = items[0]
|
|
239
|
+
|
|
240
|
+
const {
|
|
241
|
+
condition
|
|
242
|
+
} = mapGroups[main];
|
|
243
|
+
return /*#__PURE__*/_jsx(QueryBuilderContext.Provider, {
|
|
137
244
|
value: {
|
|
138
245
|
toolTipZIndex,
|
|
139
246
|
fields,
|
|
@@ -156,41 +263,39 @@ class QueryBuilderImpl extends Component {
|
|
|
156
263
|
setDraggableItems: this.setDraggableItems,
|
|
157
264
|
singleRow
|
|
158
265
|
}
|
|
159
|
-
},
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
singleRow
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
}))
|
|
185
|
-
displayFixedOutput,
|
|
266
|
+
}, void 0, /*#__PURE__*/jsxs("div", _objectSpread(_objectSpread({}, containerProps), {}, {
|
|
267
|
+
className: "nested-main-group ".concat(condition !== true ? 'is-or-group' : 'is-and-groupL', " ").concat(singleRow ? 'query-main-single-row' : 'query-main-multiple-row'),
|
|
268
|
+
children: [/*#__PURE__*/_jsx(Nestable, {
|
|
269
|
+
isAndItem: condition === true,
|
|
270
|
+
isDraggableItem: this.isDraggableItem,
|
|
271
|
+
isOrItem: condition !== true,
|
|
272
|
+
items: items,
|
|
273
|
+
onChange: this.onOrderDragAndDrop,
|
|
274
|
+
renderItem: QueryBuilderItem,
|
|
275
|
+
setDraggableItems: this.setDraggableItems,
|
|
276
|
+
step: step,
|
|
277
|
+
singleRow: singleRow
|
|
278
|
+
}), !singleRow && /*#__PURE__*/_jsx("div", {
|
|
279
|
+
className: "rule-container-options"
|
|
280
|
+
}, void 0, /*#__PURE__*/_jsx(AndOrController, {
|
|
281
|
+
allowUnGroup: false,
|
|
282
|
+
condition: condition,
|
|
283
|
+
handleRuleContainerOperator: value => this.handleRuleContainerOperator(main, value),
|
|
284
|
+
handleRuleContainerUnGroup: () => this.handleRuleContainerUnGroup(main),
|
|
285
|
+
isMain: true,
|
|
286
|
+
onAddFilter: () => this.onAddFilterToGroup(main),
|
|
287
|
+
showDragController: false,
|
|
288
|
+
step: step,
|
|
289
|
+
toolTipZIndex: toolTipZIndex
|
|
290
|
+
}))]
|
|
291
|
+
})), (displayOutput || displayFixedOutput) && /*#__PURE__*/_jsx(DisplayOutput, {
|
|
292
|
+
displayFixedOutput: displayFixedOutput,
|
|
186
293
|
hideLabel: displayOutputLabel.hide,
|
|
187
294
|
showLabel: displayOutputLabel.show,
|
|
188
295
|
show: displayOutputLabel.open
|
|
189
296
|
}));
|
|
190
297
|
}
|
|
298
|
+
|
|
191
299
|
}
|
|
192
|
-
|
|
193
|
-
export {
|
|
194
|
-
QueryBuilderImpl_default as default
|
|
195
|
-
};
|
|
196
|
-
//# sourceMappingURL=QueryBuilderImpl.js.map
|
|
300
|
+
|
|
301
|
+
export { QueryBuilderImpl as default };
|