@elliemae/ds-query-builder 2.3.0-alpha.9 → 2.3.0-next.11

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 (242) hide show
  1. package/cjs/DSQueryBuilder.js +98 -0
  2. package/cjs/components/AndOrController/AndOrController.js +222 -0
  3. package/cjs/components/ConditionController/ConditionController.js +100 -0
  4. package/cjs/components/DisplayOutput/DisplayOutput.js +93 -0
  5. package/cjs/components/DragContainerController/DragContainerController.js +45 -0
  6. package/cjs/components/DragControllerRow/DragControllerRow.js +47 -0
  7. package/cjs/components/FieldControllerRow/FieldControllerRow.js +33 -0
  8. package/cjs/components/Nestable/Nestable.js +320 -0
  9. package/cjs/components/Nestable/NestableItem.js +111 -0
  10. package/cjs/components/Nestable/actions/events.js +166 -0
  11. package/cjs/components/Nestable/actions/getItemOptions.js +28 -0
  12. package/cjs/components/Nestable/actions/getPaths.js +124 -0
  13. package/cjs/components/Nestable/actions/index.js +28 -0
  14. package/cjs/components/Nestable/actions/moveItem.js +54 -0
  15. package/cjs/components/Nestable/actions/paths.js +126 -0
  16. package/cjs/components/Nestable/actions/tryDecreaseDepth.js +35 -0
  17. package/cjs/components/Nestable/actions/tryIncreaseDepth.js +38 -0
  18. package/cjs/components/Nestable/index.js +7 -0
  19. package/cjs/components/QueryBuilderContext/QueryBuilderContext.js +13 -0
  20. package/cjs/components/QueryBuilderImpl.js +309 -0
  21. package/cjs/components/QueryBuilderItem/QueryBuilderItem.js +90 -0
  22. package/cjs/components/QueryBuilderRow/QueryBuilderRow.js +276 -0
  23. package/cjs/components/ToolBarAnimation/ToolBarAnimation.js +29 -0
  24. package/cjs/components/format/format.js +33 -0
  25. package/cjs/components/format/sqlFormat.js +73 -0
  26. package/cjs/components/format/sqlSafeFormat.js +81 -0
  27. package/cjs/components/format/xmlFormat.js +73 -0
  28. package/cjs/components/helpers/actions.js +277 -0
  29. package/cjs/components/helpers/constants.js +11 -0
  30. package/cjs/components/helpers/dependencies.js +84 -0
  31. package/cjs/components/helpers/selectors.js +101 -0
  32. package/cjs/components/helpers/store.js +177 -0
  33. package/cjs/components/helpers/types.js +64 -0
  34. package/cjs/index.js +29 -0
  35. package/cjs/propTypes.js +97 -0
  36. package/esm/DSQueryBuilder.js +74 -0
  37. package/esm/components/AndOrController/AndOrController.js +213 -0
  38. package/esm/components/ConditionController/ConditionController.js +92 -0
  39. package/esm/components/DisplayOutput/DisplayOutput.js +87 -0
  40. package/esm/components/DragContainerController/DragContainerController.js +39 -0
  41. package/esm/components/DragControllerRow/DragControllerRow.js +39 -0
  42. package/esm/components/FieldControllerRow/FieldControllerRow.js +27 -0
  43. package/esm/components/Nestable/Nestable.js +312 -0
  44. package/esm/components/Nestable/NestableItem.js +103 -0
  45. package/esm/components/Nestable/actions/events.js +153 -0
  46. package/{dist/esm → esm}/components/Nestable/actions/getItemOptions.js +11 -7
  47. package/{dist/esm → esm}/components/Nestable/actions/getPaths.js +43 -17
  48. package/esm/components/Nestable/actions/index.js +6 -0
  49. package/esm/components/Nestable/actions/moveItem.js +45 -0
  50. package/{dist/esm → esm}/components/Nestable/actions/paths.js +47 -19
  51. package/esm/components/Nestable/actions/tryDecreaseDepth.js +31 -0
  52. package/{dist/esm → esm}/components/Nestable/actions/tryIncreaseDepth.js +22 -10
  53. package/esm/components/Nestable/index.js +2 -0
  54. package/esm/components/QueryBuilderContext/QueryBuilderContext.js +5 -0
  55. package/esm/components/QueryBuilderImpl.js +301 -0
  56. package/esm/components/QueryBuilderItem/QueryBuilderItem.js +83 -0
  57. package/esm/components/QueryBuilderRow/QueryBuilderRow.js +268 -0
  58. package/esm/components/ToolBarAnimation/ToolBarAnimation.js +20 -0
  59. package/esm/components/format/format.js +31 -0
  60. package/esm/components/format/sqlFormat.js +69 -0
  61. package/esm/components/format/sqlSafeFormat.js +76 -0
  62. package/esm/components/format/xmlFormat.js +69 -0
  63. package/esm/components/helpers/actions.js +254 -0
  64. package/esm/components/helpers/constants.js +5 -0
  65. package/esm/components/helpers/dependencies.js +60 -0
  66. package/esm/components/helpers/selectors.js +93 -0
  67. package/esm/components/helpers/store.js +171 -0
  68. package/esm/components/helpers/types.js +52 -0
  69. package/esm/index.js +4 -0
  70. package/esm/propTypes.js +93 -0
  71. package/package.json +95 -97
  72. package/{dist/types → types}/DSQueryBuilder.d.ts +0 -0
  73. package/{dist/types → types}/components/AndOrController/AndOrController.d.ts +0 -0
  74. package/{dist/types → types}/components/ConditionController/ConditionController.d.ts +0 -0
  75. package/{dist/types → types}/components/DisplayOutput/DisplayOutput.d.ts +0 -0
  76. package/{dist/types → types}/components/DragContainerController/DragContainerController.d.ts +0 -0
  77. package/{dist/types → types}/components/DragControllerRow/DragControllerRow.d.ts +0 -0
  78. package/{dist/types → types}/components/FieldControllerRow/FieldControllerRow.d.ts +0 -0
  79. package/{dist/types → types}/components/Nestable/Nestable.d.ts +0 -0
  80. package/{dist/types → types}/components/Nestable/NestableItem.d.ts +0 -0
  81. package/{dist/types → types}/components/Nestable/actions/events.d.ts +0 -0
  82. package/{dist/types → types}/components/Nestable/actions/getItemOptions.d.ts +0 -0
  83. package/{dist/types → types}/components/Nestable/actions/getPaths.d.ts +0 -0
  84. package/{dist/types → types}/components/Nestable/actions/index.d.ts +0 -0
  85. package/{dist/types → types}/components/Nestable/actions/moveItem.d.ts +0 -0
  86. package/{dist/types → types}/components/Nestable/actions/paths.d.ts +0 -0
  87. package/{dist/types → types}/components/Nestable/actions/tryDecreaseDepth.d.ts +0 -0
  88. package/{dist/types → types}/components/Nestable/actions/tryIncreaseDepth.d.ts +0 -0
  89. package/{dist/types → types}/components/Nestable/index.d.ts +0 -0
  90. package/{dist/types → types}/components/QueryBuilderContext/QueryBuilderContext.d.ts +0 -0
  91. package/{dist/types → types}/components/QueryBuilderImpl.d.ts +0 -0
  92. package/{dist/types → types}/components/QueryBuilderItem/QueryBuilderItem.d.ts +0 -0
  93. package/{dist/types → types}/components/QueryBuilderRow/QueryBuilderRow.d.ts +0 -0
  94. package/{dist/types → types}/components/ToolBarAnimation/ToolBarAnimation.d.ts +0 -0
  95. package/{dist/types → types}/components/format/format.d.ts +0 -0
  96. package/{dist/types → types}/components/format/sqlFormat.d.ts +0 -0
  97. package/{dist/types → types}/components/format/sqlSafeFormat.d.ts +0 -0
  98. package/{dist/types → types}/components/format/xmlFormat.d.ts +0 -0
  99. package/{dist/types → types}/components/helpers/actions.d.ts +0 -0
  100. package/{dist/types → types}/components/helpers/constants.d.ts +0 -0
  101. package/{dist/types → types}/components/helpers/dependencies.d.ts +0 -0
  102. package/{dist/types → types}/components/helpers/selectors.d.ts +0 -0
  103. package/{dist/types → types}/components/helpers/store.d.ts +0 -0
  104. package/{dist/types → types}/components/helpers/types.d.ts +0 -0
  105. package/{dist/types → types}/index.d.ts +0 -0
  106. package/{dist/types → types}/propTypes.d.ts +0 -0
  107. package/dist/cjs/DSQueryBuilder.js +0 -118
  108. package/dist/cjs/DSQueryBuilder.js.map +0 -7
  109. package/dist/cjs/components/AndOrController/AndOrController.js +0 -208
  110. package/dist/cjs/components/AndOrController/AndOrController.js.map +0 -7
  111. package/dist/cjs/components/ConditionController/ConditionController.js +0 -116
  112. package/dist/cjs/components/ConditionController/ConditionController.js.map +0 -7
  113. package/dist/cjs/components/DisplayOutput/DisplayOutput.js +0 -92
  114. package/dist/cjs/components/DisplayOutput/DisplayOutput.js.map +0 -7
  115. package/dist/cjs/components/DragContainerController/DragContainerController.js +0 -65
  116. package/dist/cjs/components/DragContainerController/DragContainerController.js.map +0 -7
  117. package/dist/cjs/components/DragControllerRow/DragControllerRow.js +0 -51
  118. package/dist/cjs/components/DragControllerRow/DragControllerRow.js.map +0 -7
  119. package/dist/cjs/components/FieldControllerRow/FieldControllerRow.js +0 -55
  120. package/dist/cjs/components/FieldControllerRow/FieldControllerRow.js.map +0 -7
  121. package/dist/cjs/components/Nestable/Nestable.js +0 -254
  122. package/dist/cjs/components/Nestable/Nestable.js.map +0 -7
  123. package/dist/cjs/components/Nestable/NestableItem.js +0 -119
  124. package/dist/cjs/components/Nestable/NestableItem.js.map +0 -7
  125. package/dist/cjs/components/Nestable/actions/events.js +0 -143
  126. package/dist/cjs/components/Nestable/actions/events.js.map +0 -7
  127. package/dist/cjs/components/Nestable/actions/getItemOptions.js +0 -49
  128. package/dist/cjs/components/Nestable/actions/getItemOptions.js.map +0 -7
  129. package/dist/cjs/components/Nestable/actions/getPaths.js +0 -119
  130. package/dist/cjs/components/Nestable/actions/getPaths.js.map +0 -7
  131. package/dist/cjs/components/Nestable/actions/index.js +0 -42
  132. package/dist/cjs/components/Nestable/actions/index.js.map +0 -7
  133. package/dist/cjs/components/Nestable/actions/moveItem.js +0 -56
  134. package/dist/cjs/components/Nestable/actions/moveItem.js.map +0 -7
  135. package/dist/cjs/components/Nestable/actions/paths.js +0 -119
  136. package/dist/cjs/components/Nestable/actions/paths.js.map +0 -7
  137. package/dist/cjs/components/Nestable/actions/tryDecreaseDepth.js +0 -51
  138. package/dist/cjs/components/Nestable/actions/tryDecreaseDepth.js.map +0 -7
  139. package/dist/cjs/components/Nestable/actions/tryIncreaseDepth.js +0 -51
  140. package/dist/cjs/components/Nestable/actions/tryIncreaseDepth.js.map +0 -7
  141. package/dist/cjs/components/Nestable/index.js +0 -36
  142. package/dist/cjs/components/Nestable/index.js.map +0 -7
  143. package/dist/cjs/components/QueryBuilderContext/QueryBuilderContext.js +0 -36
  144. package/dist/cjs/components/QueryBuilderContext/QueryBuilderContext.js.map +0 -7
  145. package/dist/cjs/components/QueryBuilderImpl.js +0 -225
  146. package/dist/cjs/components/QueryBuilderImpl.js.map +0 -7
  147. package/dist/cjs/components/QueryBuilderItem/QueryBuilderItem.js +0 -92
  148. package/dist/cjs/components/QueryBuilderItem/QueryBuilderItem.js.map +0 -7
  149. package/dist/cjs/components/QueryBuilderRow/QueryBuilderRow.js +0 -219
  150. package/dist/cjs/components/QueryBuilderRow/QueryBuilderRow.js.map +0 -7
  151. package/dist/cjs/components/ToolBarAnimation/ToolBarAnimation.js +0 -42
  152. package/dist/cjs/components/ToolBarAnimation/ToolBarAnimation.js.map +0 -7
  153. package/dist/cjs/components/format/format.js +0 -59
  154. package/dist/cjs/components/format/format.js.map +0 -7
  155. package/dist/cjs/components/format/sqlFormat.js +0 -94
  156. package/dist/cjs/components/format/sqlFormat.js.map +0 -7
  157. package/dist/cjs/components/format/sqlSafeFormat.js +0 -98
  158. package/dist/cjs/components/format/sqlSafeFormat.js.map +0 -7
  159. package/dist/cjs/components/format/xmlFormat.js +0 -94
  160. package/dist/cjs/components/format/xmlFormat.js.map +0 -7
  161. package/dist/cjs/components/helpers/actions.js +0 -242
  162. package/dist/cjs/components/helpers/actions.js.map +0 -7
  163. package/dist/cjs/components/helpers/constants.js +0 -39
  164. package/dist/cjs/components/helpers/constants.js.map +0 -7
  165. package/dist/cjs/components/helpers/dependencies.js +0 -69
  166. package/dist/cjs/components/helpers/dependencies.js.map +0 -7
  167. package/dist/cjs/components/helpers/selectors.js +0 -161
  168. package/dist/cjs/components/helpers/selectors.js.map +0 -7
  169. package/dist/cjs/components/helpers/store.js +0 -159
  170. package/dist/cjs/components/helpers/store.js.map +0 -7
  171. package/dist/cjs/components/helpers/types.js +0 -92
  172. package/dist/cjs/components/helpers/types.js.map +0 -7
  173. package/dist/cjs/index.js +0 -36
  174. package/dist/cjs/index.js.map +0 -7
  175. package/dist/cjs/propTypes.js +0 -105
  176. package/dist/cjs/propTypes.js.map +0 -7
  177. package/dist/esm/DSQueryBuilder.js +0 -105
  178. package/dist/esm/DSQueryBuilder.js.map +0 -7
  179. package/dist/esm/components/AndOrController/AndOrController.js +0 -179
  180. package/dist/esm/components/AndOrController/AndOrController.js.map +0 -7
  181. package/dist/esm/components/ConditionController/ConditionController.js +0 -87
  182. package/dist/esm/components/ConditionController/ConditionController.js.map +0 -7
  183. package/dist/esm/components/DisplayOutput/DisplayOutput.js +0 -63
  184. package/dist/esm/components/DisplayOutput/DisplayOutput.js.map +0 -7
  185. package/dist/esm/components/DragContainerController/DragContainerController.js +0 -36
  186. package/dist/esm/components/DragContainerController/DragContainerController.js.map +0 -7
  187. package/dist/esm/components/DragControllerRow/DragControllerRow.js +0 -22
  188. package/dist/esm/components/DragControllerRow/DragControllerRow.js.map +0 -7
  189. package/dist/esm/components/FieldControllerRow/FieldControllerRow.js +0 -26
  190. package/dist/esm/components/FieldControllerRow/FieldControllerRow.js.map +0 -7
  191. package/dist/esm/components/Nestable/Nestable.js +0 -241
  192. package/dist/esm/components/Nestable/Nestable.js.map +0 -7
  193. package/dist/esm/components/Nestable/NestableItem.js +0 -90
  194. package/dist/esm/components/Nestable/NestableItem.js.map +0 -7
  195. package/dist/esm/components/Nestable/actions/events.js +0 -119
  196. package/dist/esm/components/Nestable/actions/events.js.map +0 -7
  197. package/dist/esm/components/Nestable/actions/getItemOptions.js.map +0 -7
  198. package/dist/esm/components/Nestable/actions/getPaths.js.map +0 -7
  199. package/dist/esm/components/Nestable/actions/index.js +0 -13
  200. package/dist/esm/components/Nestable/actions/index.js.map +0 -7
  201. package/dist/esm/components/Nestable/actions/moveItem.js +0 -27
  202. package/dist/esm/components/Nestable/actions/moveItem.js.map +0 -7
  203. package/dist/esm/components/Nestable/actions/paths.js.map +0 -7
  204. package/dist/esm/components/Nestable/actions/tryDecreaseDepth.js +0 -22
  205. package/dist/esm/components/Nestable/actions/tryDecreaseDepth.js.map +0 -7
  206. package/dist/esm/components/Nestable/actions/tryIncreaseDepth.js.map +0 -7
  207. package/dist/esm/components/Nestable/index.js +0 -7
  208. package/dist/esm/components/Nestable/index.js.map +0 -7
  209. package/dist/esm/components/QueryBuilderContext/QueryBuilderContext.js +0 -7
  210. package/dist/esm/components/QueryBuilderContext/QueryBuilderContext.js.map +0 -7
  211. package/dist/esm/components/QueryBuilderImpl.js +0 -196
  212. package/dist/esm/components/QueryBuilderImpl.js.map +0 -7
  213. package/dist/esm/components/QueryBuilderItem/QueryBuilderItem.js +0 -63
  214. package/dist/esm/components/QueryBuilderItem/QueryBuilderItem.js.map +0 -7
  215. package/dist/esm/components/QueryBuilderRow/QueryBuilderRow.js +0 -190
  216. package/dist/esm/components/QueryBuilderRow/QueryBuilderRow.js.map +0 -7
  217. package/dist/esm/components/ToolBarAnimation/ToolBarAnimation.js +0 -13
  218. package/dist/esm/components/ToolBarAnimation/ToolBarAnimation.js.map +0 -7
  219. package/dist/esm/components/format/format.js +0 -30
  220. package/dist/esm/components/format/format.js.map +0 -7
  221. package/dist/esm/components/format/sqlFormat.js +0 -65
  222. package/dist/esm/components/format/sqlFormat.js.map +0 -7
  223. package/dist/esm/components/format/sqlSafeFormat.js +0 -69
  224. package/dist/esm/components/format/sqlSafeFormat.js.map +0 -7
  225. package/dist/esm/components/format/xmlFormat.js +0 -65
  226. package/dist/esm/components/format/xmlFormat.js.map +0 -7
  227. package/dist/esm/components/helpers/actions.js +0 -217
  228. package/dist/esm/components/helpers/actions.js.map +0 -7
  229. package/dist/esm/components/helpers/constants.js +0 -10
  230. package/dist/esm/components/helpers/constants.js.map +0 -7
  231. package/dist/esm/components/helpers/dependencies.js +0 -40
  232. package/dist/esm/components/helpers/dependencies.js.map +0 -7
  233. package/dist/esm/components/helpers/selectors.js +0 -132
  234. package/dist/esm/components/helpers/selectors.js.map +0 -7
  235. package/dist/esm/components/helpers/store.js +0 -143
  236. package/dist/esm/components/helpers/store.js.map +0 -7
  237. package/dist/esm/components/helpers/types.js +0 -63
  238. package/dist/esm/components/helpers/types.js.map +0 -7
  239. package/dist/esm/index.js +0 -7
  240. package/dist/esm/index.js.map +0 -7
  241. package/dist/esm/propTypes.js +0 -76
  242. package/dist/esm/propTypes.js.map +0 -7
@@ -1,69 +1,99 @@
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
51
  function getPathById(id, items) {
33
- const { childrenProp } = this.props;
52
+ const {
53
+ childrenProp
54
+ } = this.props;
34
55
  let path = [];
35
56
  items.every((item, i) => {
36
57
  if (item.id === id) {
37
58
  path.push(i);
38
59
  } else if (item[childrenProp]) {
39
60
  const childrenPath = this.getPathById(id, item[childrenProp]);
61
+
40
62
  if (childrenPath.length) {
41
63
  path = path.concat(i).concat(childrenPath);
42
64
  }
43
65
  }
66
+
44
67
  return path.length === 0;
45
68
  });
46
69
  return path;
47
70
  }
48
71
  function getItemByPath(path, items) {
49
- const { childrenProp } = this.props;
72
+ const {
73
+ childrenProp
74
+ } = this.props;
50
75
  let item = null;
51
- path.forEach((index) => {
76
+ path.forEach(index => {
52
77
  const list = item ? item[childrenProp] : items;
53
78
  item = list[index];
54
79
  });
55
80
  return item;
56
81
  }
57
82
  function getItemDepth(item) {
58
- const { childrenProp } = this.props;
83
+ const {
84
+ childrenProp
85
+ } = this.props;
59
86
  let level = 1;
87
+
60
88
  if (item[childrenProp].length > 0) {
61
89
  const childrenDepths = item[childrenProp].map(this.getItemDepth);
62
90
  level += Math.max(...childrenDepths);
63
91
  }
92
+
64
93
  return level;
65
94
  }
66
- function getSplicePath(path, options = {}) {
95
+ function getSplicePath(path) {
96
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
67
97
  const splicePath = {};
68
98
  const numToRemove = options.numToRemove || 0;
69
99
  const itemsToInsert = options.itemsToInsert || [];
@@ -74,17 +104,13 @@ function getSplicePath(path, options = {}) {
74
104
  currentPath.$splice = [[index, numToRemove, ...itemsToInsert]];
75
105
  } else {
76
106
  const nextPath = {};
77
- currentPath[index] = { [options.childrenProp]: nextPath };
107
+ currentPath[index] = {
108
+ [options.childrenProp]: nextPath
109
+ };
78
110
  currentPath = nextPath;
79
111
  }
80
112
  });
81
113
  return splicePath;
82
114
  }
83
- export {
84
- getItemByPath,
85
- getItemDepth,
86
- getPathById,
87
- getRealNextPath,
88
- getSplicePath
89
- };
90
- //# sourceMappingURL=getPaths.js.map
115
+
116
+ export { getItemByPath, getItemDepth, getPathById, getRealNextPath, getSplicePath };
@@ -0,0 +1,6 @@
1
+ export { tryIncreaseDepth } from './tryIncreaseDepth.js';
2
+ export { tryDecreaseDepth } from './tryDecreaseDepth.js';
3
+ export { moveItem } from './moveItem.js';
4
+ export { getItemByPath, getItemDepth, getPathById, getRealNextPath, getSplicePath } from './paths.js';
5
+ export { onDragEnd, onDragStart, onKeyDown, onMouseEnter, onMouseMove, onToggleCollapse } from './events.js';
6
+ export { getItemOptions } from './getItemOptions.js';
@@ -0,0 +1,45 @@
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 _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
7
+ import update from 'react-addons-update';
8
+
9
+ 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; }
10
+
11
+ 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; }
12
+ function moveItem(_ref) {
13
+ let {
14
+ dragItem,
15
+ pathFrom,
16
+ pathTo
17
+ } = _ref;
18
+ let extraProps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
19
+ const {
20
+ childrenProp
21
+ } = this.props;
22
+ let {
23
+ items
24
+ } = this.state; // the remove action might affect the next position,
25
+ // so update next coordinates accordingly
26
+
27
+ const realPathTo = this.getRealNextPath(pathFrom, pathTo);
28
+ const removePath = this.getSplicePath(pathFrom, {
29
+ numToRemove: 1,
30
+ childrenProp
31
+ });
32
+ const insertPath = this.getSplicePath(realPathTo, {
33
+ numToRemove: 0,
34
+ itemsToInsert: [dragItem],
35
+ childrenProp
36
+ });
37
+ items = update(items, removePath);
38
+ items = update(items, insertPath);
39
+ this.setState(_objectSpread({
40
+ items,
41
+ isDirty: true
42
+ }, extraProps));
43
+ }
44
+
45
+ export { moveItem };
@@ -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 };
@@ -0,0 +1,31 @@
1
+ function tryDecreaseDepth(dragItem) {
2
+ const {
3
+ childrenProp,
4
+ collapsed
5
+ } = this.props;
6
+ const pathFrom = this.getPathById(dragItem.id);
7
+ const itemIndex = pathFrom[pathFrom.length - 1]; // has parent
8
+
9
+ if (pathFrom.length > 1) {
10
+ const parent = this.getItemByPath(pathFrom.slice(0, -1)); // is last (by order) item in array
11
+
12
+ if (itemIndex + 1 === parent[childrenProp].length) {
13
+ const pathTo = pathFrom.slice(0, -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
+
16
+ let collapseProps = {};
17
+
18
+ if (collapsed && parent[childrenProp].length === 1) {
19
+ collapseProps = this.onToggleCollapse(parent, true);
20
+ }
21
+
22
+ this.moveItem({
23
+ dragItem,
24
+ pathFrom,
25
+ pathTo
26
+ }, collapseProps);
27
+ }
28
+ }
29
+ }
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 };
@@ -0,0 +1,2 @@
1
+ import Nestable from './Nestable.js';
2
+ export { default } from './Nestable.js';
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+
3
+ const QueryBuilderContext = /*#__PURE__*/React.createContext({});
4
+
5
+ export { QueryBuilderContext };