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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -0,0 +1,31 @@
1
+ import { sqlFormat } from './sqlFormat.js';
2
+ import { xmlFormat } from './xmlFormat.js';
3
+ import { sqlSafeFormat } from './sqlSafeFormat.js';
4
+
5
+ class QueryBuilderFormat {
6
+ constructor() {
7
+ this.format = {
8
+ defaultFormat: query => query,
9
+ sqlFormat,
10
+ xmlFormat,
11
+ sqlSafeFormat
12
+ };
13
+ this.currentFormat = 'sqlFormat';
14
+
15
+ this.setDefaultFormat = formatName => {
16
+ if (this.format[formatName]) this.currentFormat = formatName;
17
+ };
18
+
19
+ this.addFormat = (formatName, format) => this.format[formatName] = format;
20
+
21
+ this.run = (query, formatName) => {
22
+ if (this.format[formatName]) return this.format[formatName](query);
23
+ return this.format[this.currentFormat](query);
24
+ };
25
+ }
26
+
27
+ }
28
+
29
+ var QueryBuilderFormat$1 = new QueryBuilderFormat();
30
+
31
+ export { QueryBuilderFormat$1 as default };
@@ -0,0 +1,69 @@
1
+ import 'core-js/modules/esnext.async-iterator.map.js';
2
+ import 'core-js/modules/esnext.iterator.map.js';
3
+ import { QB_OPERATOR_TYPES } from '../helpers/types.js';
4
+
5
+ const conditionSql = (condition, value) => {
6
+ const {
7
+ EQUAL,
8
+ NOT_EQUAL,
9
+ GREATER_THAN,
10
+ LESS_THAN,
11
+ CONTAINS,
12
+ NOT_CONTAINS,
13
+ BETWEEN,
14
+ GREATER_THAN_OR_EQUAL,
15
+ LESS_THAN_OR_EQUAL,
16
+ START_WITH
17
+ } = QB_OPERATOR_TYPES;
18
+ if (condition === EQUAL) return " = '".concat(value, "'");
19
+ if (condition === NOT_EQUAL) return " <> '".concat(value, "'");
20
+ if (condition === GREATER_THAN) return " > ".concat(value);
21
+ if (condition === LESS_THAN) return " < ".concat(value);
22
+ if (condition === CONTAINS) return " LIKE '%".concat(value, "%'");
23
+ if (condition === NOT_CONTAINS) return " NOT LIKE '%".concat(value, "%'");
24
+ if (condition === BETWEEN) return " BETWEEN ".concat(value[0], " AND ").concat(value[1], " ");
25
+ if (condition === GREATER_THAN_OR_EQUAL) return " >= ".concat(value);
26
+ if (condition === LESS_THAN_OR_EQUAL) return " <= ".concat(value);
27
+ if (condition === START_WITH) return " LIKE '".concat(value, "%'");
28
+ return condition;
29
+ };
30
+
31
+ const renderFilterSQl = filter => {
32
+ const {
33
+ field,
34
+ operator,
35
+ value
36
+ } = filter.element;
37
+ return "".concat(field, " ").concat(conditionSql(operator, value) || '');
38
+ };
39
+
40
+ const sqlFormat = _ref => {
41
+ let {
42
+ main,
43
+ mapGroups,
44
+ items
45
+ } = _ref;
46
+
47
+ const groupSql = (item, idGroup) => {
48
+ if (idGroup === main) {
49
+ const groupCondition = mapGroups[idGroup].condition === true ? 'AND' : 'OR';
50
+ return " ( ".concat(filterSql(item, groupCondition), " ) "); // eslint-disable-line
51
+ }
52
+
53
+ const groupCondition = item.element.condition === true ? 'AND' : 'OR';
54
+ return " ( ".concat(filterSql(item.children, groupCondition), " ) "); // eslint-disable-line
55
+ };
56
+
57
+ const filterSql = (filters, groupCondition) => {
58
+ const filterGroup = filters.map(filter => {
59
+ if (filter.element.type === 'filter') return " ".concat(renderFilterSQl(filter), " ");
60
+ return " ".concat(groupSql(filter) || '', " ");
61
+ });
62
+ return filterGroup.join(groupCondition);
63
+ };
64
+
65
+ const sql = " FROM [TABLE_NAME] WHERE ".concat(groupSql(items, main) || '', " ");
66
+ return sql;
67
+ };
68
+
69
+ export { sqlFormat };
@@ -0,0 +1,76 @@
1
+ import 'core-js/modules/esnext.async-iterator.map.js';
2
+ import 'core-js/modules/esnext.iterator.map.js';
3
+ import { QB_OPERATOR_TYPES } from '../helpers/types.js';
4
+
5
+ const specialChar = /[ !@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/;
6
+
7
+ const conditionSql = (condition, value) => {
8
+ const {
9
+ EQUAL,
10
+ NOT_EQUAL,
11
+ GREATER_THAN,
12
+ LESS_THAN,
13
+ CONTAINS,
14
+ NOT_CONTAINS,
15
+ BETWEEN,
16
+ GREATER_THAN_OR_EQUAL,
17
+ LESS_THAN_OR_EQUAL,
18
+ START_WITH
19
+ } = QB_OPERATOR_TYPES; // eslint-disable-next-line no-restricted-globals
20
+
21
+ const valueDisplay = isNaN(value) ? "'".concat(value, "'") : value;
22
+ if (condition === EQUAL) return " = ".concat(valueDisplay);
23
+ if (condition === NOT_EQUAL) return " <> ".concat(valueDisplay);
24
+ if (condition === GREATER_THAN) return " > ".concat(valueDisplay);
25
+ if (condition === LESS_THAN) return " < ".concat(valueDisplay);
26
+ if (condition === CONTAINS) return " LIKE '%".concat(value, "%'");
27
+ if (condition === NOT_CONTAINS) return " NOT LIKE '%".concat(value, "%'");
28
+ if (condition === BETWEEN) return " BETWEEN ".concat(value[0], " AND ").concat(value[1], " ");
29
+ if (condition === GREATER_THAN_OR_EQUAL) return " >= ".concat(value);
30
+ if (condition === LESS_THAN_OR_EQUAL) return " <= ".concat(value);
31
+ if (condition === START_WITH) return " LIKE '".concat(value, "%'");
32
+ return condition;
33
+ };
34
+
35
+ const renderFilterSQl = filter => {
36
+ const {
37
+ field,
38
+ operator,
39
+ value
40
+ } = filter.element; // eslint-disable-next-line no-restricted-globals
41
+
42
+ const fieldDisplay = // eslint-disable-next-line no-restricted-globals
43
+ /[.]/.test(field) || !isNaN(field) ? "\\\"".concat(field, "\\\"") : field;
44
+ return "".concat(fieldDisplay, " ").concat(conditionSql(operator, value) || '');
45
+ };
46
+
47
+ const sqlSafeFormat = _ref => {
48
+ let {
49
+ main,
50
+ mapGroups,
51
+ items
52
+ } = _ref;
53
+
54
+ const groupSql = (item, idGroup) => {
55
+ if (idGroup === main) {
56
+ const groupCondition = mapGroups[idGroup].condition === true ? 'AND' : 'OR';
57
+ return " ( ".concat(filterSql(item, groupCondition), " ) "); // eslint-disable-line
58
+ }
59
+
60
+ const groupCondition = item.element.condition === true ? 'AND' : 'OR';
61
+ return " ( ".concat(filterSql(item.children, groupCondition), " ) "); // eslint-disable-line
62
+ };
63
+
64
+ const filterSql = (filters, groupCondition) => {
65
+ const filterGroup = filters.map(filter => {
66
+ if (filter.element.type === 'filter') return " ".concat(renderFilterSQl(filter), " ");
67
+ return " ".concat(groupSql(filter) || '', " ");
68
+ });
69
+ return filterGroup.join(groupCondition);
70
+ };
71
+
72
+ const sql = " FROM [TABLE_NAME] WHERE ".concat(groupSql(items, main) || '', " ");
73
+ return sql;
74
+ };
75
+
76
+ export { specialChar, sqlSafeFormat };
@@ -0,0 +1,69 @@
1
+ import 'core-js/modules/esnext.async-iterator.map.js';
2
+ import 'core-js/modules/esnext.iterator.map.js';
3
+ import { QB_OPERATOR_TYPES } from '../helpers/types.js';
4
+
5
+ const conditionSql = (condition, value) => {
6
+ const {
7
+ EQUAL,
8
+ NOT_EQUAL,
9
+ GREATER_THAN,
10
+ LESS_THAN,
11
+ CONTAINS,
12
+ NOT_CONTAINS,
13
+ BETWEEN,
14
+ GREATER_THAN_OR_EQUAL,
15
+ LESS_THAN_OR_EQUAL,
16
+ START_WITH
17
+ } = QB_OPERATOR_TYPES;
18
+ if (condition === EQUAL) return "<condition>EQUAL</condition><value>".concat(value, "</value>");
19
+ if (condition === NOT_EQUAL) return "<condition>NOT_EQUAL</condition><value>".concat(value, "</value>");
20
+ if (condition === GREATER_THAN) return "<condition>GREATER_THAN</condition><value>".concat(value, "</value>");
21
+ if (condition === LESS_THAN) return "<condition>LESS_THAN</condition><value>".concat(value, "</value>");
22
+ if (condition === CONTAINS) return "<condition>LIKE</condition><value>".concat(value, "</value>");
23
+ if (condition === NOT_CONTAINS) return "<condition>NOT_LIKE</condition><value>".concat(value, "</value>");
24
+ if (condition === BETWEEN) return "<condition>NOT_LIKE</condition><value><from>".concat(value[0], "</from><to>").concat(value[1], "</to></value>");
25
+ if (condition === GREATER_THAN_OR_EQUAL) return "<condition>GREATER_THAN_OR_EQUAL</condition><value>".concat(value, "</value>");
26
+ if (condition === LESS_THAN_OR_EQUAL) return "<condition>LESS_THAN_OR_EQUAL</condition><value>".concat(value, "</value>");
27
+ if (condition === START_WITH) return "<condition>GREATER_THAN</condition><value>".concat(value, "</value>");
28
+ return condition;
29
+ };
30
+
31
+ const renderFilterSQl = filter => {
32
+ const {
33
+ field,
34
+ operator,
35
+ value
36
+ } = filter.element;
37
+ return "<filter><field>".concat(field, "</field>").concat(conditionSql(operator, value) || '', "</filter>");
38
+ };
39
+
40
+ const xmlFormat = _ref => {
41
+ let {
42
+ main,
43
+ mapGroups,
44
+ items
45
+ } = _ref;
46
+
47
+ const groupXML = (item, idGroup) => {
48
+ if (idGroup === main) {
49
+ const groupCondition = mapGroups[idGroup].condition === true ? 'AND' : 'OR';
50
+ return "<group value=\"".concat(groupCondition, "\">").concat(filterXML(item), "</group>"); // eslint-disable-line
51
+ }
52
+
53
+ const groupCondition = item.element.condition === true ? 'AND' : 'OR';
54
+ return "<group value=\"".concat(groupCondition, "\">").concat(filterXML(item.children), "</group>"); // eslint-disable-line
55
+ };
56
+
57
+ const filterXML = filters => {
58
+ const filterGroup = filters.map(filter => {
59
+ if (filter.element.type === 'filter') return "".concat(renderFilterSQl(filter) || '', " ");
60
+ return " ".concat(groupXML(filter), " ");
61
+ });
62
+ return filterGroup.join('');
63
+ };
64
+
65
+ const xml = "<xml><query>".concat(groupXML(items, main) || '', "</query></xml>");
66
+ return xml;
67
+ };
68
+
69
+ export { xmlFormat };
@@ -0,0 +1,254 @@
1
+ import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
2
+ import 'core-js/modules/esnext.async-iterator.find.js';
3
+ import 'core-js/modules/esnext.iterator.constructor.js';
4
+ import 'core-js/modules/esnext.iterator.find.js';
5
+ import 'core-js/modules/esnext.async-iterator.for-each.js';
6
+ import 'core-js/modules/esnext.iterator.for-each.js';
7
+ import 'core-js/modules/esnext.async-iterator.filter.js';
8
+ import 'core-js/modules/esnext.iterator.filter.js';
9
+ import 'core-js/modules/esnext.async-iterator.map.js';
10
+ import 'core-js/modules/esnext.iterator.map.js';
11
+ import { QB_DRAG_TYPES, QB_GROUP_CONDITION_TYPES, QB_FIELD_SHARED_ACTIONS } from './types.js';
12
+
13
+ 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; }
14
+
15
+ 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; }
16
+ /**
17
+ * this is injected. instance of QBStore
18
+ *
19
+ * @param {*} idGroup: UUID
20
+ * @param idGroup
21
+ */
22
+
23
+ const createNewFilter = function (idGroup) {
24
+ const idFilter = "filter_".concat(new Date().getTime(), "_").concat(Math.random().toString(36).substring(7));
25
+ return {
26
+ idGroup,
27
+ field: '',
28
+ condition: '',
29
+ value: '',
30
+ idFilter,
31
+ type: QB_DRAG_TYPES.FILTER
32
+ };
33
+ };
34
+ /**
35
+ * this is injected. instance of QBStore
36
+ *
37
+ * @param {*} parentIdGroup: UUID
38
+ * @param parentIdGroup
39
+ */
40
+
41
+ const createNewGroup = function (parentIdGroup) {
42
+ const idGroup = "group_".concat(new Date().getTime(), "_").concat(Math.random().toString(36).substring(7));
43
+ return {
44
+ parentIdGroup,
45
+ idGroup,
46
+ condition: QB_GROUP_CONDITION_TYPES.AND,
47
+ type: QB_DRAG_TYPES.GROUP
48
+ };
49
+ };
50
+ /**
51
+ * this is injected. instance of QBStore
52
+ *
53
+ * @param {*} newFilter
54
+ */
55
+
56
+ const addFilterToMap = function (newFilter) {
57
+ this.mapFilters = _objectSpread(_objectSpread({}, this.mapFilters), {}, {
58
+ [newFilter.idFilter]: newFilter
59
+ });
60
+ };
61
+ /**
62
+ * this is injected. instance of QBStore
63
+ *
64
+ * @param {*} newFilter
65
+ * @param newGroup
66
+ */
67
+
68
+ const addGroupToMap = function (newGroup) {
69
+ this.mapGroups = _objectSpread(_objectSpread({}, this.mapGroups), {}, {
70
+ [newGroup.idGroup]: _objectSpread({}, newGroup)
71
+ });
72
+ };
73
+ const addFilterToItem = function (item, newFilter) {
74
+ item.children.push({
75
+ id: newFilter.idFilter,
76
+ element: newFilter,
77
+ children: []
78
+ });
79
+ };
80
+ const addFilterToMainItem = function (items, newFilter) {
81
+ items.push({
82
+ id: newFilter.idFilter,
83
+ element: newFilter,
84
+ children: []
85
+ });
86
+ };
87
+ const findInChilds = function (childs, filterId) {
88
+ const found = childs.find(_ref => {
89
+ let {
90
+ id
91
+ } = _ref;
92
+ return id === filterId;
93
+ });
94
+
95
+ if (!found) {
96
+ let findInChild;
97
+ childs.forEach(item => {
98
+ if (!findInChild) findInChild = findInChilds(item.children, filterId);
99
+ });
100
+ if (findInChild) return findInChild;
101
+ }
102
+
103
+ return found;
104
+ };
105
+ const findItemFilterById = function (filterId) {
106
+ return findInChilds(this.items, filterId);
107
+ };
108
+ const findParentWithFilterId = function (childs, filterId) {
109
+ const found = childs.find(_ref2 => {
110
+ let {
111
+ id
112
+ } = _ref2;
113
+ return id === filterId;
114
+ });
115
+
116
+ if (!found) {
117
+ let findInChild;
118
+ childs.forEach(item => {
119
+ if (!findInChild) findInChild = findParentWithFilterId(item.children, filterId);
120
+ });
121
+ if (findInChild) return findInChild;
122
+ }
123
+
124
+ return childs;
125
+ };
126
+ const findParentFilterById = function (filterId) {
127
+ return findParentWithFilterId(this.items, filterId);
128
+ };
129
+ const filterInChildren = function (childs, filterId, mainId) {
130
+ if (childs.children) {
131
+ childs.children = childs.children.filter(_ref3 => {
132
+ let {
133
+ id
134
+ } = _ref3;
135
+ return id !== filterId;
136
+ });
137
+ childs.children = childs.children.forEach(item => filterInChildren(item.children, filterId));
138
+ return childs;
139
+ } // main
140
+
141
+
142
+ if (childs.length > 1) childs = childs.filter(_ref4 => {
143
+ let {
144
+ id
145
+ } = _ref4;
146
+ return id !== filterId;
147
+ }); // https://jira.elliemae.io/browse/PUI-1252
148
+
149
+ if (childs.length === 0 && mainId) {
150
+ const emptyFilter = createNewFilter.call(this, mainId);
151
+ addFilterToMainItem.call(this, childs, emptyFilter);
152
+ }
153
+
154
+ childs.forEach(item => item.children = filterInChildren(item.children, filterId));
155
+ return childs;
156
+ };
157
+ const removeFilterItem = function (filterId) {
158
+ this.items = filterInChildren(this.items, filterId, this.main);
159
+ };
160
+ const addGroupFilterToItem = function (idGroup, idFilter, newGroup) {
161
+ const child = findItemFilterById.call(this, idFilter);
162
+
163
+ const copy = _objectSpread({}, child);
164
+
165
+ if (copy.element.type === 'group') {
166
+ copy.element.parentIdGroup = newGroup.idGroup;
167
+ } else {
168
+ copy.element.idGroup = newGroup.idGroup;
169
+ }
170
+
171
+ child.id = newGroup.idGroup;
172
+ child.element = newGroup;
173
+ child.children = [copy];
174
+ };
175
+ const unGroupFilterToItem = function (idGroup) {
176
+ const group = findItemFilterById.call(this, idGroup);
177
+
178
+ if (group.element.parentIdGroup === this.main) {
179
+ const index = this.items.map(item => item.id).indexOf(idGroup);
180
+ const tmp = [];
181
+ tmp.splice.apply(this.items, [index, 1].concat(group.children));
182
+ this.items.forEach(item => {
183
+ if (item.element.type === 'group') {
184
+ item.element.parentIdGroup = this.main;
185
+ } else {
186
+ item.element.idGroup = this.main;
187
+ }
188
+ });
189
+ } else {
190
+ const parent = findItemFilterById.call(this, group.element.parentIdGroup);
191
+ const index = parent.children.map(item => item.id).indexOf(idGroup);
192
+ const tmp = [];
193
+ tmp.splice.apply(parent.children, [index, 1].concat(group.children));
194
+ parent.children.forEach(item => {
195
+ if (item.element.type === 'group') {
196
+ item.element.parentIdGroup = parent.id;
197
+ } else {
198
+ item.element.idGroup = parent.id;
199
+ }
200
+ });
201
+ }
202
+ };
203
+ const changeGroupOperator = function (idGroup, value) {
204
+ const group = findItemFilterById.call(this, idGroup);
205
+
206
+ if (idGroup !== this.main) {
207
+ group.element.condition = value;
208
+ }
209
+ };
210
+ const changeFilterItem = function (_ref5) {
211
+ let {
212
+ idFilter,
213
+ field,
214
+ value,
215
+ operator,
216
+ additionalInfo,
217
+ target,
218
+ fieldsSharedActions: {
219
+ onFieldChange,
220
+ onOperatorChange,
221
+ onValueChange
222
+ }
223
+ } = _ref5;
224
+ const child = findItemFilterById.call(this, idFilter);
225
+ if (field || field === '' || typeof field === 'boolean') child.element.field = field;
226
+ if (operator) child.element.operator = operator;
227
+ if (value || value === '' || typeof value === 'boolean') child.element.value = value;
228
+ if (additionalInfo) child.element.additionalInfo = additionalInfo; // shared fields actions
229
+
230
+ if (target === 'field') {
231
+ onFieldChange.forEach(_ref6 => {
232
+ let {
233
+ action
234
+ } = _ref6;
235
+ if (action === QB_FIELD_SHARED_ACTIONS.RESET_FIELD) child.element.field = null;else if (action === QB_FIELD_SHARED_ACTIONS.RESET_OPERATOR) child.element.operator = null;else if (action === QB_FIELD_SHARED_ACTIONS.RESET_VALUE) child.element.value = null;
236
+ });
237
+ } else if (target === 'operator') {
238
+ onOperatorChange.forEach(_ref7 => {
239
+ let {
240
+ action
241
+ } = _ref7;
242
+ if (action === QB_FIELD_SHARED_ACTIONS.RESET_FIELD) child.element.field = null;else if (action === QB_FIELD_SHARED_ACTIONS.RESET_OPERATOR) child.element.operator = null;else if (action === QB_FIELD_SHARED_ACTIONS.RESET_VALUE) child.element.value = null;
243
+ });
244
+ } else if (target === 'value') {
245
+ onValueChange.forEach(_ref8 => {
246
+ let {
247
+ action
248
+ } = _ref8;
249
+ if (action === QB_FIELD_SHARED_ACTIONS.RESET_FIELD) child.element.field = null;else if (action === QB_FIELD_SHARED_ACTIONS.RESET_OPERATOR) child.element.operator = null;else if (action === QB_FIELD_SHARED_ACTIONS.RESET_VALUE) child.element.value = null;
250
+ });
251
+ }
252
+ };
253
+
254
+ export { addFilterToItem, addFilterToMainItem, addFilterToMap, addGroupFilterToItem, addGroupToMap, changeFilterItem, changeGroupOperator, createNewFilter, createNewGroup, filterInChildren, findInChilds, findItemFilterById, findParentFilterById, findParentWithFilterId, removeFilterItem, unGroupFilterToItem };
@@ -0,0 +1,5 @@
1
+ const DELAY_CLOSE = 0.1;
2
+ const DELAY_OPEN = 0.1;
3
+ const TOOLBAR_ANIMATION_DURATION = 50;
4
+
5
+ export { DELAY_CLOSE, DELAY_OPEN, TOOLBAR_ANIMATION_DURATION };
@@ -0,0 +1,60 @@
1
+ import 'core-js/modules/esnext.async-iterator.every.js';
2
+ import 'core-js/modules/esnext.iterator.constructor.js';
3
+ import 'core-js/modules/esnext.iterator.every.js';
4
+ import 'core-js/modules/esnext.async-iterator.some.js';
5
+ import 'core-js/modules/esnext.iterator.some.js';
6
+ import 'core-js/modules/esnext.async-iterator.reduce.js';
7
+ import 'core-js/modules/esnext.iterator.reduce.js';
8
+ import { get } from 'lodash';
9
+ import * as operators from '@elliemae/ds-utilities/operators';
10
+ import { QB_GROUP_CONDITION_TYPES } from './types.js';
11
+
12
+ const resolveCondition = function (condition, state) {
13
+ let resolveBy = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : QB_GROUP_CONDITION_TYPES.AND;
14
+ if (condition.length === 0 || !condition) return true; // resolve by AND: all the conditions must be true
15
+
16
+ if (resolveBy) {
17
+ return condition.every(rule => {
18
+ const {
19
+ source: sourceRule,
20
+ operator: operatorRule,
21
+ value: valueRule
22
+ } = rule;
23
+ if (typeof operatorRule === "function") return operatorRule(get(state, sourceRule), valueRule);
24
+ return operators[operatorRule](get(state, sourceRule), valueRule);
25
+ });
26
+ } // resolve by OR: at least one condition must be true
27
+
28
+
29
+ return condition.some(rule => {
30
+ const {
31
+ source: sourceRule,
32
+ operator: operatorRule,
33
+ value: valueRule
34
+ } = rule;
35
+ return operators[operatorRule](state[sourceRule], valueRule);
36
+ });
37
+ };
38
+
39
+ const resolveDependencies = (state, fields) => {
40
+ const fieldsToRender = fields.reduce((result, _ref) => {
41
+ let {
42
+ target,
43
+ component,
44
+ condition,
45
+ resolveBy,
46
+ validation,
47
+ handleWidth
48
+ } = _ref;
49
+ if (resolveCondition(condition, state, resolveBy)) result.push({
50
+ target,
51
+ component,
52
+ validation,
53
+ handleWidth
54
+ });
55
+ return result;
56
+ }, []);
57
+ return fieldsToRender;
58
+ };
59
+
60
+ export { resolveDependencies };
@@ -0,0 +1,93 @@
1
+ import { QB_FIELD_TYPES, QB_OPERATOR_TYPES } from './types.js';
2
+
3
+ const QB_DEFAULT_VALUES_OPTIONS = [{
4
+ label: 'Choose a Field',
5
+ value: ''
6
+ }];
7
+ const QB_SUBJECT_VALUES_OPTIONS = [{
8
+ label: 'Condominium',
9
+ value: 'Condominium'
10
+ }, {
11
+ label: 'Single Family Home',
12
+ value: 'Single Family Home'
13
+ }, {
14
+ label: 'Co-Operative',
15
+ value: 'Co-Operative'
16
+ }, {
17
+ label: 'Detached',
18
+ value: 'Detached'
19
+ }, {
20
+ label: 'High Rise Condominium',
21
+ value: 'High Rise Condominium'
22
+ }, {
23
+ label: 'Manufactured Housing',
24
+ value: 'Manufactured Housing'
25
+ }, {
26
+ label: 'Other',
27
+ value: 'Other'
28
+ }];
29
+ const QB_LOAN_VALUES_OPTIONS = [{
30
+ label: 'Conventional',
31
+ value: 'Conventional'
32
+ }, {
33
+ label: 'VA',
34
+ value: 'VA'
35
+ }, {
36
+ label: 'FHA',
37
+ value: 'FHA'
38
+ }, {
39
+ label: 'USAD-RHS',
40
+ value: 'USAD-RHS'
41
+ }, {
42
+ label: 'HELOC',
43
+ value: 'HELOC'
44
+ }, {
45
+ label: 'Other',
46
+ value: 'Other'
47
+ }];
48
+ const QB_FIELD_OPTIONS = [{
49
+ label: 'Select',
50
+ value: ''
51
+ }, {
52
+ label: 'Loan Type',
53
+ value: QB_FIELD_TYPES.LOAN_VALUES
54
+ }, {
55
+ label: 'Loan To Value (LTV)',
56
+ value: QB_FIELD_TYPES.LTV_VALUES
57
+ }, {
58
+ label: 'Subject Property Type',
59
+ value: QB_FIELD_TYPES.SUBJECT_VALUES
60
+ }, {
61
+ label: 'Last Finished Milestone',
62
+ value: QB_FIELD_TYPES.LAST_VALUES
63
+ }, {
64
+ label: 'Credit Score',
65
+ value: QB_FIELD_TYPES.CREDIT_VALUES
66
+ }];
67
+ const QB_OPERATOR_OPTIONS = [{
68
+ label: 'Select',
69
+ value: ''
70
+ }, {
71
+ label: 'Is',
72
+ value: QB_OPERATOR_TYPES.EQUAL
73
+ }, {
74
+ label: 'Is not',
75
+ value: QB_OPERATOR_TYPES.NOT_EQUAL
76
+ }, {
77
+ label: 'Greater than',
78
+ value: QB_OPERATOR_TYPES.GREATER_THAN
79
+ }, {
80
+ label: 'Less than',
81
+ value: QB_OPERATOR_TYPES.LESS_THAN
82
+ }, {
83
+ label: 'Contains',
84
+ value: QB_OPERATOR_TYPES.CONTAINS
85
+ }, {
86
+ label: "Doesn't Contain",
87
+ value: QB_OPERATOR_TYPES.NOT_CONTAINS
88
+ }, {
89
+ label: 'Between',
90
+ value: QB_OPERATOR_TYPES.BETWEEN
91
+ }];
92
+
93
+ export { QB_DEFAULT_VALUES_OPTIONS, QB_FIELD_OPTIONS, QB_LOAN_VALUES_OPTIONS, QB_OPERATOR_OPTIONS, QB_SUBJECT_VALUES_OPTIONS };