@elliemae/ds-query-builder 2.0.0-next.9 → 2.0.0-rc.12
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 +60 -56
- package/cjs/components/AndOrController/AndOrController.js +26 -34
- package/cjs/components/ConditionController/ConditionController.js +26 -32
- package/cjs/components/DisplayOutput/DisplayOutput.js +20 -21
- package/cjs/components/DragContainerController/DragContainerController.js +13 -15
- package/cjs/components/DragControllerRow/DragControllerRow.js +10 -6
- package/cjs/components/FieldControllerRow/FieldControllerRow.js +22 -22
- package/cjs/components/Nestable/Nestable.js +44 -30
- package/cjs/components/Nestable/NestableItem.js +18 -10
- package/cjs/components/Nestable/actions/events.js +5 -0
- package/cjs/components/Nestable/actions/getPaths.js +9 -1
- package/cjs/components/Nestable/actions/moveItem.js +12 -5
- package/cjs/components/Nestable/actions/paths.js +13 -3
- package/cjs/components/QueryBuilderImpl.js +34 -30
- package/cjs/components/QueryBuilderItem/QueryBuilderItem.js +28 -20
- package/cjs/components/QueryBuilderRow/QueryBuilderRow.js +42 -33
- package/cjs/components/ToolBarAnimation/ToolBarAnimation.js +5 -0
- package/cjs/components/format/format.js +8 -14
- package/cjs/components/format/sqlFormat.js +9 -7
- package/cjs/components/format/sqlSafeFormat.js +9 -7
- package/cjs/components/format/xmlFormat.js +9 -7
- package/cjs/components/helpers/actions.js +59 -34
- package/cjs/components/helpers/dependencies.js +17 -8
- package/cjs/components/helpers/store.js +38 -39
- package/cjs/index.js +2 -1
- package/esm/DSQueryBuilder.js +60 -57
- package/esm/components/AndOrController/AndOrController.js +16 -19
- package/esm/components/ConditionController/ConditionController.js +20 -22
- package/esm/components/DisplayOutput/DisplayOutput.js +16 -14
- package/esm/components/DragContainerController/DragContainerController.js +10 -10
- package/esm/components/DragControllerRow/DragControllerRow.js +7 -2
- package/esm/components/FieldControllerRow/FieldControllerRow.js +22 -20
- package/esm/components/Nestable/Nestable.js +43 -29
- package/esm/components/Nestable/NestableItem.js +18 -10
- package/esm/components/Nestable/actions/events.js +5 -0
- package/esm/components/Nestable/actions/getPaths.js +9 -1
- package/esm/components/Nestable/actions/moveItem.js +12 -5
- package/esm/components/Nestable/actions/paths.js +13 -3
- package/esm/components/QueryBuilderImpl.js +34 -30
- package/esm/components/QueryBuilderItem/QueryBuilderItem.js +28 -20
- package/esm/components/QueryBuilderRow/QueryBuilderRow.js +42 -32
- package/esm/components/ToolBarAnimation/ToolBarAnimation.js +5 -0
- package/esm/components/format/format.js +8 -10
- package/esm/components/format/sqlFormat.js +9 -7
- package/esm/components/format/sqlSafeFormat.js +9 -7
- package/esm/components/format/xmlFormat.js +9 -7
- package/esm/components/helpers/actions.js +59 -34
- package/esm/components/helpers/dependencies.js +17 -8
- package/esm/components/helpers/store.js +38 -39
- package/esm/index.js +1 -1
- package/package.json +14 -7
- package/types/DSQueryBuilder.d.ts +170 -25
- package/types/components/AndOrController/AndOrController.d.ts +4 -4
- package/types/components/ConditionController/ConditionController.d.ts +2 -2
- package/types/components/DragContainerController/DragContainerController.d.ts +3 -3
- package/types/components/DragControllerRow/DragControllerRow.d.ts +2 -2
- package/types/propTypes.d.ts +133 -23
|
@@ -3,9 +3,16 @@
|
|
|
3
3
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
4
4
|
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
5
5
|
require('core-js/modules/web.dom-collections.iterator.js');
|
|
6
|
+
require('core-js/modules/esnext.async-iterator.map.js');
|
|
7
|
+
require('core-js/modules/esnext.iterator.map.js');
|
|
8
|
+
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
9
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
10
|
+
require('core-js/modules/esnext.iterator.filter.js');
|
|
11
|
+
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
12
|
+
require('core-js/modules/esnext.iterator.for-each.js');
|
|
6
13
|
var React = require('react');
|
|
7
|
-
var
|
|
8
|
-
var DSTooltip = require('@elliemae/ds-
|
|
14
|
+
var dsIcons = require('@elliemae/ds-icons');
|
|
15
|
+
var DSTooltip = require('@elliemae/ds-tooltip');
|
|
9
16
|
var dsClassnames = require('@elliemae/ds-classnames');
|
|
10
17
|
var dependencies = require('../helpers/dependencies.js');
|
|
11
18
|
var ConditionController = require('../ConditionController/ConditionController.js');
|
|
@@ -17,22 +24,22 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
17
24
|
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
18
25
|
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
19
26
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
20
|
-
var AlertsDetail__default = /*#__PURE__*/_interopDefaultLegacy(AlertsDetail);
|
|
21
27
|
|
|
22
28
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
23
29
|
|
|
24
30
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
25
31
|
|
|
26
|
-
const RenderField =
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
const RenderField = _ref => {
|
|
33
|
+
let {
|
|
34
|
+
target,
|
|
35
|
+
component,
|
|
36
|
+
valueProp,
|
|
37
|
+
additionalInfo,
|
|
38
|
+
handleMouseEnterInput,
|
|
39
|
+
handleMouseLeaveInput,
|
|
40
|
+
onChangeHandler,
|
|
41
|
+
hasError
|
|
42
|
+
} = _ref;
|
|
36
43
|
const ref = React__default["default"].useRef();
|
|
37
44
|
const id = React__default["default"].useMemo(() => "el_".concat(String.fromCharCode(65 + Math.floor(Math.random() * 26))), []);
|
|
38
45
|
return /*#__PURE__*/_jsx__default["default"]("div", {
|
|
@@ -60,20 +67,22 @@ const RenderField = ({
|
|
|
60
67
|
'aria-invalid': Boolean(hasError)
|
|
61
68
|
})
|
|
62
69
|
}), hasError && hasError.errorMessage ? /*#__PURE__*/_jsx__default["default"]("div", {
|
|
70
|
+
style: {
|
|
71
|
+
width: '40px'
|
|
72
|
+
}
|
|
73
|
+
}, void 0, /*#__PURE__*/_jsx__default["default"](DSTooltip.DSTooltipV3, {
|
|
74
|
+
text: hasError.errorMessage
|
|
75
|
+
}, void 0, /*#__PURE__*/_jsx__default["default"]("div", {
|
|
63
76
|
tabIndex: 0,
|
|
64
77
|
className: "row-icon-alert",
|
|
65
78
|
"data-testid": "qb-error-state-icon",
|
|
66
|
-
role: "alert"
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
color: ['danger', 900],
|
|
74
|
-
title: hasError.message
|
|
75
|
-
})
|
|
76
|
-
})) : null); // return React.useMemo(
|
|
79
|
+
role: "alert"
|
|
80
|
+
}, void 0, /*#__PURE__*/_jsx__default["default"](dsIcons.AlertsDetail, {
|
|
81
|
+
width: 20,
|
|
82
|
+
height: 20,
|
|
83
|
+
color: ['danger', 900],
|
|
84
|
+
title: hasError.errorMessage
|
|
85
|
+
})))) : null); // return React.useMemo(
|
|
77
86
|
// () => (
|
|
78
87
|
// <div
|
|
79
88
|
// className={`em-ds-query-builder-row-input child-type-${target}`}
|
|
@@ -105,31 +114,31 @@ class QueryBuilderRow extends React.Component {
|
|
|
105
114
|
constructor(props) {
|
|
106
115
|
super(props);
|
|
107
116
|
|
|
108
|
-
|
|
117
|
+
this.handleMouseEnterRow = () => {};
|
|
109
118
|
|
|
110
|
-
|
|
119
|
+
this.handleMouseLeaveRow = () => {
|
|
111
120
|
this.handleTooltipRow(false);
|
|
112
|
-
}
|
|
121
|
+
};
|
|
113
122
|
|
|
114
|
-
|
|
123
|
+
this.handleMouseEnterInput = () => {
|
|
115
124
|
const {
|
|
116
125
|
setDraggableItems
|
|
117
126
|
} = this.props;
|
|
118
127
|
setDraggableItems(false);
|
|
119
|
-
}
|
|
128
|
+
};
|
|
120
129
|
|
|
121
|
-
|
|
130
|
+
this.handleMouseLeaveInput = () => {
|
|
122
131
|
const {
|
|
123
132
|
setDraggableItems
|
|
124
133
|
} = this.props;
|
|
125
134
|
setDraggableItems(true);
|
|
126
|
-
}
|
|
135
|
+
};
|
|
127
136
|
|
|
128
|
-
|
|
137
|
+
this.handleTooltipRow = isOpen => {
|
|
129
138
|
this.setState({
|
|
130
139
|
isOpen
|
|
131
140
|
});
|
|
132
|
-
}
|
|
141
|
+
};
|
|
133
142
|
|
|
134
143
|
this.state = {
|
|
135
144
|
isOpen: false
|
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
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');
|
|
5
10
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
6
11
|
var React = require('react');
|
|
7
12
|
var GrowRight = require('@elliemae/ds-shared/Animations/GrowRight');
|
|
@@ -1,35 +1,29 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
4
3
|
var sqlFormat = require('./sqlFormat.js');
|
|
5
4
|
var xmlFormat = require('./xmlFormat.js');
|
|
6
5
|
var sqlSafeFormat = require('./sqlSafeFormat.js');
|
|
7
6
|
|
|
8
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
|
-
|
|
10
|
-
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
11
|
-
|
|
12
7
|
class QueryBuilderFormat {
|
|
13
8
|
constructor() {
|
|
14
|
-
|
|
9
|
+
this.format = {
|
|
15
10
|
defaultFormat: query => query,
|
|
16
11
|
sqlFormat: sqlFormat.sqlFormat,
|
|
17
12
|
xmlFormat: xmlFormat.xmlFormat,
|
|
18
13
|
sqlSafeFormat: sqlSafeFormat.sqlSafeFormat
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
_defineProperty__default["default"](this, "currentFormat", 'sqlFormat');
|
|
14
|
+
};
|
|
15
|
+
this.currentFormat = 'sqlFormat';
|
|
22
16
|
|
|
23
|
-
|
|
17
|
+
this.setDefaultFormat = formatName => {
|
|
24
18
|
if (this.format[formatName]) this.currentFormat = formatName;
|
|
25
|
-
}
|
|
19
|
+
};
|
|
26
20
|
|
|
27
|
-
|
|
21
|
+
this.addFormat = (formatName, format) => this.format[formatName] = format;
|
|
28
22
|
|
|
29
|
-
|
|
23
|
+
this.run = (query, formatName) => {
|
|
30
24
|
if (this.format[formatName]) return this.format[formatName](query);
|
|
31
25
|
return this.format[this.currentFormat](query);
|
|
32
|
-
}
|
|
26
|
+
};
|
|
33
27
|
}
|
|
34
28
|
|
|
35
29
|
}
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
require('core-js/modules/esnext.async-iterator.map.js');
|
|
6
|
+
require('core-js/modules/esnext.iterator.map.js');
|
|
5
7
|
var types = require('../helpers/types.js');
|
|
6
8
|
|
|
7
|
-
/* eslint-disable complexity */
|
|
8
|
-
|
|
9
9
|
const conditionSql = (condition, value) => {
|
|
10
10
|
const {
|
|
11
11
|
EQUAL,
|
|
@@ -41,11 +41,13 @@ const renderFilterSQl = filter => {
|
|
|
41
41
|
return "".concat(field, " ").concat(conditionSql(operator, value) || '');
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
-
const sqlFormat =
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
const sqlFormat = _ref => {
|
|
45
|
+
let {
|
|
46
|
+
main,
|
|
47
|
+
mapGroups,
|
|
48
|
+
items
|
|
49
|
+
} = _ref;
|
|
50
|
+
|
|
49
51
|
const groupSql = (item, idGroup) => {
|
|
50
52
|
if (idGroup === main) {
|
|
51
53
|
const groupCondition = mapGroups[idGroup].condition === true ? 'AND' : 'OR';
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
require('core-js/modules/esnext.async-iterator.map.js');
|
|
6
|
+
require('core-js/modules/esnext.iterator.map.js');
|
|
5
7
|
var types = require('../helpers/types.js');
|
|
6
8
|
|
|
7
|
-
/* eslint-disable complexity */
|
|
8
|
-
|
|
9
9
|
const specialChar = /[ !@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/;
|
|
10
10
|
|
|
11
11
|
const conditionSql = (condition, value) => {
|
|
@@ -48,11 +48,13 @@ const renderFilterSQl = filter => {
|
|
|
48
48
|
return "".concat(fieldDisplay, " ").concat(conditionSql(operator, value) || '');
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
-
const sqlSafeFormat =
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
const sqlSafeFormat = _ref => {
|
|
52
|
+
let {
|
|
53
|
+
main,
|
|
54
|
+
mapGroups,
|
|
55
|
+
items
|
|
56
|
+
} = _ref;
|
|
57
|
+
|
|
56
58
|
const groupSql = (item, idGroup) => {
|
|
57
59
|
if (idGroup === main) {
|
|
58
60
|
const groupCondition = mapGroups[idGroup].condition === true ? 'AND' : 'OR';
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
require('core-js/modules/esnext.async-iterator.map.js');
|
|
6
|
+
require('core-js/modules/esnext.iterator.map.js');
|
|
5
7
|
var types = require('../helpers/types.js');
|
|
6
8
|
|
|
7
|
-
/* eslint-disable complexity */
|
|
8
|
-
|
|
9
9
|
const conditionSql = (condition, value) => {
|
|
10
10
|
const {
|
|
11
11
|
EQUAL,
|
|
@@ -41,11 +41,13 @@ const renderFilterSQl = filter => {
|
|
|
41
41
|
return "<filter><field>".concat(field, "</field>").concat(conditionSql(operator, value) || '', "</filter>");
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
-
const xmlFormat =
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
const xmlFormat = _ref => {
|
|
45
|
+
let {
|
|
46
|
+
main,
|
|
47
|
+
mapGroups,
|
|
48
|
+
items
|
|
49
|
+
} = _ref;
|
|
50
|
+
|
|
49
51
|
const groupXML = (item, idGroup) => {
|
|
50
52
|
if (idGroup === main) {
|
|
51
53
|
const groupCondition = mapGroups[idGroup].condition === true ? 'AND' : 'OR';
|
|
@@ -3,6 +3,15 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
6
|
+
require('core-js/modules/esnext.async-iterator.find.js');
|
|
7
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
8
|
+
require('core-js/modules/esnext.iterator.find.js');
|
|
9
|
+
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
10
|
+
require('core-js/modules/esnext.iterator.for-each.js');
|
|
11
|
+
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
12
|
+
require('core-js/modules/esnext.iterator.filter.js');
|
|
13
|
+
require('core-js/modules/esnext.async-iterator.map.js');
|
|
14
|
+
require('core-js/modules/esnext.iterator.map.js');
|
|
6
15
|
var types = require('./types.js');
|
|
7
16
|
|
|
8
17
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -84,9 +93,12 @@ const addFilterToMainItem = function (items, newFilter) {
|
|
|
84
93
|
});
|
|
85
94
|
};
|
|
86
95
|
const findInChilds = function (childs, filterId) {
|
|
87
|
-
const found = childs.find(
|
|
88
|
-
|
|
89
|
-
|
|
96
|
+
const found = childs.find(_ref => {
|
|
97
|
+
let {
|
|
98
|
+
id
|
|
99
|
+
} = _ref;
|
|
100
|
+
return id === filterId;
|
|
101
|
+
});
|
|
90
102
|
|
|
91
103
|
if (!found) {
|
|
92
104
|
let findInChild;
|
|
@@ -102,9 +114,12 @@ const findItemFilterById = function (filterId) {
|
|
|
102
114
|
return findInChilds(this.items, filterId);
|
|
103
115
|
};
|
|
104
116
|
const findParentWithFilterId = function (childs, filterId) {
|
|
105
|
-
const found = childs.find(
|
|
106
|
-
|
|
107
|
-
|
|
117
|
+
const found = childs.find(_ref2 => {
|
|
118
|
+
let {
|
|
119
|
+
id
|
|
120
|
+
} = _ref2;
|
|
121
|
+
return id === filterId;
|
|
122
|
+
});
|
|
108
123
|
|
|
109
124
|
if (!found) {
|
|
110
125
|
let findInChild;
|
|
@@ -121,17 +136,23 @@ const findParentFilterById = function (filterId) {
|
|
|
121
136
|
};
|
|
122
137
|
const filterInChildren = function (childs, filterId, mainId) {
|
|
123
138
|
if (childs.children) {
|
|
124
|
-
childs.children = childs.children.filter(
|
|
125
|
-
|
|
126
|
-
|
|
139
|
+
childs.children = childs.children.filter(_ref3 => {
|
|
140
|
+
let {
|
|
141
|
+
id
|
|
142
|
+
} = _ref3;
|
|
143
|
+
return id !== filterId;
|
|
144
|
+
});
|
|
127
145
|
childs.children = childs.children.forEach(item => filterInChildren(item.children, filterId));
|
|
128
146
|
return childs;
|
|
129
147
|
} // main
|
|
130
148
|
|
|
131
149
|
|
|
132
|
-
if (childs.length > 1) childs = childs.filter(
|
|
133
|
-
|
|
134
|
-
|
|
150
|
+
if (childs.length > 1) childs = childs.filter(_ref4 => {
|
|
151
|
+
let {
|
|
152
|
+
id
|
|
153
|
+
} = _ref4;
|
|
154
|
+
return id !== filterId;
|
|
155
|
+
}); // https://jira.elliemae.io/browse/PUI-1252
|
|
135
156
|
|
|
136
157
|
if (childs.length === 0 && mainId) {
|
|
137
158
|
const emptyFilter = createNewFilter.call(this, mainId);
|
|
@@ -194,19 +215,20 @@ const changeGroupOperator = function (idGroup, value) {
|
|
|
194
215
|
group.element.condition = value;
|
|
195
216
|
}
|
|
196
217
|
};
|
|
197
|
-
const changeFilterItem = function ({
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
}
|
|
218
|
+
const changeFilterItem = function (_ref5) {
|
|
219
|
+
let {
|
|
220
|
+
idFilter,
|
|
221
|
+
field,
|
|
222
|
+
value,
|
|
223
|
+
operator,
|
|
224
|
+
additionalInfo,
|
|
225
|
+
target,
|
|
226
|
+
fieldsSharedActions: {
|
|
227
|
+
onFieldChange,
|
|
228
|
+
onOperatorChange,
|
|
229
|
+
onValueChange
|
|
230
|
+
}
|
|
231
|
+
} = _ref5;
|
|
210
232
|
const child = findItemFilterById.call(this, idFilter);
|
|
211
233
|
if (field || field === '' || typeof field === 'boolean') child.element.field = field;
|
|
212
234
|
if (operator) child.element.operator = operator;
|
|
@@ -214,21 +236,24 @@ const changeFilterItem = function ({
|
|
|
214
236
|
if (additionalInfo) child.element.additionalInfo = additionalInfo; // shared fields actions
|
|
215
237
|
|
|
216
238
|
if (target === 'field') {
|
|
217
|
-
onFieldChange.forEach(
|
|
218
|
-
|
|
219
|
-
|
|
239
|
+
onFieldChange.forEach(_ref6 => {
|
|
240
|
+
let {
|
|
241
|
+
action
|
|
242
|
+
} = _ref6;
|
|
220
243
|
if (action === types.QB_FIELD_SHARED_ACTIONS.RESET_FIELD) child.element.field = null;else if (action === types.QB_FIELD_SHARED_ACTIONS.RESET_OPERATOR) child.element.operator = null;else if (action === types.QB_FIELD_SHARED_ACTIONS.RESET_VALUE) child.element.value = null;
|
|
221
244
|
});
|
|
222
245
|
} else if (target === 'operator') {
|
|
223
|
-
onOperatorChange.forEach(
|
|
224
|
-
|
|
225
|
-
|
|
246
|
+
onOperatorChange.forEach(_ref7 => {
|
|
247
|
+
let {
|
|
248
|
+
action
|
|
249
|
+
} = _ref7;
|
|
226
250
|
if (action === types.QB_FIELD_SHARED_ACTIONS.RESET_FIELD) child.element.field = null;else if (action === types.QB_FIELD_SHARED_ACTIONS.RESET_OPERATOR) child.element.operator = null;else if (action === types.QB_FIELD_SHARED_ACTIONS.RESET_VALUE) child.element.value = null;
|
|
227
251
|
});
|
|
228
252
|
} else if (target === 'value') {
|
|
229
|
-
onValueChange.forEach(
|
|
230
|
-
|
|
231
|
-
|
|
253
|
+
onValueChange.forEach(_ref8 => {
|
|
254
|
+
let {
|
|
255
|
+
action
|
|
256
|
+
} = _ref8;
|
|
232
257
|
if (action === types.QB_FIELD_SHARED_ACTIONS.RESET_FIELD) child.element.field = null;else if (action === types.QB_FIELD_SHARED_ACTIONS.RESET_OPERATOR) child.element.operator = null;else if (action === types.QB_FIELD_SHARED_ACTIONS.RESET_VALUE) child.element.value = null;
|
|
233
258
|
});
|
|
234
259
|
}
|
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
require('core-js/modules/esnext.async-iterator.every.js');
|
|
6
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
7
|
+
require('core-js/modules/esnext.iterator.every.js');
|
|
8
|
+
require('core-js/modules/esnext.async-iterator.some.js');
|
|
9
|
+
require('core-js/modules/esnext.iterator.some.js');
|
|
10
|
+
require('core-js/modules/esnext.async-iterator.reduce.js');
|
|
11
|
+
require('core-js/modules/esnext.iterator.reduce.js');
|
|
5
12
|
var lodash = require('lodash');
|
|
6
13
|
var operators = require('@elliemae/ds-utilities/operators');
|
|
7
14
|
var types = require('./types.js');
|
|
@@ -26,7 +33,8 @@ function _interopNamespace(e) {
|
|
|
26
33
|
|
|
27
34
|
var operators__namespace = /*#__PURE__*/_interopNamespace(operators);
|
|
28
35
|
|
|
29
|
-
const resolveCondition = (condition, state
|
|
36
|
+
const resolveCondition = function (condition, state) {
|
|
37
|
+
let resolveBy = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : types.QB_GROUP_CONDITION_TYPES.AND;
|
|
30
38
|
if (condition.length === 0 || !condition) return true; // resolve by AND: all the conditions must be true
|
|
31
39
|
|
|
32
40
|
if (resolveBy) {
|
|
@@ -53,13 +61,14 @@ const resolveCondition = (condition, state, resolveBy = types.QB_GROUP_CONDITION
|
|
|
53
61
|
};
|
|
54
62
|
|
|
55
63
|
const resolveDependencies = (state, fields) => {
|
|
56
|
-
const fieldsToRender = fields.reduce((result, {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
64
|
+
const fieldsToRender = fields.reduce((result, _ref) => {
|
|
65
|
+
let {
|
|
66
|
+
target,
|
|
67
|
+
component,
|
|
68
|
+
condition,
|
|
69
|
+
resolveBy,
|
|
70
|
+
validation
|
|
71
|
+
} = _ref;
|
|
63
72
|
if (resolveCondition(condition, state, resolveBy)) result.push({
|
|
64
73
|
target,
|
|
65
74
|
component,
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
4
|
+
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
5
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
6
|
+
require('core-js/modules/esnext.iterator.for-each.js');
|
|
7
|
+
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
8
|
+
require('core-js/modules/esnext.iterator.filter.js');
|
|
4
9
|
var actions = require('./actions.js');
|
|
5
10
|
var format = require('../format/format.js');
|
|
6
11
|
|
|
@@ -25,36 +30,30 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
25
30
|
|
|
26
31
|
class QueryBuilderStore {
|
|
27
32
|
constructor(init, _format) {
|
|
28
|
-
|
|
33
|
+
this.items = [];
|
|
34
|
+
this.step = 0;
|
|
35
|
+
this.steps = {};
|
|
36
|
+
this.mapFilters = {};
|
|
37
|
+
this.mapGroups = {};
|
|
38
|
+
this.main = null;
|
|
39
|
+
this.format = null;
|
|
29
40
|
|
|
30
|
-
|
|
41
|
+
this.createNewFilter = idGroup => actions.createNewFilter.call(this, idGroup);
|
|
31
42
|
|
|
32
|
-
|
|
43
|
+
this.createNewGroup = parentIdGroup => actions.createNewGroup.call(this, parentIdGroup);
|
|
33
44
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
_defineProperty__default["default"](this, "mapGroups", {});
|
|
37
|
-
|
|
38
|
-
_defineProperty__default["default"](this, "main", null);
|
|
39
|
-
|
|
40
|
-
_defineProperty__default["default"](this, "format", null);
|
|
41
|
-
|
|
42
|
-
_defineProperty__default["default"](this, "createNewFilter", idGroup => actions.createNewFilter.call(this, idGroup));
|
|
43
|
-
|
|
44
|
-
_defineProperty__default["default"](this, "createNewGroup", parentIdGroup => actions.createNewGroup.call(this, parentIdGroup));
|
|
45
|
-
|
|
46
|
-
_defineProperty__default["default"](this, "onOrderDragAndDrop", items => {
|
|
45
|
+
this.onOrderDragAndDrop = items => {
|
|
47
46
|
this.items = items;
|
|
48
47
|
return this.getState();
|
|
49
|
-
}
|
|
48
|
+
};
|
|
50
49
|
|
|
51
|
-
|
|
50
|
+
this.addFilterNextToFilterId = (idGroup, idFilter) => {
|
|
52
51
|
// eslint-disable-line
|
|
53
52
|
this.addFilter(idGroup);
|
|
54
53
|
return this.getState();
|
|
55
|
-
}
|
|
54
|
+
};
|
|
56
55
|
|
|
57
|
-
|
|
56
|
+
this.addFilter = idGroup => {
|
|
58
57
|
const newFilter = this.createNewFilter(idGroup);
|
|
59
58
|
actions.addFilterToMap.call(this, newFilter); // new API
|
|
60
59
|
|
|
@@ -69,22 +68,22 @@ class QueryBuilderStore {
|
|
|
69
68
|
}
|
|
70
69
|
|
|
71
70
|
return this.getState();
|
|
72
|
-
}
|
|
71
|
+
};
|
|
73
72
|
|
|
74
|
-
|
|
73
|
+
this.onRemoveFilter = idFilter => {
|
|
75
74
|
// new API
|
|
76
75
|
actions.removeFilterItem.call(this, idFilter);
|
|
77
76
|
return this.getState();
|
|
78
|
-
}
|
|
77
|
+
};
|
|
79
78
|
|
|
80
|
-
|
|
79
|
+
this.addRuleContainerInPlace = (idGroup, idFilter) => {
|
|
81
80
|
// Create a new group
|
|
82
81
|
const newGroup = this.createNewGroup(idGroup);
|
|
83
82
|
actions.addGroupFilterToItem.call(this, idGroup, idFilter, newGroup);
|
|
84
83
|
return this.getState();
|
|
85
|
-
}
|
|
84
|
+
};
|
|
86
85
|
|
|
87
|
-
|
|
86
|
+
this.addRuleContainer = (idGroup, idFilter) => {
|
|
88
87
|
// eslint-disable-line
|
|
89
88
|
const newGroup = this.createNewGroup(idGroup);
|
|
90
89
|
actions.addGroupToMap.call(this, newGroup);
|
|
@@ -100,33 +99,33 @@ class QueryBuilderStore {
|
|
|
100
99
|
}
|
|
101
100
|
|
|
102
101
|
return this.getState();
|
|
103
|
-
}
|
|
102
|
+
};
|
|
104
103
|
|
|
105
|
-
|
|
104
|
+
this.unGroup = idGroup => {
|
|
106
105
|
actions.unGroupFilterToItem.call(this, idGroup);
|
|
107
106
|
return this.getState();
|
|
108
|
-
}
|
|
107
|
+
};
|
|
109
108
|
|
|
110
|
-
|
|
109
|
+
this.changeGroupOperator = (idGroup, value) => {
|
|
111
110
|
this.getGroupById(idGroup).condition = value;
|
|
112
111
|
actions.changeGroupOperator.call(this, idGroup, value);
|
|
113
112
|
return this.getState();
|
|
114
|
-
}
|
|
113
|
+
};
|
|
115
114
|
|
|
116
|
-
|
|
115
|
+
this.changeFilter = data => {
|
|
117
116
|
const {
|
|
118
117
|
idFilter
|
|
119
118
|
} = data;
|
|
120
119
|
this.mapFilters[idFilter] = _objectSpread(_objectSpread({}, this.mapFilters[idFilter]), data);
|
|
121
120
|
actions.changeFilterItem.call(this, data);
|
|
122
121
|
return this.getState();
|
|
123
|
-
}
|
|
122
|
+
};
|
|
124
123
|
|
|
125
|
-
|
|
124
|
+
this.getGroupById = idGroup => this.mapGroups[idGroup] || {};
|
|
126
125
|
|
|
127
|
-
|
|
126
|
+
this.getFilterById = idFilter => this.mapFilters[idFilter];
|
|
128
127
|
|
|
129
|
-
|
|
128
|
+
this.getInitialState = () => {
|
|
130
129
|
const newFilters = {
|
|
131
130
|
step: this.step,
|
|
132
131
|
mapFilters: _objectSpread({}, this.mapFilters),
|
|
@@ -138,9 +137,9 @@ class QueryBuilderStore {
|
|
|
138
137
|
return _objectSpread(_objectSpread({}, newFilters), {}, {
|
|
139
138
|
format: format$1
|
|
140
139
|
});
|
|
141
|
-
}
|
|
140
|
+
};
|
|
142
141
|
|
|
143
|
-
|
|
142
|
+
this.getState = () => {
|
|
144
143
|
this.step += 1;
|
|
145
144
|
const newFilters = {
|
|
146
145
|
step: this.step,
|
|
@@ -153,7 +152,7 @@ class QueryBuilderStore {
|
|
|
153
152
|
return _objectSpread(_objectSpread({}, newFilters), {}, {
|
|
154
153
|
format: format$1
|
|
155
154
|
});
|
|
156
|
-
}
|
|
155
|
+
};
|
|
157
156
|
|
|
158
157
|
this.firstLoad = true;
|
|
159
158
|
this.format = _format;
|
package/cjs/index.js
CHANGED
|
@@ -9,8 +9,9 @@ var format = require('./components/format/format.js');
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
|
+
exports.DSQueryBuilder = DSQueryBuilder.DSQueryBuilder;
|
|
12
13
|
exports.DSQueryBuilderWithSchema = DSQueryBuilder.DSQueryBuilderWithSchema;
|
|
13
|
-
exports["default"] = DSQueryBuilder
|
|
14
|
+
exports["default"] = DSQueryBuilder.DSQueryBuilder;
|
|
14
15
|
exports.QB_ADD_FILTER_METHOD_TYPES = types.QB_ADD_FILTER_METHOD_TYPES;
|
|
15
16
|
exports.QB_DRAG_LOCATIONS = types.QB_DRAG_LOCATIONS;
|
|
16
17
|
exports.QB_DRAG_TYPES = types.QB_DRAG_TYPES;
|