@elliemae/ds-query-builder 3.11.0-rc.4 → 3.11.0-rc.6
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.
|
@@ -44,49 +44,52 @@ const getType = (item) => isGroup(item) ? "group" : "filter";
|
|
|
44
44
|
const adapterV2toV1 = (value) => {
|
|
45
45
|
const main = value[0];
|
|
46
46
|
const parseField = (currenNode, parentIdGroup, mapFilters2, mapGroups2, items2) => {
|
|
47
|
-
currenNode.fields.forEach(
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
currenNode.fields.forEach(
|
|
48
|
+
(element) => {
|
|
49
|
+
const isItGroup = isGroup(element);
|
|
50
|
+
const id = isItGroup ? createGroupId(element) : createFieldId(element);
|
|
51
|
+
const translation = {
|
|
52
|
+
id,
|
|
53
|
+
element: {
|
|
54
|
+
parentIdGroup: isItGroup ? parentIdGroup : void 0,
|
|
55
|
+
idGroup: isItGroup ? id : parentIdGroup,
|
|
56
|
+
idFilter: isItGroup ? void 0 : id,
|
|
57
|
+
field: isItGroup ? void 0 : element.column,
|
|
58
|
+
condition: isItGroup ? translateCondition(element.logical) : "",
|
|
59
|
+
value: isItGroup ? void 0 : element.value,
|
|
60
|
+
type: getType(element),
|
|
61
|
+
operator: isItGroup ? void 0 : element.operator,
|
|
62
|
+
additionalInfo: element.additionalInfo
|
|
63
|
+
},
|
|
64
|
+
children: []
|
|
65
|
+
};
|
|
66
|
+
const mapGroupsTranslation = isItGroup ? {
|
|
67
|
+
condition: translateCondition(element.logical),
|
|
68
|
+
idGroup: id,
|
|
69
|
+
parentIdGroup,
|
|
70
|
+
type: getType(element)
|
|
71
|
+
} : void 0;
|
|
72
|
+
const mapFiltersTranslation = !isItGroup ? {
|
|
53
73
|
parentIdGroup: isItGroup ? parentIdGroup : void 0,
|
|
54
74
|
idGroup: isItGroup ? id : parentIdGroup,
|
|
55
75
|
idFilter: isItGroup ? void 0 : id,
|
|
56
76
|
field: isItGroup ? void 0 : element.column,
|
|
57
|
-
condition: isItGroup ? translateCondition(element.logical) :
|
|
77
|
+
condition: isItGroup ? translateCondition(element.logical) : void 0,
|
|
58
78
|
value: isItGroup ? void 0 : element.value,
|
|
59
79
|
type: getType(element),
|
|
60
|
-
operator: isItGroup ? void 0 : element.operator
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
parentIdGroup: isItGroup ? parentIdGroup : void 0,
|
|
72
|
-
idGroup: isItGroup ? id : parentIdGroup,
|
|
73
|
-
idFilter: isItGroup ? void 0 : id,
|
|
74
|
-
field: isItGroup ? void 0 : element.column,
|
|
75
|
-
condition: isItGroup ? translateCondition(element.logical) : void 0,
|
|
76
|
-
value: isItGroup ? void 0 : element.value,
|
|
77
|
-
type: getType(element),
|
|
78
|
-
operator: isItGroup ? void 0 : element.operator,
|
|
79
|
-
target: "value"
|
|
80
|
-
} : void 0;
|
|
81
|
-
if (isItGroup) {
|
|
82
|
-
mapGroups2[id] = mapGroupsTranslation;
|
|
83
|
-
} else
|
|
84
|
-
mapFilters2[id] = mapFiltersTranslation;
|
|
85
|
-
items2.push(translation);
|
|
86
|
-
if (isItGroup && element.fields.length > 0) {
|
|
87
|
-
parseField(element, id, mapFilters2, mapGroups2, translation.children);
|
|
80
|
+
operator: isItGroup ? void 0 : element.operator,
|
|
81
|
+
target: "value"
|
|
82
|
+
} : void 0;
|
|
83
|
+
if (isItGroup) {
|
|
84
|
+
mapGroups2[id] = mapGroupsTranslation;
|
|
85
|
+
} else
|
|
86
|
+
mapFilters2[id] = mapFiltersTranslation;
|
|
87
|
+
items2.push(translation);
|
|
88
|
+
if (isItGroup && element.fields.length > 0) {
|
|
89
|
+
parseField(element, id, mapFilters2, mapGroups2, translation.children);
|
|
90
|
+
}
|
|
88
91
|
}
|
|
89
|
-
|
|
92
|
+
);
|
|
90
93
|
};
|
|
91
94
|
const mainGroup = createGroupId({});
|
|
92
95
|
const mapFilters = {};
|
|
@@ -120,7 +123,12 @@ const adapterV1toV2 = (data) => {
|
|
|
120
123
|
items.forEach((item) => {
|
|
121
124
|
const { element, children } = item;
|
|
122
125
|
if (element.type === "filter") {
|
|
123
|
-
result2.push({
|
|
126
|
+
result2.push({
|
|
127
|
+
additionalInfo: element.additionalInfo,
|
|
128
|
+
column: element.field,
|
|
129
|
+
operator: element.operator,
|
|
130
|
+
value: element.value
|
|
131
|
+
});
|
|
124
132
|
} else {
|
|
125
133
|
const group = {
|
|
126
134
|
logical: getConditionToLogical(element.condition),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/components/helpers/adapter.ts", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["const translateCondition = (logical: string) => {\n console.log('logical', logical)
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,MAAM,qBAAqB,CAAC,YAAoB;AAC9C,UAAQ,IAAI,WAAW,OAAO;AAC9B,MAAI,YAAY;AAAO,WAAO;AAC9B,MAAI,YAAY;AAAM,WAAO;AAC7B,QAAM,MAAM,
|
|
4
|
+
"sourcesContent": ["const translateCondition = (logical: string) => {\n console.log('logical', logical);\n if (logical === 'and') return true;\n if (logical === 'or') return false;\n throw Error('invalid logical: ' + logical);\n};\nconst isGroup = (item: { logical: string }) => item.logical === 'and' || item.logical === 'or';\nconst createFieldId = (item: any) => `filter_${new Date().getTime()}_${Math.random().toString(36).substring(7)}`;\nconst createGroupId = (item: {}) => `group_${new Date().getTime()}_${Math.random().toString(36).substring(7)}`;\nconst getType = (item: any) => (isGroup(item) ? 'group' : 'filter');\n\nexport const adapterV2toV1 = (value: any[]) => {\n const main = value[0]; // QB1 only support a group as level 0\n const parseField = (\n currenNode: { fields: any[] },\n parentIdGroup: string,\n mapFilters: {\n [x: string]:\n | {\n parentIdGroup: any;\n idGroup: any;\n idFilter: string | undefined;\n field: any;\n condition: boolean | undefined;\n value: any;\n type: string;\n operator: any;\n target: string;\n }\n | undefined;\n },\n mapGroups: {\n [x: string]:\n | { condition: boolean; idGroup: string; parentIdGroup: any; type: string }\n | { parentIdGroup: string; idGroup: string; condition: boolean; type: string }\n | undefined;\n },\n items: {\n id: string;\n element: {\n parentIdGroup: any;\n idGroup: any;\n idFilter: string | undefined;\n field: any;\n condition: string | boolean;\n value: any;\n type: string;\n operator: any;\n };\n children: never[];\n }[],\n ) => {\n currenNode.fields.forEach(\n (element: { column: any; logical: string; value: any; operator: any; fields: string | any[], additionalInfo?: any }) => {\n const isItGroup = isGroup(element);\n const id = isItGroup ? createGroupId(element) : createFieldId(element);\n const translation = {\n id,\n element: {\n parentIdGroup: isItGroup ? parentIdGroup : undefined,\n idGroup: isItGroup ? id : parentIdGroup,\n idFilter: isItGroup ? undefined : id,\n field: isItGroup ? undefined : element.column,\n condition: isItGroup ? translateCondition(element.logical) : '',\n value: isItGroup ? undefined : element.value,\n type: getType(element),\n operator: isItGroup ? undefined : element.operator,\n additionalInfo: element.additionalInfo\n },\n children: [],\n };\n\n const mapGroupsTranslation = isItGroup\n ? {\n condition: translateCondition(element.logical),\n idGroup: id,\n parentIdGroup,\n type: getType(element),\n }\n : undefined;\n const mapFiltersTranslation = !isItGroup\n ? {\n parentIdGroup: isItGroup ? parentIdGroup : undefined,\n idGroup: isItGroup ? id : parentIdGroup,\n idFilter: isItGroup ? undefined : id,\n field: isItGroup ? undefined : element.column,\n condition: isItGroup ? translateCondition(element.logical) : undefined,\n value: isItGroup ? undefined : element.value,\n type: getType(element),\n operator: isItGroup ? undefined : element.operator,\n target: 'value',\n }\n : undefined;\n\n if (isItGroup) {\n mapGroups[id] = mapGroupsTranslation;\n } else mapFilters[id] = mapFiltersTranslation;\n items.push(translation);\n\n if (isItGroup && element.fields.length > 0) {\n parseField(element as any, id, mapFilters, mapGroups, translation.children);\n }\n },\n );\n };\n\n const mainGroup = createGroupId({});\n const mapFilters = {};\n const mapGroups = {\n [mainGroup]: {\n parentIdGroup: 'main',\n idGroup: mainGroup,\n condition: translateCondition(main.logical),\n type: 'group',\n },\n };\n const items: any = [];\n parseField(main, mainGroup, mapFilters, mapGroups, items);\n return {\n step: Math.round(Math.random() * 100) + 1,\n mapFilters,\n mapGroups,\n main: mainGroup,\n items,\n };\n};\n\nconst getConditionToLogical = (condition: any) => (condition ? 'and' : 'or');\n\nexport const adapterV1toV2 = (data: { main: any; mapGroups: { [x: string]: { condition: any } }; items: any }) => {\n const result = [];\n const mainGroup = data.main;\n const init = {\n logical: getConditionToLogical(data.mapGroups[mainGroup].condition),\n fields: [],\n };\n const parseItemsToFields = (\n items: any[],\n result: { column?: any; operator?: any; value?: any; logical?: string; fields?: never[] }[],\n ) => {\n items.forEach((item: { element: any; children: any }) => {\n const { element, children } = item;\n if (element.type === 'filter') {\n result.push({\n additionalInfo: element.additionalInfo,\n column: element.field,\n operator: element.operator,\n value: element.value,\n });\n } else {\n const group = {\n logical: getConditionToLogical(element.condition),\n fields: [],\n };\n parseItemsToFields(children, group.fields);\n result.push(group);\n }\n });\n };\n\n parseItemsToFields(data.items, init.fields);\n result.push(init);\n return result;\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,MAAM,qBAAqB,CAAC,YAAoB;AAC9C,UAAQ,IAAI,WAAW,OAAO;AAC9B,MAAI,YAAY;AAAO,WAAO;AAC9B,MAAI,YAAY;AAAM,WAAO;AAC7B,QAAM,MAAM,sBAAsB,OAAO;AAC3C;AACA,MAAM,UAAU,CAAC,SAA8B,KAAK,YAAY,SAAS,KAAK,YAAY;AAC1F,MAAM,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AAQ,SAAS,UAAU;AAC7B,QAAAA,QAAO,KAAK;AAAA,UACV,gBAAgB,QAAQ;AAAA,UACxB,QAAQ,QAAQ;AAAA,UAChB,UAAU,QAAQ;AAAA,UAClB,OAAO,QAAQ;AAAA,QACjB,CAAC;AAAA,MACH,OAAO;AACL,cAAM,QAAQ;AAAA,UACZ,SAAS,sBAAsB,QAAQ,SAAS;AAAA,UAChD,QAAQ,CAAC;AAAA,QACX;AACA,2BAAmB,UAAU,MAAM,MAAM;AACzC,QAAAA,QAAO,KAAK,KAAK;AAAA,MACnB;AAAA,IACF,CAAC;AAAA,EACH;AAEA,qBAAmB,KAAK,OAAO,KAAK,MAAM;AAC1C,SAAO,KAAK,IAAI;AAChB,SAAO;AACT;",
|
|
6
6
|
"names": ["mapFilters", "mapGroups", "items", "result"]
|
|
7
7
|
}
|
|
@@ -14,49 +14,52 @@ const getType = (item) => isGroup(item) ? "group" : "filter";
|
|
|
14
14
|
const adapterV2toV1 = (value) => {
|
|
15
15
|
const main = value[0];
|
|
16
16
|
const parseField = (currenNode, parentIdGroup, mapFilters2, mapGroups2, items2) => {
|
|
17
|
-
currenNode.fields.forEach(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
currenNode.fields.forEach(
|
|
18
|
+
(element) => {
|
|
19
|
+
const isItGroup = isGroup(element);
|
|
20
|
+
const id = isItGroup ? createGroupId(element) : createFieldId(element);
|
|
21
|
+
const translation = {
|
|
22
|
+
id,
|
|
23
|
+
element: {
|
|
24
|
+
parentIdGroup: isItGroup ? parentIdGroup : void 0,
|
|
25
|
+
idGroup: isItGroup ? id : parentIdGroup,
|
|
26
|
+
idFilter: isItGroup ? void 0 : id,
|
|
27
|
+
field: isItGroup ? void 0 : element.column,
|
|
28
|
+
condition: isItGroup ? translateCondition(element.logical) : "",
|
|
29
|
+
value: isItGroup ? void 0 : element.value,
|
|
30
|
+
type: getType(element),
|
|
31
|
+
operator: isItGroup ? void 0 : element.operator,
|
|
32
|
+
additionalInfo: element.additionalInfo
|
|
33
|
+
},
|
|
34
|
+
children: []
|
|
35
|
+
};
|
|
36
|
+
const mapGroupsTranslation = isItGroup ? {
|
|
37
|
+
condition: translateCondition(element.logical),
|
|
38
|
+
idGroup: id,
|
|
39
|
+
parentIdGroup,
|
|
40
|
+
type: getType(element)
|
|
41
|
+
} : void 0;
|
|
42
|
+
const mapFiltersTranslation = !isItGroup ? {
|
|
23
43
|
parentIdGroup: isItGroup ? parentIdGroup : void 0,
|
|
24
44
|
idGroup: isItGroup ? id : parentIdGroup,
|
|
25
45
|
idFilter: isItGroup ? void 0 : id,
|
|
26
46
|
field: isItGroup ? void 0 : element.column,
|
|
27
|
-
condition: isItGroup ? translateCondition(element.logical) :
|
|
47
|
+
condition: isItGroup ? translateCondition(element.logical) : void 0,
|
|
28
48
|
value: isItGroup ? void 0 : element.value,
|
|
29
49
|
type: getType(element),
|
|
30
|
-
operator: isItGroup ? void 0 : element.operator
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
parentIdGroup: isItGroup ? parentIdGroup : void 0,
|
|
42
|
-
idGroup: isItGroup ? id : parentIdGroup,
|
|
43
|
-
idFilter: isItGroup ? void 0 : id,
|
|
44
|
-
field: isItGroup ? void 0 : element.column,
|
|
45
|
-
condition: isItGroup ? translateCondition(element.logical) : void 0,
|
|
46
|
-
value: isItGroup ? void 0 : element.value,
|
|
47
|
-
type: getType(element),
|
|
48
|
-
operator: isItGroup ? void 0 : element.operator,
|
|
49
|
-
target: "value"
|
|
50
|
-
} : void 0;
|
|
51
|
-
if (isItGroup) {
|
|
52
|
-
mapGroups2[id] = mapGroupsTranslation;
|
|
53
|
-
} else
|
|
54
|
-
mapFilters2[id] = mapFiltersTranslation;
|
|
55
|
-
items2.push(translation);
|
|
56
|
-
if (isItGroup && element.fields.length > 0) {
|
|
57
|
-
parseField(element, id, mapFilters2, mapGroups2, translation.children);
|
|
50
|
+
operator: isItGroup ? void 0 : element.operator,
|
|
51
|
+
target: "value"
|
|
52
|
+
} : void 0;
|
|
53
|
+
if (isItGroup) {
|
|
54
|
+
mapGroups2[id] = mapGroupsTranslation;
|
|
55
|
+
} else
|
|
56
|
+
mapFilters2[id] = mapFiltersTranslation;
|
|
57
|
+
items2.push(translation);
|
|
58
|
+
if (isItGroup && element.fields.length > 0) {
|
|
59
|
+
parseField(element, id, mapFilters2, mapGroups2, translation.children);
|
|
60
|
+
}
|
|
58
61
|
}
|
|
59
|
-
|
|
62
|
+
);
|
|
60
63
|
};
|
|
61
64
|
const mainGroup = createGroupId({});
|
|
62
65
|
const mapFilters = {};
|
|
@@ -90,7 +93,12 @@ const adapterV1toV2 = (data) => {
|
|
|
90
93
|
items.forEach((item) => {
|
|
91
94
|
const { element, children } = item;
|
|
92
95
|
if (element.type === "filter") {
|
|
93
|
-
result2.push({
|
|
96
|
+
result2.push({
|
|
97
|
+
additionalInfo: element.additionalInfo,
|
|
98
|
+
column: element.field,
|
|
99
|
+
operator: element.operator,
|
|
100
|
+
value: element.value
|
|
101
|
+
});
|
|
94
102
|
} else {
|
|
95
103
|
const group = {
|
|
96
104
|
logical: getConditionToLogical(element.condition),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/components/helpers/adapter.ts"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "const translateCondition = (logical: string) => {\n console.log('logical', logical)
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACAvB,MAAM,qBAAqB,CAAC,YAAoB;AAC9C,UAAQ,IAAI,WAAW,OAAO;AAC9B,MAAI,YAAY;AAAO,WAAO;AAC9B,MAAI,YAAY;AAAM,WAAO;AAC7B,QAAM,MAAM,
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "const translateCondition = (logical: string) => {\n console.log('logical', logical);\n if (logical === 'and') return true;\n if (logical === 'or') return false;\n throw Error('invalid logical: ' + logical);\n};\nconst isGroup = (item: { logical: string }) => item.logical === 'and' || item.logical === 'or';\nconst createFieldId = (item: any) => `filter_${new Date().getTime()}_${Math.random().toString(36).substring(7)}`;\nconst createGroupId = (item: {}) => `group_${new Date().getTime()}_${Math.random().toString(36).substring(7)}`;\nconst getType = (item: any) => (isGroup(item) ? 'group' : 'filter');\n\nexport const adapterV2toV1 = (value: any[]) => {\n const main = value[0]; // QB1 only support a group as level 0\n const parseField = (\n currenNode: { fields: any[] },\n parentIdGroup: string,\n mapFilters: {\n [x: string]:\n | {\n parentIdGroup: any;\n idGroup: any;\n idFilter: string | undefined;\n field: any;\n condition: boolean | undefined;\n value: any;\n type: string;\n operator: any;\n target: string;\n }\n | undefined;\n },\n mapGroups: {\n [x: string]:\n | { condition: boolean; idGroup: string; parentIdGroup: any; type: string }\n | { parentIdGroup: string; idGroup: string; condition: boolean; type: string }\n | undefined;\n },\n items: {\n id: string;\n element: {\n parentIdGroup: any;\n idGroup: any;\n idFilter: string | undefined;\n field: any;\n condition: string | boolean;\n value: any;\n type: string;\n operator: any;\n };\n children: never[];\n }[],\n ) => {\n currenNode.fields.forEach(\n (element: { column: any; logical: string; value: any; operator: any; fields: string | any[], additionalInfo?: any }) => {\n const isItGroup = isGroup(element);\n const id = isItGroup ? createGroupId(element) : createFieldId(element);\n const translation = {\n id,\n element: {\n parentIdGroup: isItGroup ? parentIdGroup : undefined,\n idGroup: isItGroup ? id : parentIdGroup,\n idFilter: isItGroup ? undefined : id,\n field: isItGroup ? undefined : element.column,\n condition: isItGroup ? translateCondition(element.logical) : '',\n value: isItGroup ? undefined : element.value,\n type: getType(element),\n operator: isItGroup ? undefined : element.operator,\n additionalInfo: element.additionalInfo\n },\n children: [],\n };\n\n const mapGroupsTranslation = isItGroup\n ? {\n condition: translateCondition(element.logical),\n idGroup: id,\n parentIdGroup,\n type: getType(element),\n }\n : undefined;\n const mapFiltersTranslation = !isItGroup\n ? {\n parentIdGroup: isItGroup ? parentIdGroup : undefined,\n idGroup: isItGroup ? id : parentIdGroup,\n idFilter: isItGroup ? undefined : id,\n field: isItGroup ? undefined : element.column,\n condition: isItGroup ? translateCondition(element.logical) : undefined,\n value: isItGroup ? undefined : element.value,\n type: getType(element),\n operator: isItGroup ? undefined : element.operator,\n target: 'value',\n }\n : undefined;\n\n if (isItGroup) {\n mapGroups[id] = mapGroupsTranslation;\n } else mapFilters[id] = mapFiltersTranslation;\n items.push(translation);\n\n if (isItGroup && element.fields.length > 0) {\n parseField(element as any, id, mapFilters, mapGroups, translation.children);\n }\n },\n );\n };\n\n const mainGroup = createGroupId({});\n const mapFilters = {};\n const mapGroups = {\n [mainGroup]: {\n parentIdGroup: 'main',\n idGroup: mainGroup,\n condition: translateCondition(main.logical),\n type: 'group',\n },\n };\n const items: any = [];\n parseField(main, mainGroup, mapFilters, mapGroups, items);\n return {\n step: Math.round(Math.random() * 100) + 1,\n mapFilters,\n mapGroups,\n main: mainGroup,\n items,\n };\n};\n\nconst getConditionToLogical = (condition: any) => (condition ? 'and' : 'or');\n\nexport const adapterV1toV2 = (data: { main: any; mapGroups: { [x: string]: { condition: any } }; items: any }) => {\n const result = [];\n const mainGroup = data.main;\n const init = {\n logical: getConditionToLogical(data.mapGroups[mainGroup].condition),\n fields: [],\n };\n const parseItemsToFields = (\n items: any[],\n result: { column?: any; operator?: any; value?: any; logical?: string; fields?: never[] }[],\n ) => {\n items.forEach((item: { element: any; children: any }) => {\n const { element, children } = item;\n if (element.type === 'filter') {\n result.push({\n additionalInfo: element.additionalInfo,\n column: element.field,\n operator: element.operator,\n value: element.value,\n });\n } else {\n const group = {\n logical: getConditionToLogical(element.condition),\n fields: [],\n };\n parseItemsToFields(children, group.fields);\n result.push(group);\n }\n });\n };\n\n parseItemsToFields(data.items, init.fields);\n result.push(init);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MAAM,gBAAgB,CAAC,SAAoF;AAChH,QAAM,SAAS,CAAC;AAChB,QAAM,YAAY,KAAK;AACvB,QAAM,OAAO;AAAA,IACX,SAAS,sBAAsB,KAAK,UAAU,WAAW,SAAS;AAAA,IAClE,QAAQ,CAAC;AAAA,EACX;AACA,QAAM,qBAAqB,CACzB,OACAE,YACG;AACH,UAAM,QAAQ,CAAC,SAA0C;AACvD,YAAM,EAAE,SAAS,SAAS,IAAI;AAC9B,UAAI,QAAQ,SAAS,UAAU;AAC7B,QAAAA,QAAO,KAAK;AAAA,UACV,gBAAgB,QAAQ;AAAA,UACxB,QAAQ,QAAQ;AAAA,UAChB,UAAU,QAAQ;AAAA,UAClB,OAAO,QAAQ;AAAA,QACjB,CAAC;AAAA,MACH,OAAO;AACL,cAAM,QAAQ;AAAA,UACZ,SAAS,sBAAsB,QAAQ,SAAS;AAAA,UAChD,QAAQ,CAAC;AAAA,QACX;AACA,2BAAmB,UAAU,MAAM,MAAM;AACzC,QAAAA,QAAO,KAAK,KAAK;AAAA,MACnB;AAAA,IACF,CAAC;AAAA,EACH;AAEA,qBAAmB,KAAK,OAAO,KAAK,MAAM;AAC1C,SAAO,KAAK,IAAI;AAChB,SAAO;AACT;",
|
|
6
6
|
"names": ["mapFilters", "mapGroups", "items", "result"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-query-builder",
|
|
3
|
-
"version": "3.11.0-rc.
|
|
3
|
+
"version": "3.11.0-rc.6",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Query Builder",
|
|
6
6
|
"files": [
|
|
@@ -171,17 +171,17 @@
|
|
|
171
171
|
"indent": 4
|
|
172
172
|
},
|
|
173
173
|
"dependencies": {
|
|
174
|
-
"@elliemae/ds-accordion": "3.11.0-rc.
|
|
175
|
-
"@elliemae/ds-button": "3.11.0-rc.
|
|
176
|
-
"@elliemae/ds-classnames": "3.11.0-rc.
|
|
177
|
-
"@elliemae/ds-form": "3.11.0-rc.
|
|
178
|
-
"@elliemae/ds-grid": "3.11.0-rc.
|
|
179
|
-
"@elliemae/ds-icon": "3.11.0-rc.
|
|
180
|
-
"@elliemae/ds-icons": "3.11.0-rc.
|
|
181
|
-
"@elliemae/ds-popper": "3.11.0-rc.
|
|
182
|
-
"@elliemae/ds-shared": "3.11.0-rc.
|
|
183
|
-
"@elliemae/ds-tooltip": "3.11.0-rc.
|
|
184
|
-
"@elliemae/ds-utilities": "3.11.0-rc.
|
|
174
|
+
"@elliemae/ds-accordion": "3.11.0-rc.6",
|
|
175
|
+
"@elliemae/ds-button": "3.11.0-rc.6",
|
|
176
|
+
"@elliemae/ds-classnames": "3.11.0-rc.6",
|
|
177
|
+
"@elliemae/ds-form": "3.11.0-rc.6",
|
|
178
|
+
"@elliemae/ds-grid": "3.11.0-rc.6",
|
|
179
|
+
"@elliemae/ds-icon": "3.11.0-rc.6",
|
|
180
|
+
"@elliemae/ds-icons": "3.11.0-rc.6",
|
|
181
|
+
"@elliemae/ds-popper": "3.11.0-rc.6",
|
|
182
|
+
"@elliemae/ds-shared": "3.11.0-rc.6",
|
|
183
|
+
"@elliemae/ds-tooltip": "3.11.0-rc.6",
|
|
184
|
+
"@elliemae/ds-utilities": "3.11.0-rc.6",
|
|
185
185
|
"classnames": "~2.3.1",
|
|
186
186
|
"prop-types": "~15.8.1",
|
|
187
187
|
"react-addons-update": "~15.6.3"
|