@evoke-platform/ui-components 1.0.0-dev.254 → 1.0.0-dev.256
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.
@@ -3,8 +3,9 @@ import { Typography } from '@mui/material';
|
|
3
3
|
import { QueryBuilderMaterial } from '@react-querybuilder/material';
|
4
4
|
import { isArray, isEmpty, startCase } from 'lodash';
|
5
5
|
import React, { useEffect, useMemo, useState } from 'react';
|
6
|
-
import { QueryBuilder, RuleGroupBodyComponents, RuleGroupHeaderComponents, TestID, formatQuery, useRuleGroup, } from 'react-querybuilder';
|
6
|
+
import { QueryBuilder, RuleGroupBodyComponents, RuleGroupHeaderComponents, TestID, defaultRuleProcessorMongoDB, formatQuery, useRuleGroup, } from 'react-querybuilder';
|
7
7
|
import 'react-querybuilder/dist/query-builder.css';
|
8
|
+
import escape from 'string-escape-regex';
|
8
9
|
import { TrashCan } from '../../../icons/custom';
|
9
10
|
import { Autocomplete, Button, IconButton, TextField } from '../../core';
|
10
11
|
import { Box } from '../../layout';
|
@@ -22,9 +23,6 @@ const ALL_OPERATORS = [
|
|
22
23
|
{ name: 'contains', label: 'Contains' },
|
23
24
|
{ name: 'beginsWith', label: 'Starts with' },
|
24
25
|
{ name: 'endsWith', label: 'Ends with' },
|
25
|
-
{ name: 'doesNotContain', label: 'Does not contain' },
|
26
|
-
{ name: 'doesNotBeginWith', label: 'Does not start with' },
|
27
|
-
{ name: 'doesNotEndWith', label: 'Does not end with' },
|
28
26
|
{ name: 'null', label: 'Is empty' },
|
29
27
|
{ name: 'notNull', label: 'Is not empty' },
|
30
28
|
{ name: 'in', label: 'In' },
|
@@ -330,7 +328,16 @@ const CriteriaBuilder = (props) => {
|
|
330
328
|
};
|
331
329
|
const handleQueryChange = (q) => {
|
332
330
|
setQuery(q);
|
333
|
-
const newCriteria = JSON.parse(formatQuery(q,
|
331
|
+
const newCriteria = JSON.parse(formatQuery(q, {
|
332
|
+
format: 'mongodb',
|
333
|
+
ruleProcessor: (rule, options) => {
|
334
|
+
let newRule = rule;
|
335
|
+
if (['contains', 'beginsWith', 'endsWith'].includes(rule.operator)) {
|
336
|
+
newRule = { ...rule, value: escape(rule.value) };
|
337
|
+
}
|
338
|
+
return defaultRuleProcessorMongoDB(newRule, options);
|
339
|
+
},
|
340
|
+
}));
|
334
341
|
//when q has no rules, it formats and parses to { $and: [{ $expr: true }] }
|
335
342
|
const allRulesDeleted = isEmpty(difference(newCriteria, { $and: [{ $expr: true }] }));
|
336
343
|
// since the Add Condition / Add Group buttons add rules with all the fields empty,
|
@@ -197,6 +197,10 @@ export function parseMongoDB(mongoQuery) {
|
|
197
197
|
operator = 'endsWith';
|
198
198
|
regexValue = regexValue.slice(0, -1);
|
199
199
|
}
|
200
|
+
if (regexValue) {
|
201
|
+
// remove escape characters for display
|
202
|
+
regexValue = regexValue.replace(/\\/g, '');
|
203
|
+
}
|
200
204
|
return {
|
201
205
|
field: key,
|
202
206
|
operator: operator,
|
@@ -8,7 +8,7 @@ const CriteriaBuilderTemplate = (args) => {
|
|
8
8
|
const [criteria, setCriteria] = React.useState(args.criteria);
|
9
9
|
args.setCriteria = setCriteria;
|
10
10
|
args.criteria = criteria;
|
11
|
-
console.log('
|
11
|
+
console.log('criteria= ', JSON.stringify(criteria, null, 4));
|
12
12
|
return React.createElement(BuildCriteria, { ...args });
|
13
13
|
};
|
14
14
|
export const CriteriaBuilderEmpty = CriteriaBuilderTemplate.bind({});
|
@@ -97,7 +97,6 @@ CriteriaBuilderEmpty.args = {
|
|
97
97
|
},
|
98
98
|
],
|
99
99
|
criteria: {},
|
100
|
-
setCriteria: (criteria) => console.log('criteria= ', criteria),
|
101
100
|
};
|
102
101
|
export const CriteriaBuilder = CriteriaBuilderTemplate.bind({});
|
103
102
|
CriteriaBuilder.args = {
|
@@ -190,7 +189,6 @@ CriteriaBuilder.args = {
|
|
190
189
|
required: false,
|
191
190
|
},
|
192
191
|
],
|
193
|
-
setCriteria: (criteria) => console.log('criteria= ', criteria),
|
194
192
|
criteria: {
|
195
193
|
$or: [
|
196
194
|
{
|
@@ -216,6 +214,11 @@ CriteriaBuilder.args = {
|
|
216
214
|
{
|
217
215
|
issueDate: '2023-03-16',
|
218
216
|
},
|
217
|
+
{
|
218
|
+
applicantName: {
|
219
|
+
$regex: '\\(410\\)',
|
220
|
+
},
|
221
|
+
},
|
219
222
|
],
|
220
223
|
},
|
221
224
|
enablePresetValues: false,
|
@@ -311,7 +314,6 @@ CriteriaBuilderPresetUserID.args = {
|
|
311
314
|
required: false,
|
312
315
|
},
|
313
316
|
],
|
314
|
-
setCriteria: (criteria) => console.log('criteria= ', criteria),
|
315
317
|
criteria: {
|
316
318
|
$or: [
|
317
319
|
{
|
@@ -380,7 +382,6 @@ CriteriaBuilderGroupedPresetValues.args = {
|
|
380
382
|
searchable: false,
|
381
383
|
},
|
382
384
|
],
|
383
|
-
setCriteria: (criteria) => console.log('criteria= ', criteria),
|
384
385
|
criteria: {
|
385
386
|
$or: [
|
386
387
|
{
|
@@ -836,7 +837,6 @@ CriteriaBuilderRelatedObject.args = {
|
|
836
837
|
required: false,
|
837
838
|
},
|
838
839
|
],
|
839
|
-
setCriteria: (criteria) => console.log('criteria= ', criteria),
|
840
840
|
criteria: {
|
841
841
|
$and: [
|
842
842
|
{
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@evoke-platform/ui-components",
|
3
|
-
"version": "1.0.0-dev.
|
3
|
+
"version": "1.0.0-dev.256",
|
4
4
|
"description": "",
|
5
5
|
"main": "dist/published/index.js",
|
6
6
|
"module": "dist/published/index.js",
|
@@ -127,7 +127,8 @@
|
|
127
127
|
"react-querybuilder": "^6.0.2",
|
128
128
|
"rtf.js": "^3.0.9",
|
129
129
|
"sift": "^17.1.3",
|
130
|
-
"small-date": "^2.0.0"
|
130
|
+
"small-date": "^2.0.0",
|
131
|
+
"string-escape-regex": "^1.0.1"
|
131
132
|
},
|
132
133
|
"lint-staged": {
|
133
134
|
"*.{js,jsx,ts,tsx,json,css,md}": [
|