@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.
Files changed (141) hide show
  1. package/cjs/DSQueryBuilder.js +97 -117
  2. package/cjs/components/AndOrController/AndOrController.js +162 -148
  3. package/cjs/components/ConditionController/ConditionController.js +72 -88
  4. package/cjs/components/DisplayOutput/DisplayOutput.js +68 -63
  5. package/cjs/components/DragContainerController/DragContainerController.js +41 -61
  6. package/cjs/components/DragControllerRow/DragControllerRow.js +46 -50
  7. package/cjs/components/FieldControllerRow/FieldControllerRow.js +32 -54
  8. package/cjs/components/Nestable/Nestable.js +209 -143
  9. package/cjs/components/Nestable/NestableItem.js +90 -98
  10. package/cjs/components/Nestable/actions/events.js +95 -72
  11. package/cjs/components/Nestable/actions/getItemOptions.js +15 -36
  12. package/cjs/components/Nestable/actions/getPaths.js +51 -46
  13. package/cjs/components/Nestable/actions/index.js +28 -42
  14. package/cjs/components/Nestable/actions/moveItem.js +42 -44
  15. package/cjs/components/Nestable/actions/paths.js +55 -48
  16. package/cjs/components/Nestable/actions/tryDecreaseDepth.js +23 -39
  17. package/cjs/components/Nestable/actions/tryIncreaseDepth.js +26 -39
  18. package/cjs/components/Nestable/index.js +7 -36
  19. package/cjs/components/QueryBuilderContext/QueryBuilderContext.js +13 -36
  20. package/cjs/components/QueryBuilderImpl.js +202 -118
  21. package/cjs/components/QueryBuilderItem/QueryBuilderItem.js +78 -80
  22. package/cjs/components/QueryBuilderRow/QueryBuilderRow.js +211 -154
  23. package/cjs/components/ToolBarAnimation/ToolBarAnimation.js +26 -39
  24. package/cjs/components/format/format.js +22 -48
  25. package/cjs/components/format/sqlFormat.js +48 -69
  26. package/cjs/components/format/sqlSafeFormat.js +55 -72
  27. package/cjs/components/format/xmlFormat.js +50 -71
  28. package/cjs/components/helpers/actions.js +186 -151
  29. package/cjs/components/helpers/constants.js +8 -36
  30. package/cjs/components/helpers/dependencies.js +64 -49
  31. package/cjs/components/helpers/selectors.js +101 -161
  32. package/cjs/components/helpers/store.js +104 -86
  33. package/cjs/components/helpers/types.js +44 -72
  34. package/cjs/index.js +29 -36
  35. package/cjs/propTypes.js +94 -102
  36. package/esm/DSQueryBuilder.js +72 -103
  37. package/esm/components/AndOrController/AndOrController.js +147 -113
  38. package/esm/components/ConditionController/ConditionController.js +62 -57
  39. package/esm/components/DisplayOutput/DisplayOutput.js +59 -31
  40. package/esm/components/DragContainerController/DragContainerController.js +35 -32
  41. package/esm/components/DragControllerRow/DragControllerRow.js +38 -21
  42. package/esm/components/FieldControllerRow/FieldControllerRow.js +26 -25
  43. package/esm/components/Nestable/Nestable.js +186 -115
  44. package/esm/components/Nestable/NestableItem.js +82 -69
  45. package/esm/components/Nestable/actions/events.js +79 -45
  46. package/esm/components/Nestable/actions/getItemOptions.js +11 -7
  47. package/esm/components/Nestable/actions/getPaths.js +43 -17
  48. package/esm/components/Nestable/actions/index.js +6 -13
  49. package/esm/components/Nestable/actions/moveItem.js +31 -13
  50. package/esm/components/Nestable/actions/paths.js +47 -19
  51. package/esm/components/Nestable/actions/tryDecreaseDepth.js +19 -10
  52. package/esm/components/Nestable/actions/tryIncreaseDepth.js +22 -10
  53. package/esm/components/Nestable/index.js +2 -7
  54. package/esm/components/QueryBuilderContext/QueryBuilderContext.js +5 -7
  55. package/esm/components/QueryBuilderImpl.js +187 -82
  56. package/esm/components/QueryBuilderItem/QueryBuilderItem.js +70 -50
  57. package/esm/components/QueryBuilderRow/QueryBuilderRow.js +201 -123
  58. package/esm/components/ToolBarAnimation/ToolBarAnimation.js +17 -10
  59. package/esm/components/format/format.js +17 -16
  60. package/esm/components/format/sqlFormat.js +43 -39
  61. package/esm/components/format/sqlSafeFormat.js +50 -43
  62. package/esm/components/format/xmlFormat.js +45 -41
  63. package/esm/components/helpers/actions.js +160 -123
  64. package/esm/components/helpers/constants.js +2 -7
  65. package/esm/components/helpers/dependencies.js +39 -19
  66. package/esm/components/helpers/selectors.js +93 -132
  67. package/esm/components/helpers/store.js +82 -54
  68. package/esm/components/helpers/types.js +33 -44
  69. package/esm/index.js +4 -7
  70. package/esm/propTypes.js +72 -55
  71. package/package.json +12 -12
  72. package/cjs/DSQueryBuilder.js.map +0 -7
  73. package/cjs/components/AndOrController/AndOrController.js.map +0 -7
  74. package/cjs/components/ConditionController/ConditionController.js.map +0 -7
  75. package/cjs/components/DisplayOutput/DisplayOutput.js.map +0 -7
  76. package/cjs/components/DragContainerController/DragContainerController.js.map +0 -7
  77. package/cjs/components/DragControllerRow/DragControllerRow.js.map +0 -7
  78. package/cjs/components/FieldControllerRow/FieldControllerRow.js.map +0 -7
  79. package/cjs/components/Nestable/Nestable.js.map +0 -7
  80. package/cjs/components/Nestable/NestableItem.js.map +0 -7
  81. package/cjs/components/Nestable/actions/events.js.map +0 -7
  82. package/cjs/components/Nestable/actions/getItemOptions.js.map +0 -7
  83. package/cjs/components/Nestable/actions/getPaths.js.map +0 -7
  84. package/cjs/components/Nestable/actions/index.js.map +0 -7
  85. package/cjs/components/Nestable/actions/moveItem.js.map +0 -7
  86. package/cjs/components/Nestable/actions/paths.js.map +0 -7
  87. package/cjs/components/Nestable/actions/tryDecreaseDepth.js.map +0 -7
  88. package/cjs/components/Nestable/actions/tryIncreaseDepth.js.map +0 -7
  89. package/cjs/components/Nestable/index.js.map +0 -7
  90. package/cjs/components/QueryBuilderContext/QueryBuilderContext.js.map +0 -7
  91. package/cjs/components/QueryBuilderImpl.js.map +0 -7
  92. package/cjs/components/QueryBuilderItem/QueryBuilderItem.js.map +0 -7
  93. package/cjs/components/QueryBuilderRow/QueryBuilderRow.js.map +0 -7
  94. package/cjs/components/ToolBarAnimation/ToolBarAnimation.js.map +0 -7
  95. package/cjs/components/format/format.js.map +0 -7
  96. package/cjs/components/format/sqlFormat.js.map +0 -7
  97. package/cjs/components/format/sqlSafeFormat.js.map +0 -7
  98. package/cjs/components/format/xmlFormat.js.map +0 -7
  99. package/cjs/components/helpers/actions.js.map +0 -7
  100. package/cjs/components/helpers/constants.js.map +0 -7
  101. package/cjs/components/helpers/dependencies.js.map +0 -7
  102. package/cjs/components/helpers/selectors.js.map +0 -7
  103. package/cjs/components/helpers/store.js.map +0 -7
  104. package/cjs/components/helpers/types.js.map +0 -7
  105. package/cjs/index.js.map +0 -7
  106. package/cjs/propTypes.js.map +0 -7
  107. package/esm/DSQueryBuilder.js.map +0 -7
  108. package/esm/components/AndOrController/AndOrController.js.map +0 -7
  109. package/esm/components/ConditionController/ConditionController.js.map +0 -7
  110. package/esm/components/DisplayOutput/DisplayOutput.js.map +0 -7
  111. package/esm/components/DragContainerController/DragContainerController.js.map +0 -7
  112. package/esm/components/DragControllerRow/DragControllerRow.js.map +0 -7
  113. package/esm/components/FieldControllerRow/FieldControllerRow.js.map +0 -7
  114. package/esm/components/Nestable/Nestable.js.map +0 -7
  115. package/esm/components/Nestable/NestableItem.js.map +0 -7
  116. package/esm/components/Nestable/actions/events.js.map +0 -7
  117. package/esm/components/Nestable/actions/getItemOptions.js.map +0 -7
  118. package/esm/components/Nestable/actions/getPaths.js.map +0 -7
  119. package/esm/components/Nestable/actions/index.js.map +0 -7
  120. package/esm/components/Nestable/actions/moveItem.js.map +0 -7
  121. package/esm/components/Nestable/actions/paths.js.map +0 -7
  122. package/esm/components/Nestable/actions/tryDecreaseDepth.js.map +0 -7
  123. package/esm/components/Nestable/actions/tryIncreaseDepth.js.map +0 -7
  124. package/esm/components/Nestable/index.js.map +0 -7
  125. package/esm/components/QueryBuilderContext/QueryBuilderContext.js.map +0 -7
  126. package/esm/components/QueryBuilderImpl.js.map +0 -7
  127. package/esm/components/QueryBuilderItem/QueryBuilderItem.js.map +0 -7
  128. package/esm/components/QueryBuilderRow/QueryBuilderRow.js.map +0 -7
  129. package/esm/components/ToolBarAnimation/ToolBarAnimation.js.map +0 -7
  130. package/esm/components/format/format.js.map +0 -7
  131. package/esm/components/format/sqlFormat.js.map +0 -7
  132. package/esm/components/format/sqlSafeFormat.js.map +0 -7
  133. package/esm/components/format/xmlFormat.js.map +0 -7
  134. package/esm/components/helpers/actions.js.map +0 -7
  135. package/esm/components/helpers/constants.js.map +0 -7
  136. package/esm/components/helpers/dependencies.js.map +0 -7
  137. package/esm/components/helpers/selectors.js.map +0 -7
  138. package/esm/components/helpers/store.js.map +0 -7
  139. package/esm/components/helpers/types.js.map +0 -7
  140. package/esm/index.js.map +0 -7
  141. package/esm/propTypes.js.map +0 -7
@@ -1,69 +1,101 @@
1
- import * as React from "react";
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 { childrenProp } = this.props;
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
- if (typeof prevPath[i] !== "number") {
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, items = this.getDefaultItems()) {
33
- const { childrenProp } = this.props;
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, items = this.getDefaultItems()) {
49
- const { childrenProp } = this.props;
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((index) => {
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 { childrenProp } = this.props;
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, options = {}) {
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] = { [options.childrenProp]: nextPath };
109
+ currentPath[index] = {
110
+ [options.childrenProp]: nextPath
111
+ };
78
112
  currentPath = nextPath;
79
113
  }
80
114
  });
81
115
  return splicePath;
82
116
  }
83
- export {
84
- getItemByPath,
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 { childrenProp, collapsed } = this.props;
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
- this.moveItem({ dragItem, pathFrom, pathTo }, collapseProps);
21
+
22
+ this.moveItem({
23
+ dragItem,
24
+ pathFrom,
25
+ pathTo
26
+ }, collapseProps);
16
27
  }
17
28
  }
18
29
  }
19
- export {
20
- tryDecreaseDepth
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 { maxDepth, childrenProp, collapsed } = this.props;
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
- this.moveItem({ dragItem, pathFrom, pathTo }, collapseProps);
24
+
25
+ this.moveItem({
26
+ dragItem,
27
+ pathFrom,
28
+ pathTo
29
+ }, collapseProps);
16
30
  }
17
31
  }
18
32
  }
19
- export {
20
- tryIncreaseDepth
21
- };
22
- //# sourceMappingURL=tryIncreaseDepth.js.map
33
+
34
+ export { tryIncreaseDepth };
@@ -1,7 +1,2 @@
1
- import * as React from "react";
2
- import Nestable from "./Nestable";
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 * as React from "react";
2
- import React2 from "react";
3
- const QueryBuilderContext = React2.createContext({});
4
- export {
5
- QueryBuilderContext
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 * as React from "react";
2
- import React2, { Component } from "react";
3
- import Nestable from "./Nestable";
4
- import { QueryBuilderContext } from "./QueryBuilderContext/QueryBuilderContext";
5
- import { QB_DRAG_TYPES, QB_ADD_FILTER_METHOD_TYPES, QB_GROUP_FILTER_METHOD_TYPES } from "./helpers/types";
6
- import QueryBuilderStore from "./helpers/store";
7
- import AndOrController from "./AndOrController/AndOrController";
8
- import QueryBuilderItem from "./QueryBuilderItem/QueryBuilderItem";
9
- import DisplayOutput from "./DisplayOutput/DisplayOutput";
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("reOrderOnDragAndDrop", { items });
32
+ this.sendCall('reOrderOnDragAndDrop', {
33
+ items
34
+ });
17
35
  this.sendChange(newFilters);
18
36
  };
19
- this.onAddFilterToGroup = (idGroup) => {
37
+
38
+ this.onAddFilterToGroup = idGroup => {
20
39
  const newFilters = this.store.addFilter(idGroup);
21
- this.sendCall("onAddFilterToGroup", { idGroup });
40
+ this.sendCall('onAddFilterToGroup', {
41
+ idGroup
42
+ });
22
43
  this.sendChange(newFilters);
23
44
  };
45
+
24
46
  this.onAddFilter = (idGroup, idFilter) => {
25
- const { addFilterMethod } = this.props;
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("onAddFilter", { idGroup, idFilter });
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 { groupFilterMethod } = this.props;
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("onAddRuleContainer", { idGroup, idFilter });
63
+ this.sendCall('onAddRuleContainer', {
64
+ idGroup,
65
+ idFilter
66
+ });
34
67
  this.sendChange(newFilters);
35
68
  };
36
- this.onRemoveFilter = (idFilter) => {
69
+
70
+ this.onRemoveFilter = idFilter => {
37
71
  const newFilters = this.store.onRemoveFilter(idFilter);
38
- this.sendCall("onRemoveFilter", { idFilter });
72
+ this.sendCall('onRemoveFilter', {
73
+ idFilter
74
+ });
39
75
  this.sendChange(newFilters);
40
76
  };
41
- this.handleFieldChange = (data) => {
42
- const { fieldsSharedActions } = this.props;
43
- const newFilters = this.store.changeFilter({
44
- ...data,
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("handleRuleContainerOperator", { idGroup, value });
93
+ this.sendCall('handleRuleContainerOperator', {
94
+ idGroup,
95
+ value
96
+ });
53
97
  this.sendChange(newFilters);
54
98
  };
55
- this.handleRuleContainerUnGroup = (idGroup) => {
99
+
100
+ this.handleRuleContainerUnGroup = idGroup => {
56
101
  const newFilters = this.store.unGroup(idGroup);
57
- this.sendCall("handleRuleContainerUnGroup", { idGroup });
102
+ this.sendCall('handleRuleContainerUnGroup', {
103
+ idGroup
104
+ });
58
105
  this.sendChange(newFilters);
59
106
  };
107
+
60
108
  this.handleDropFilter = (filter, dragTo) => {
61
- const { position: oldPosition, idGroup, idFilter } = filter;
62
- const { position: newPosition, targetIdGroup } = dragTo;
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("handleDropFilter", { filter, dragTo });
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 { position: oldPosition, idFilter, idGroup } = group;
69
- const { position: newPosition, targetIdGroup } = dragTo;
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("handleDropGroup", { group, dragTo });
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 { type } = dragElement;
76
- if (type === QB_DRAG_TYPES.FILTER)
77
- return this.handleDropFilter(dragElement, dragTo);
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
- this.sendChange = ({ format, ...newFilters }) => {
81
- this.setState({ format, ...newFilters });
82
- const { onChange } = this.props;
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 { [action]: callback } = this.props;
87
- if (callback)
88
- callback(data);
168
+ const {
169
+ [action]: callback
170
+ } = this.props;
171
+ if (callback) callback(data);
89
172
  };
90
- this.setDraggableItems = (drag) => {
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("MSIE ");
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 { isDraggableItem } = this.state;
182
+ const {
183
+ isDraggableItem
184
+ } = this.state;
185
+
97
186
  if (drag !== isDraggableItem) {
98
- this.setState({ isDraggableItem: drag });
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 !== void 0 && Number.isInteger(props.init.step) && props.init.step !== state.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 { mapGroups, main, mapFilters, step, items, format } = this.state;
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
- const { condition } = mapGroups[main];
136
- return /* @__PURE__ */ React2.createElement(QueryBuilderContext.Provider, {
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
- }, /* @__PURE__ */ React2.createElement("div", {
160
- ...containerProps,
161
- className: `nested-main-group ${condition !== true ? "is-or-group" : "is-and-groupL"} ${singleRow ? "query-main-single-row" : "query-main-multiple-row"}`
162
- }, /* @__PURE__ */ React2.createElement(Nestable, {
163
- isAndItem: condition === true,
164
- isDraggableItem: this.isDraggableItem,
165
- isOrItem: condition !== true,
166
- items,
167
- onChange: this.onOrderDragAndDrop,
168
- renderItem: QueryBuilderItem,
169
- setDraggableItems: this.setDraggableItems,
170
- step,
171
- singleRow
172
- }), !singleRow && /* @__PURE__ */ React2.createElement("div", {
173
- className: "rule-container-options"
174
- }, /* @__PURE__ */ React2.createElement(AndOrController, {
175
- allowUnGroup: false,
176
- condition,
177
- handleRuleContainerOperator: (value) => this.handleRuleContainerOperator(main, value),
178
- handleRuleContainerUnGroup: () => this.handleRuleContainerUnGroup(main),
179
- isMain: true,
180
- onAddFilter: () => this.onAddFilterToGroup(main),
181
- showDragController: false,
182
- step,
183
- toolTipZIndex
184
- }))), (displayOutput || displayFixedOutput) && /* @__PURE__ */ React2.createElement(DisplayOutput, {
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
- var QueryBuilderImpl_default = QueryBuilderImpl;
193
- export {
194
- QueryBuilderImpl_default as default
195
- };
196
- //# sourceMappingURL=QueryBuilderImpl.js.map
300
+
301
+ export { QueryBuilderImpl as default };