@evoke-platform/ui-components 1.0.0-dev.255 → 1.0.0-dev.257

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.
@@ -27,6 +27,15 @@ export type CriteriaInputProps = {
27
27
  fetchObject?: (objectId: string) => Promise<EvokeObject | undefined>;
28
28
  object: TreeViewObject;
29
29
  };
30
+ /**
31
+ * String matching operators ('contains', 'beginsWith', 'endsWith') use regex patterns.
32
+ * Special characters like .*+?^${}()|[] are escaped (\\) by default.
33
+ * Set to true to treat these characters as normal text instead.
34
+ * @example
35
+ * // Default: input "hello.*" becomes "hello\.\*" in the query
36
+ * // With disableRegexEscapeChars=true: "hello.*" stays as "hello.*" in the query
37
+ */
38
+ disableRegexEscapeChars?: boolean;
30
39
  };
31
40
  export declare const valueEditor: (props: ValueEditorProps) => JSX.Element;
32
41
  declare const CriteriaBuilder: (props: CriteriaInputProps) => JSX.Element;
@@ -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';
@@ -263,7 +264,7 @@ export const valueEditor = (props) => {
263
264
  return ValueEditor(props);
264
265
  };
265
266
  const CriteriaBuilder = (props) => {
266
- const { properties, criteria, setCriteria, originalCriteria, enablePresetValues, presetValues, operators, dynamicContentInput, disabled, disabledCriteria, hideBorder, presetGroupLabel, treeViewOpts, } = props;
267
+ const { properties, criteria, setCriteria, originalCriteria, enablePresetValues, presetValues, operators, dynamicContentInput, disabled, disabledCriteria, hideBorder, presetGroupLabel, treeViewOpts, disableRegexEscapeChars, } = props;
267
268
  const [query, setQuery] = useState(undefined);
268
269
  const [propertyTreeMap, setPropertyTreeMap] = useState({});
269
270
  useEffect(() => {
@@ -327,7 +328,19 @@ const CriteriaBuilder = (props) => {
327
328
  };
328
329
  const handleQueryChange = (q) => {
329
330
  setQuery(q);
330
- const newCriteria = JSON.parse(formatQuery(q, 'mongodb'));
331
+ const newCriteria = JSON.parse(formatQuery(q, {
332
+ format: 'mongodb',
333
+ ruleProcessor: (rule, options) => {
334
+ let newRule = rule;
335
+ const isPresetValue = typeof rule.value === 'string' && rule.value.startsWith('{{') && rule.value.endsWith('}}');
336
+ if (!disableRegexEscapeChars &&
337
+ ['contains', 'beginsWith', 'endsWith'].includes(rule.operator) &&
338
+ !isPresetValue) {
339
+ newRule = { ...rule, value: escape(rule.value) };
340
+ }
341
+ return defaultRuleProcessorMongoDB(newRule, options);
342
+ },
343
+ }));
331
344
  //when q has no rules, it formats and parses to { $and: [{ $expr: true }] }
332
345
  const allRulesDeleted = isEmpty(difference(newCriteria, { $and: [{ $expr: true }] }));
333
346
  // 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, '$1');
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('reset criteria= ', criteria);
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
  {
@@ -598,7 +599,7 @@ CriteriaBuilderRelatedObject.args = {
598
599
  id: 'status',
599
600
  name: 'Status',
600
601
  type: 'string',
601
- enum: ['RN', 'NP', 'DNP', 'MA'],
602
+ enum: ['RN', 'NP', 'DNP', 'MA', 'RN (LP)'],
602
603
  required: false,
603
604
  },
604
605
  {
@@ -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.255",
3
+ "version": "1.0.0-dev.257",
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}": [