@elliemae/ds-query-builder 2.2.0 → 2.3.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/DSQueryBuilder.js +117 -97
- package/cjs/DSQueryBuilder.js.map +7 -0
- package/cjs/components/AndOrController/AndOrController.js +148 -162
- package/cjs/components/AndOrController/AndOrController.js.map +7 -0
- package/cjs/components/ConditionController/ConditionController.js +88 -72
- package/cjs/components/ConditionController/ConditionController.js.map +7 -0
- package/cjs/components/DisplayOutput/DisplayOutput.js +67 -64
- package/cjs/components/DisplayOutput/DisplayOutput.js.map +7 -0
- package/cjs/components/DragContainerController/DragContainerController.js +61 -41
- package/cjs/components/DragContainerController/DragContainerController.js.map +7 -0
- package/cjs/components/DragControllerRow/DragControllerRow.js +50 -46
- package/cjs/components/DragControllerRow/DragControllerRow.js.map +7 -0
- package/cjs/components/FieldControllerRow/FieldControllerRow.js +54 -32
- package/cjs/components/FieldControllerRow/FieldControllerRow.js.map +7 -0
- package/cjs/components/Nestable/Nestable.js +143 -209
- package/cjs/components/Nestable/Nestable.js.map +7 -0
- package/cjs/components/Nestable/NestableItem.js +98 -90
- package/cjs/components/Nestable/NestableItem.js.map +7 -0
- package/cjs/components/Nestable/actions/events.js +72 -95
- package/cjs/components/Nestable/actions/events.js.map +7 -0
- package/cjs/components/Nestable/actions/getItemOptions.js +36 -15
- package/cjs/components/Nestable/actions/getItemOptions.js.map +7 -0
- package/cjs/components/Nestable/actions/getPaths.js +46 -51
- package/cjs/components/Nestable/actions/getPaths.js.map +7 -0
- package/cjs/components/Nestable/actions/index.js +42 -28
- package/cjs/components/Nestable/actions/index.js.map +7 -0
- package/cjs/components/Nestable/actions/moveItem.js +44 -42
- package/cjs/components/Nestable/actions/moveItem.js.map +7 -0
- package/cjs/components/Nestable/actions/paths.js +48 -55
- package/cjs/components/Nestable/actions/paths.js.map +7 -0
- package/cjs/components/Nestable/actions/tryDecreaseDepth.js +39 -23
- package/cjs/components/Nestable/actions/tryDecreaseDepth.js.map +7 -0
- package/cjs/components/Nestable/actions/tryIncreaseDepth.js +39 -26
- package/cjs/components/Nestable/actions/tryIncreaseDepth.js.map +7 -0
- package/cjs/components/Nestable/index.js +36 -7
- package/cjs/components/Nestable/index.js.map +7 -0
- package/cjs/components/QueryBuilderContext/QueryBuilderContext.js +36 -13
- package/cjs/components/QueryBuilderContext/QueryBuilderContext.js.map +7 -0
- package/cjs/components/QueryBuilderImpl.js +118 -202
- package/cjs/components/QueryBuilderImpl.js.map +7 -0
- package/cjs/components/QueryBuilderItem/QueryBuilderItem.js +80 -78
- package/cjs/components/QueryBuilderItem/QueryBuilderItem.js.map +7 -0
- package/cjs/components/QueryBuilderRow/QueryBuilderRow.js +154 -211
- package/cjs/components/QueryBuilderRow/QueryBuilderRow.js.map +7 -0
- package/cjs/components/ToolBarAnimation/ToolBarAnimation.js +39 -26
- package/cjs/components/ToolBarAnimation/ToolBarAnimation.js.map +7 -0
- package/cjs/components/format/format.js +48 -22
- package/cjs/components/format/format.js.map +7 -0
- package/cjs/components/format/sqlFormat.js +69 -48
- package/cjs/components/format/sqlFormat.js.map +7 -0
- package/cjs/components/format/sqlSafeFormat.js +72 -55
- package/cjs/components/format/sqlSafeFormat.js.map +7 -0
- package/cjs/components/format/xmlFormat.js +71 -50
- package/cjs/components/format/xmlFormat.js.map +7 -0
- package/cjs/components/helpers/actions.js +151 -186
- package/cjs/components/helpers/actions.js.map +7 -0
- package/cjs/components/helpers/constants.js +36 -8
- package/cjs/components/helpers/constants.js.map +7 -0
- package/cjs/components/helpers/dependencies.js +49 -64
- package/cjs/components/helpers/dependencies.js.map +7 -0
- package/cjs/components/helpers/selectors.js +161 -101
- package/cjs/components/helpers/selectors.js.map +7 -0
- package/cjs/components/helpers/store.js +86 -104
- package/cjs/components/helpers/store.js.map +7 -0
- package/cjs/components/helpers/types.js +72 -44
- package/cjs/components/helpers/types.js.map +7 -0
- package/cjs/index.js +36 -29
- package/cjs/index.js.map +7 -0
- package/cjs/propTypes.js +102 -94
- package/cjs/propTypes.js.map +7 -0
- package/esm/DSQueryBuilder.js +103 -72
- package/esm/DSQueryBuilder.js.map +7 -0
- package/esm/components/AndOrController/AndOrController.js +113 -147
- package/esm/components/AndOrController/AndOrController.js.map +7 -0
- package/esm/components/ConditionController/ConditionController.js +57 -62
- package/esm/components/ConditionController/ConditionController.js.map +7 -0
- package/esm/components/DisplayOutput/DisplayOutput.js +35 -55
- package/esm/components/DisplayOutput/DisplayOutput.js.map +7 -0
- package/esm/components/DragContainerController/DragContainerController.js +32 -35
- package/esm/components/DragContainerController/DragContainerController.js.map +7 -0
- package/esm/components/DragControllerRow/DragControllerRow.js +21 -38
- package/esm/components/DragControllerRow/DragControllerRow.js.map +7 -0
- package/esm/components/FieldControllerRow/FieldControllerRow.js +25 -26
- package/esm/components/FieldControllerRow/FieldControllerRow.js.map +7 -0
- package/esm/components/Nestable/Nestable.js +115 -186
- package/esm/components/Nestable/Nestable.js.map +7 -0
- package/esm/components/Nestable/NestableItem.js +69 -82
- package/esm/components/Nestable/NestableItem.js.map +7 -0
- package/esm/components/Nestable/actions/events.js +45 -79
- package/esm/components/Nestable/actions/events.js.map +7 -0
- package/esm/components/Nestable/actions/getItemOptions.js +7 -11
- package/esm/components/Nestable/actions/getItemOptions.js.map +7 -0
- package/esm/components/Nestable/actions/getPaths.js +17 -43
- package/esm/components/Nestable/actions/getPaths.js.map +7 -0
- package/esm/components/Nestable/actions/index.js +13 -6
- package/esm/components/Nestable/actions/index.js.map +7 -0
- package/esm/components/Nestable/actions/moveItem.js +13 -31
- package/esm/components/Nestable/actions/moveItem.js.map +7 -0
- package/esm/components/Nestable/actions/paths.js +19 -47
- package/esm/components/Nestable/actions/paths.js.map +7 -0
- package/esm/components/Nestable/actions/tryDecreaseDepth.js +10 -19
- package/esm/components/Nestable/actions/tryDecreaseDepth.js.map +7 -0
- package/esm/components/Nestable/actions/tryIncreaseDepth.js +10 -22
- package/esm/components/Nestable/actions/tryIncreaseDepth.js.map +7 -0
- package/esm/components/Nestable/index.js +7 -2
- package/esm/components/Nestable/index.js.map +7 -0
- package/esm/components/QueryBuilderContext/QueryBuilderContext.js +7 -5
- package/esm/components/QueryBuilderContext/QueryBuilderContext.js.map +7 -0
- package/esm/components/QueryBuilderImpl.js +82 -187
- package/esm/components/QueryBuilderImpl.js.map +7 -0
- package/esm/components/QueryBuilderItem/QueryBuilderItem.js +50 -70
- package/esm/components/QueryBuilderItem/QueryBuilderItem.js.map +7 -0
- package/esm/components/QueryBuilderRow/QueryBuilderRow.js +123 -201
- package/esm/components/QueryBuilderRow/QueryBuilderRow.js.map +7 -0
- package/esm/components/ToolBarAnimation/ToolBarAnimation.js +10 -17
- package/esm/components/ToolBarAnimation/ToolBarAnimation.js.map +7 -0
- package/esm/components/format/format.js +16 -17
- package/esm/components/format/format.js.map +7 -0
- package/esm/components/format/sqlFormat.js +39 -43
- package/esm/components/format/sqlFormat.js.map +7 -0
- package/esm/components/format/sqlSafeFormat.js +43 -50
- package/esm/components/format/sqlSafeFormat.js.map +7 -0
- package/esm/components/format/xmlFormat.js +41 -45
- package/esm/components/format/xmlFormat.js.map +7 -0
- package/esm/components/helpers/actions.js +123 -160
- package/esm/components/helpers/actions.js.map +7 -0
- package/esm/components/helpers/constants.js +7 -2
- package/esm/components/helpers/constants.js.map +7 -0
- package/esm/components/helpers/dependencies.js +19 -39
- package/esm/components/helpers/dependencies.js.map +7 -0
- package/esm/components/helpers/selectors.js +132 -93
- package/esm/components/helpers/selectors.js.map +7 -0
- package/esm/components/helpers/store.js +54 -82
- package/esm/components/helpers/store.js.map +7 -0
- package/esm/components/helpers/types.js +44 -33
- package/esm/components/helpers/types.js.map +7 -0
- package/esm/index.js +7 -4
- package/esm/index.js.map +7 -0
- package/esm/propTypes.js +55 -72
- package/esm/propTypes.js.map +7 -0
- package/package.json +12 -12
|
@@ -1,31 +1,30 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { sqlFormat } from "./sqlFormat";
|
|
3
|
+
import { xmlFormat } from "./xmlFormat";
|
|
4
|
+
import { sqlSafeFormat } from "./sqlSafeFormat";
|
|
5
5
|
class QueryBuilderFormat {
|
|
6
6
|
constructor() {
|
|
7
7
|
this.format = {
|
|
8
|
-
defaultFormat: query => query,
|
|
8
|
+
defaultFormat: (query) => query,
|
|
9
9
|
sqlFormat,
|
|
10
10
|
xmlFormat,
|
|
11
11
|
sqlSafeFormat
|
|
12
12
|
};
|
|
13
|
-
this.currentFormat =
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
this.currentFormat = "sqlFormat";
|
|
14
|
+
this.setDefaultFormat = (formatName) => {
|
|
15
|
+
if (this.format[formatName])
|
|
16
|
+
this.currentFormat = formatName;
|
|
17
17
|
};
|
|
18
|
-
|
|
19
18
|
this.addFormat = (formatName, format) => this.format[formatName] = format;
|
|
20
|
-
|
|
21
19
|
this.run = (query, formatName) => {
|
|
22
|
-
if (this.format[formatName])
|
|
20
|
+
if (this.format[formatName])
|
|
21
|
+
return this.format[formatName](query);
|
|
23
22
|
return this.format[this.currentFormat](query);
|
|
24
23
|
};
|
|
25
24
|
}
|
|
26
|
-
|
|
27
25
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
var format_default = new QueryBuilderFormat();
|
|
27
|
+
export {
|
|
28
|
+
format_default as default
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=format.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/components/format/format.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { sqlFormat } from './sqlFormat';\nimport { xmlFormat } from './xmlFormat';\nimport { sqlSafeFormat } from './sqlSafeFormat';\n\nclass QueryBuilderFormat {\n format = {\n defaultFormat: query => query,\n sqlFormat,\n xmlFormat,\n sqlSafeFormat,\n };\n\n currentFormat = 'sqlFormat';\n\n setDefaultFormat = formatName => {\n if (this.format[formatName]) this.currentFormat = formatName;\n };\n\n addFormat = (formatName, format) => (this.format[formatName] = format);\n\n run = (query, formatName) => {\n if (this.format[formatName]) return this.format[formatName](query);\n return this.format[this.currentFormat](query);\n };\n}\n\nexport default new QueryBuilderFormat();\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AACA;AACA;AAEA,yBAAyB;AAAA,EAAzB,cAJA;AAKE,kBAAS;AAAA,MACP,eAAe,WAAS;AAAA,MACxB;AAAA,MACA;AAAA,MACA;AAAA;AAGF,yBAAgB;AAEhB,4BAAmB,gBAAc;AAC/B,UAAI,KAAK,OAAO;AAAa,aAAK,gBAAgB;AAAA;AAGpD,qBAAY,CAAC,YAAY,WAAY,KAAK,OAAO,cAAc;AAE/D,eAAM,CAAC,OAAO,eAAe;AAC3B,UAAI,KAAK,OAAO;AAAa,eAAO,KAAK,OAAO,YAAY;AAC5D,aAAO,KAAK,OAAO,KAAK,eAAe;AAAA;AAAA;AAAA;AAI3C,IAAO,iBAAQ,IAAI;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { QB_OPERATOR_TYPES } from '../helpers/types.js';
|
|
4
|
-
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { QB_OPERATOR_TYPES } from "../helpers/types";
|
|
5
3
|
const conditionSql = (condition, value) => {
|
|
6
4
|
const {
|
|
7
5
|
EQUAL,
|
|
@@ -15,55 +13,53 @@ const conditionSql = (condition, value) => {
|
|
|
15
13
|
LESS_THAN_OR_EQUAL,
|
|
16
14
|
START_WITH
|
|
17
15
|
} = QB_OPERATOR_TYPES;
|
|
18
|
-
if (condition === EQUAL)
|
|
19
|
-
|
|
20
|
-
if (condition ===
|
|
21
|
-
|
|
22
|
-
if (condition ===
|
|
23
|
-
|
|
24
|
-
if (condition ===
|
|
25
|
-
|
|
26
|
-
if (condition ===
|
|
27
|
-
|
|
16
|
+
if (condition === EQUAL)
|
|
17
|
+
return ` = '${value}'`;
|
|
18
|
+
if (condition === NOT_EQUAL)
|
|
19
|
+
return ` <> '${value}'`;
|
|
20
|
+
if (condition === GREATER_THAN)
|
|
21
|
+
return ` > ${value}`;
|
|
22
|
+
if (condition === LESS_THAN)
|
|
23
|
+
return ` < ${value}`;
|
|
24
|
+
if (condition === CONTAINS)
|
|
25
|
+
return ` LIKE '%${value}%'`;
|
|
26
|
+
if (condition === NOT_CONTAINS)
|
|
27
|
+
return ` NOT LIKE '%${value}%'`;
|
|
28
|
+
if (condition === BETWEEN)
|
|
29
|
+
return ` BETWEEN ${value[0]} AND ${value[1]} `;
|
|
30
|
+
if (condition === GREATER_THAN_OR_EQUAL)
|
|
31
|
+
return ` >= ${value}`;
|
|
32
|
+
if (condition === LESS_THAN_OR_EQUAL)
|
|
33
|
+
return ` <= ${value}`;
|
|
34
|
+
if (condition === START_WITH)
|
|
35
|
+
return ` LIKE '${value}%'`;
|
|
28
36
|
return condition;
|
|
29
37
|
};
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
field,
|
|
34
|
-
operator,
|
|
35
|
-
value
|
|
36
|
-
} = filter.element;
|
|
37
|
-
return "".concat(field, " ").concat(conditionSql(operator, value) || '');
|
|
38
|
+
const renderFilterSQl = (filter) => {
|
|
39
|
+
const { field, operator, value } = filter.element;
|
|
40
|
+
return `${field} ${conditionSql(operator, value) || ""}`;
|
|
38
41
|
};
|
|
39
|
-
|
|
40
|
-
const sqlFormat = _ref => {
|
|
41
|
-
let {
|
|
42
|
-
main,
|
|
43
|
-
mapGroups,
|
|
44
|
-
items
|
|
45
|
-
} = _ref;
|
|
46
|
-
|
|
42
|
+
const sqlFormat = ({ main, mapGroups, items }) => {
|
|
47
43
|
const groupSql = (item, idGroup) => {
|
|
48
44
|
if (idGroup === main) {
|
|
49
|
-
const
|
|
50
|
-
return
|
|
45
|
+
const groupCondition2 = mapGroups[idGroup].condition === true ? "AND" : "OR";
|
|
46
|
+
return ` ( ${filterSql(item, groupCondition2)} ) `;
|
|
51
47
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return " ( ".concat(filterSql(item.children, groupCondition), " ) "); // eslint-disable-line
|
|
48
|
+
const groupCondition = item.element.condition === true ? "AND" : "OR";
|
|
49
|
+
return ` ( ${filterSql(item.children, groupCondition)} ) `;
|
|
55
50
|
};
|
|
56
|
-
|
|
57
51
|
const filterSql = (filters, groupCondition) => {
|
|
58
|
-
const filterGroup = filters.map(filter => {
|
|
59
|
-
if (filter.element.type ===
|
|
60
|
-
|
|
52
|
+
const filterGroup = filters.map((filter) => {
|
|
53
|
+
if (filter.element.type === "filter")
|
|
54
|
+
return ` ${renderFilterSQl(filter)} `;
|
|
55
|
+
return ` ${groupSql(filter) || ""} `;
|
|
61
56
|
});
|
|
62
57
|
return filterGroup.join(groupCondition);
|
|
63
58
|
};
|
|
64
|
-
|
|
65
|
-
const sql = " FROM [TABLE_NAME] WHERE ".concat(groupSql(items, main) || '', " ");
|
|
59
|
+
const sql = ` FROM [TABLE_NAME] WHERE ${groupSql(items, main) || ""} `;
|
|
66
60
|
return sql;
|
|
67
61
|
};
|
|
68
|
-
|
|
69
|
-
|
|
62
|
+
export {
|
|
63
|
+
sqlFormat
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=sqlFormat.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/components/format/sqlFormat.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable complexity */\nimport { QB_OPERATOR_TYPES } from '../helpers/types';\n\nconst conditionSql = (condition, value) => {\n const {\n EQUAL,\n NOT_EQUAL,\n GREATER_THAN,\n LESS_THAN,\n CONTAINS,\n NOT_CONTAINS,\n BETWEEN,\n GREATER_THAN_OR_EQUAL,\n LESS_THAN_OR_EQUAL,\n START_WITH,\n } = QB_OPERATOR_TYPES;\n\n if (condition === EQUAL) return ` = '${value}'`;\n if (condition === NOT_EQUAL) return ` <> '${value}'`;\n if (condition === GREATER_THAN) return ` > ${value}`;\n if (condition === LESS_THAN) return ` < ${value}`;\n if (condition === CONTAINS) return ` LIKE '%${value}%'`;\n if (condition === NOT_CONTAINS) return ` NOT LIKE '%${value}%'`;\n if (condition === BETWEEN) return ` BETWEEN ${value[0]} AND ${value[1]} `;\n if (condition === GREATER_THAN_OR_EQUAL) return ` >= ${value}`;\n if (condition === LESS_THAN_OR_EQUAL) return ` <= ${value}`;\n if (condition === START_WITH) return ` LIKE '${value}%'`;\n return condition;\n};\n\nconst renderFilterSQl = (filter) => {\n const { field, operator, value } = filter.element;\n\n return `${field} ${conditionSql(operator, value) || ''}`;\n};\nexport const sqlFormat = ({ main, mapGroups, items }) => {\n const groupSql = (item, idGroup) => {\n if (idGroup === main) {\n const groupCondition =\n mapGroups[idGroup].condition === true ? 'AND' : 'OR';\n return ` ( ${filterSql(item, groupCondition)} ) `; // eslint-disable-line\n }\n const groupCondition = item.element.condition === true ? 'AND' : 'OR';\n return ` ( ${filterSql(item.children, groupCondition)} ) `; // eslint-disable-line\n };\n\n const filterSql = (filters, groupCondition) => {\n const filterGroup = filters.map((filter) => {\n if (filter.element.type === 'filter')\n return ` ${renderFilterSQl(filter)} `;\n return ` ${groupSql(filter) || ''} `;\n });\n return filterGroup.join(groupCondition);\n };\n\n const sql = ` FROM [TABLE_NAME] WHERE ${groupSql(items, main) || ''} `;\n\n return sql;\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACCA;AAEA,MAAM,eAAe,CAAC,WAAW,UAAU;AACzC,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IAC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,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { QB_OPERATOR_TYPES } from '../helpers/types.js';
|
|
4
|
-
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { QB_OPERATOR_TYPES } from "../helpers/types";
|
|
5
3
|
const specialChar = /[ !@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/;
|
|
6
|
-
|
|
7
4
|
const conditionSql = (condition, value) => {
|
|
8
5
|
const {
|
|
9
6
|
EQUAL,
|
|
@@ -16,61 +13,57 @@ const conditionSql = (condition, value) => {
|
|
|
16
13
|
GREATER_THAN_OR_EQUAL,
|
|
17
14
|
LESS_THAN_OR_EQUAL,
|
|
18
15
|
START_WITH
|
|
19
|
-
} = QB_OPERATOR_TYPES;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (condition === NOT_EQUAL)
|
|
24
|
-
|
|
25
|
-
if (condition ===
|
|
26
|
-
|
|
27
|
-
if (condition ===
|
|
28
|
-
|
|
29
|
-
if (condition ===
|
|
30
|
-
|
|
31
|
-
if (condition ===
|
|
16
|
+
} = QB_OPERATOR_TYPES;
|
|
17
|
+
const valueDisplay = isNaN(value) ? `'${value}'` : value;
|
|
18
|
+
if (condition === EQUAL)
|
|
19
|
+
return ` = ${valueDisplay}`;
|
|
20
|
+
if (condition === NOT_EQUAL)
|
|
21
|
+
return ` <> ${valueDisplay}`;
|
|
22
|
+
if (condition === GREATER_THAN)
|
|
23
|
+
return ` > ${valueDisplay}`;
|
|
24
|
+
if (condition === LESS_THAN)
|
|
25
|
+
return ` < ${valueDisplay}`;
|
|
26
|
+
if (condition === CONTAINS)
|
|
27
|
+
return ` LIKE '%${value}%'`;
|
|
28
|
+
if (condition === NOT_CONTAINS)
|
|
29
|
+
return ` NOT LIKE '%${value}%'`;
|
|
30
|
+
if (condition === BETWEEN)
|
|
31
|
+
return ` BETWEEN ${value[0]} AND ${value[1]} `;
|
|
32
|
+
if (condition === GREATER_THAN_OR_EQUAL)
|
|
33
|
+
return ` >= ${value}`;
|
|
34
|
+
if (condition === LESS_THAN_OR_EQUAL)
|
|
35
|
+
return ` <= ${value}`;
|
|
36
|
+
if (condition === START_WITH)
|
|
37
|
+
return ` LIKE '${value}%'`;
|
|
32
38
|
return condition;
|
|
33
39
|
};
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
const {
|
|
37
|
-
|
|
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) || '');
|
|
40
|
+
const renderFilterSQl = (filter) => {
|
|
41
|
+
const { field, operator, value } = filter.element;
|
|
42
|
+
const fieldDisplay = /[.]/.test(field) || !isNaN(field) ? `\\"${field}\\"` : field;
|
|
43
|
+
return `${fieldDisplay} ${conditionSql(operator, value) || ""}`;
|
|
45
44
|
};
|
|
46
|
-
|
|
47
|
-
const sqlSafeFormat = _ref => {
|
|
48
|
-
let {
|
|
49
|
-
main,
|
|
50
|
-
mapGroups,
|
|
51
|
-
items
|
|
52
|
-
} = _ref;
|
|
53
|
-
|
|
45
|
+
const sqlSafeFormat = ({ main, mapGroups, items }) => {
|
|
54
46
|
const groupSql = (item, idGroup) => {
|
|
55
47
|
if (idGroup === main) {
|
|
56
|
-
const
|
|
57
|
-
return
|
|
48
|
+
const groupCondition2 = mapGroups[idGroup].condition === true ? "AND" : "OR";
|
|
49
|
+
return ` ( ${filterSql(item, groupCondition2)} ) `;
|
|
58
50
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
return " ( ".concat(filterSql(item.children, groupCondition), " ) "); // eslint-disable-line
|
|
51
|
+
const groupCondition = item.element.condition === true ? "AND" : "OR";
|
|
52
|
+
return ` ( ${filterSql(item.children, groupCondition)} ) `;
|
|
62
53
|
};
|
|
63
|
-
|
|
64
54
|
const filterSql = (filters, groupCondition) => {
|
|
65
|
-
const filterGroup = filters.map(filter => {
|
|
66
|
-
if (filter.element.type ===
|
|
67
|
-
|
|
55
|
+
const filterGroup = filters.map((filter) => {
|
|
56
|
+
if (filter.element.type === "filter")
|
|
57
|
+
return ` ${renderFilterSQl(filter)} `;
|
|
58
|
+
return ` ${groupSql(filter) || ""} `;
|
|
68
59
|
});
|
|
69
60
|
return filterGroup.join(groupCondition);
|
|
70
61
|
};
|
|
71
|
-
|
|
72
|
-
const sql = " FROM [TABLE_NAME] WHERE ".concat(groupSql(items, main) || '', " ");
|
|
62
|
+
const sql = ` FROM [TABLE_NAME] WHERE ${groupSql(items, main) || ""} `;
|
|
73
63
|
return sql;
|
|
74
64
|
};
|
|
75
|
-
|
|
76
|
-
|
|
65
|
+
export {
|
|
66
|
+
specialChar,
|
|
67
|
+
sqlSafeFormat
|
|
68
|
+
};
|
|
69
|
+
//# sourceMappingURL=sqlSafeFormat.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/components/format/sqlSafeFormat.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable complexity */\nimport { QB_OPERATOR_TYPES } from '../helpers/types';\n\n// eslint-disable-next-line no-useless-escape\nexport const specialChar = /[ !@#$%^&*()_+\\-=\\[\\]{};':\"\\\\|,.<>\\/?]/;\n\nconst conditionSql = (condition, value) => {\n const {\n EQUAL,\n NOT_EQUAL,\n GREATER_THAN,\n LESS_THAN,\n CONTAINS,\n NOT_CONTAINS,\n BETWEEN,\n GREATER_THAN_OR_EQUAL,\n LESS_THAN_OR_EQUAL,\n START_WITH,\n } = QB_OPERATOR_TYPES;\n // eslint-disable-next-line no-restricted-globals\n const valueDisplay = isNaN(value) ? `'${value}'` : value;\n\n if (condition === EQUAL) return ` = ${valueDisplay}`;\n if (condition === NOT_EQUAL) return ` <> ${valueDisplay}`;\n if (condition === GREATER_THAN) return ` > ${valueDisplay}`;\n if (condition === LESS_THAN) return ` < ${valueDisplay}`;\n if (condition === CONTAINS) return ` LIKE '%${value}%'`;\n if (condition === NOT_CONTAINS) return ` NOT LIKE '%${value}%'`;\n if (condition === BETWEEN) return ` BETWEEN ${value[0]} AND ${value[1]} `;\n if (condition === GREATER_THAN_OR_EQUAL) return ` >= ${value}`;\n if (condition === LESS_THAN_OR_EQUAL) return ` <= ${value}`;\n if (condition === START_WITH) return ` LIKE '${value}%'`;\n return condition;\n};\n\nconst renderFilterSQl = (filter) => {\n const { field, operator, value } = filter.element;\n // eslint-disable-next-line no-restricted-globals\n const fieldDisplay =\n // eslint-disable-next-line no-restricted-globals\n /[.]/.test(field) || !isNaN(field) ? `\\\\\"${field}\\\\\"` : field;\n return `${fieldDisplay} ${conditionSql(operator, value) || ''}`;\n};\nexport const sqlSafeFormat = ({ main, mapGroups, items }) => {\n const groupSql = (item, idGroup) => {\n if (idGroup === main) {\n const groupCondition =\n mapGroups[idGroup].condition === true ? 'AND' : 'OR';\n return ` ( ${filterSql(item, groupCondition)} ) `; // eslint-disable-line\n }\n const groupCondition = item.element.condition === true ? 'AND' : 'OR';\n return ` ( ${filterSql(item.children, groupCondition)} ) `; // eslint-disable-line\n };\n\n const filterSql = (filters, groupCondition) => {\n const filterGroup = filters.map((filter) => {\n if (filter.element.type === 'filter')\n return ` ${renderFilterSQl(filter)} `;\n return ` ${groupSql(filter) || ''} `;\n });\n return filterGroup.join(groupCondition);\n };\n\n const sql = ` FROM [TABLE_NAME] WHERE ${groupSql(items, main) || ''} `;\n\n return sql;\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACCA;AAGO,MAAM,cAAc;AAE3B,MAAM,eAAe,CAAC,WAAW,UAAU;AACzC,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AA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AAAA;AAG1B,QAAM,MAAM,4BAA4B,SAAS,OAAO,SAAS;AAEjE,SAAO;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { QB_OPERATOR_TYPES } from '../helpers/types.js';
|
|
4
|
-
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { QB_OPERATOR_TYPES } from "../helpers/types";
|
|
5
3
|
const conditionSql = (condition, value) => {
|
|
6
4
|
const {
|
|
7
5
|
EQUAL,
|
|
@@ -15,55 +13,53 @@ const conditionSql = (condition, value) => {
|
|
|
15
13
|
LESS_THAN_OR_EQUAL,
|
|
16
14
|
START_WITH
|
|
17
15
|
} = QB_OPERATOR_TYPES;
|
|
18
|
-
if (condition === EQUAL)
|
|
19
|
-
|
|
20
|
-
if (condition ===
|
|
21
|
-
|
|
22
|
-
if (condition ===
|
|
23
|
-
|
|
24
|
-
if (condition ===
|
|
25
|
-
|
|
26
|
-
if (condition ===
|
|
27
|
-
|
|
16
|
+
if (condition === EQUAL)
|
|
17
|
+
return `<condition>EQUAL</condition><value>${value}</value>`;
|
|
18
|
+
if (condition === NOT_EQUAL)
|
|
19
|
+
return `<condition>NOT_EQUAL</condition><value>${value}</value>`;
|
|
20
|
+
if (condition === GREATER_THAN)
|
|
21
|
+
return `<condition>GREATER_THAN</condition><value>${value}</value>`;
|
|
22
|
+
if (condition === LESS_THAN)
|
|
23
|
+
return `<condition>LESS_THAN</condition><value>${value}</value>`;
|
|
24
|
+
if (condition === CONTAINS)
|
|
25
|
+
return `<condition>LIKE</condition><value>${value}</value>`;
|
|
26
|
+
if (condition === NOT_CONTAINS)
|
|
27
|
+
return `<condition>NOT_LIKE</condition><value>${value}</value>`;
|
|
28
|
+
if (condition === BETWEEN)
|
|
29
|
+
return `<condition>NOT_LIKE</condition><value><from>${value[0]}</from><to>${value[1]}</to></value>`;
|
|
30
|
+
if (condition === GREATER_THAN_OR_EQUAL)
|
|
31
|
+
return `<condition>GREATER_THAN_OR_EQUAL</condition><value>${value}</value>`;
|
|
32
|
+
if (condition === LESS_THAN_OR_EQUAL)
|
|
33
|
+
return `<condition>LESS_THAN_OR_EQUAL</condition><value>${value}</value>`;
|
|
34
|
+
if (condition === START_WITH)
|
|
35
|
+
return `<condition>GREATER_THAN</condition><value>${value}</value>`;
|
|
28
36
|
return condition;
|
|
29
37
|
};
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
field,
|
|
34
|
-
operator,
|
|
35
|
-
value
|
|
36
|
-
} = filter.element;
|
|
37
|
-
return "<filter><field>".concat(field, "</field>").concat(conditionSql(operator, value) || '', "</filter>");
|
|
38
|
+
const renderFilterSQl = (filter) => {
|
|
39
|
+
const { field, operator, value } = filter.element;
|
|
40
|
+
return `<filter><field>${field}</field>${conditionSql(operator, value) || ""}</filter>`;
|
|
38
41
|
};
|
|
39
|
-
|
|
40
|
-
const xmlFormat = _ref => {
|
|
41
|
-
let {
|
|
42
|
-
main,
|
|
43
|
-
mapGroups,
|
|
44
|
-
items
|
|
45
|
-
} = _ref;
|
|
46
|
-
|
|
42
|
+
const xmlFormat = ({ main, mapGroups, items }) => {
|
|
47
43
|
const groupXML = (item, idGroup) => {
|
|
48
44
|
if (idGroup === main) {
|
|
49
|
-
const
|
|
50
|
-
return
|
|
45
|
+
const groupCondition2 = mapGroups[idGroup].condition === true ? "AND" : "OR";
|
|
46
|
+
return `<group value="${groupCondition2}">${filterXML(item, groupCondition2)}</group>`;
|
|
51
47
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return "<group value=\"".concat(groupCondition, "\">").concat(filterXML(item.children), "</group>"); // eslint-disable-line
|
|
48
|
+
const groupCondition = item.element.condition === true ? "AND" : "OR";
|
|
49
|
+
return `<group value="${groupCondition}">${filterXML(item.children, groupCondition)}</group>`;
|
|
55
50
|
};
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return
|
|
51
|
+
const filterXML = (filters) => {
|
|
52
|
+
const filterGroup = filters.map((filter) => {
|
|
53
|
+
if (filter.element.type === "filter")
|
|
54
|
+
return `${renderFilterSQl(filter) || ""} `;
|
|
55
|
+
return ` ${groupXML(filter)} `;
|
|
61
56
|
});
|
|
62
|
-
return filterGroup.join(
|
|
57
|
+
return filterGroup.join("");
|
|
63
58
|
};
|
|
64
|
-
|
|
65
|
-
const xml = "<xml><query>".concat(groupXML(items, main) || '', "</query></xml>");
|
|
59
|
+
const xml = `<xml><query>${groupXML(items, main) || ""}</query></xml>`;
|
|
66
60
|
return xml;
|
|
67
61
|
};
|
|
68
|
-
|
|
69
|
-
|
|
62
|
+
export {
|
|
63
|
+
xmlFormat
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=xmlFormat.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/components/format/xmlFormat.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable complexity */\nimport { QB_OPERATOR_TYPES } from '../helpers/types';\n\nconst conditionSql = (condition, value) => {\n const {\n EQUAL,\n NOT_EQUAL,\n GREATER_THAN,\n LESS_THAN,\n CONTAINS,\n NOT_CONTAINS,\n BETWEEN,\n GREATER_THAN_OR_EQUAL,\n LESS_THAN_OR_EQUAL,\n START_WITH,\n } = QB_OPERATOR_TYPES;\n\n if (condition === EQUAL)\n return `<condition>EQUAL</condition><value>${value}</value>`;\n if (condition === NOT_EQUAL)\n return `<condition>NOT_EQUAL</condition><value>${value}</value>`;\n if (condition === GREATER_THAN)\n return `<condition>GREATER_THAN</condition><value>${value}</value>`;\n if (condition === LESS_THAN)\n return `<condition>LESS_THAN</condition><value>${value}</value>`;\n if (condition === CONTAINS)\n return `<condition>LIKE</condition><value>${value}</value>`;\n if (condition === NOT_CONTAINS)\n return `<condition>NOT_LIKE</condition><value>${value}</value>`;\n if (condition === BETWEEN)\n return `<condition>NOT_LIKE</condition><value><from>${value[0]}</from><to>${value[1]}</to></value>`;\n if (condition === GREATER_THAN_OR_EQUAL)\n return `<condition>GREATER_THAN_OR_EQUAL</condition><value>${value}</value>`;\n if (condition === LESS_THAN_OR_EQUAL)\n return `<condition>LESS_THAN_OR_EQUAL</condition><value>${value}</value>`;\n if (condition === START_WITH)\n return `<condition>GREATER_THAN</condition><value>${value}</value>`;\n\n return condition;\n};\n\nconst renderFilterSQl = (filter) => {\n const { field, operator, value } = filter.element;\n\n return `<filter><field>${field}</field>${\n conditionSql(operator, value) || ''\n }</filter>`;\n};\nexport const xmlFormat = ({ main, mapGroups, items }) => {\n const groupXML = (item, idGroup) => {\n if (idGroup === main) {\n const groupCondition =\n mapGroups[idGroup].condition === true ? 'AND' : 'OR';\n return `<group value=\"${groupCondition}\">${filterXML(\n item,\n groupCondition,\n )}</group>`; // eslint-disable-line\n }\n const groupCondition = item.element.condition === true ? 'AND' : 'OR';\n return `<group value=\"${groupCondition}\">${filterXML(\n item.children,\n groupCondition,\n )}</group>`; // eslint-disable-line\n };\n const filterXML = (filters) => {\n const filterGroup = filters.map((filter) => {\n if (filter.element.type === 'filter')\n return `${renderFilterSQl(filter) || ''} `;\n return ` ${groupXML(filter)} `;\n });\n return filterGroup.join('');\n };\n\n const xml = `<xml><query>${groupXML(items, main) || ''}</query></xml>`;\n\n return xml;\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACCA;AAEA,MAAM,eAAe,CAAC,WAAW,UAAU;AACzC,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MACE;AAEJ,MAAI,cAAc;AAChB,WAAO,sCAAsC;AAC/C,MAAI,cAAc;AAChB,WAAO,0CAA0C;AACnD,MAAI,cAAc;AAChB,WAAO,6C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