@evoke-platform/ui-components 1.4.0-testing.12 → 1.4.0-testing.14
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.
@@ -21,7 +21,7 @@ const DatePicker = (props) => {
|
|
21
21
|
if (newValue instanceof Error) {
|
22
22
|
newValue = new InvalidDate(keyboardInputValue);
|
23
23
|
}
|
24
|
-
handleChange(newValue, keyboardInputValue);
|
24
|
+
handleChange(newValue instanceof InvalidDate || newValue === null ? newValue : LocalDate.from(newValue), keyboardInputValue);
|
25
25
|
};
|
26
26
|
return (React.createElement(UIThemeProvider, null,
|
27
27
|
React.createElement(MUIDatePicker, { value: value, onChange: onChange, renderInput: (params) => React.createElement(TextField, { ...params }), PaperProps: {
|
@@ -2,7 +2,7 @@ import { AddRounded, UnfoldMore } from '@mui/icons-material';
|
|
2
2
|
import { Typography } from '@mui/material';
|
3
3
|
import { QueryBuilderMaterial } from '@react-querybuilder/material';
|
4
4
|
import { isArray, isEmpty, startCase } from 'lodash';
|
5
|
-
import React, { useEffect, useMemo, useState } from 'react';
|
5
|
+
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
6
6
|
import { QueryBuilder, RuleGroupBodyComponents, RuleGroupHeaderComponents, TestID, add, defaultRuleProcessorMongoDB, formatQuery, useRuleGroup, } from 'react-querybuilder';
|
7
7
|
import 'react-querybuilder/dist/query-builder.css';
|
8
8
|
import escape from 'string-escape-regex';
|
@@ -170,7 +170,7 @@ const customSelector = (props) => {
|
|
170
170
|
break;
|
171
171
|
case 'Fields':
|
172
172
|
placeholder = 'Select Property';
|
173
|
-
width = '
|
173
|
+
width = '37%';
|
174
174
|
val = options.find((option) => option.name === val)?.name;
|
175
175
|
break;
|
176
176
|
}
|
@@ -268,21 +268,7 @@ const CriteriaBuilder = (props) => {
|
|
268
268
|
const { properties, criteria, setCriteria, originalCriteria, enablePresetValues, presetValues, operators, disabled, disabledCriteria, hideBorder, presetGroupLabel, customValueEditor, treeViewOpts, disableRegexEscapeChars, } = props;
|
269
269
|
const [query, setQuery] = useState(undefined);
|
270
270
|
const [propertyTreeMap, setPropertyTreeMap] = useState();
|
271
|
-
|
272
|
-
if (criteria || originalCriteria) {
|
273
|
-
const criteriaToParse = criteria || originalCriteria || {};
|
274
|
-
const updatedQuery = parseMongoDB(criteriaToParse);
|
275
|
-
!isEmpty(treeViewOpts) && updatePropertyTreeMap(updatedQuery);
|
276
|
-
setQuery({
|
277
|
-
...updatedQuery,
|
278
|
-
rules: processRules(updatedQuery.rules, true),
|
279
|
-
});
|
280
|
-
}
|
281
|
-
else {
|
282
|
-
setQuery({ combinator: 'and', rules: [] });
|
283
|
-
}
|
284
|
-
}, [originalCriteria]);
|
285
|
-
const processRules = (rules, isSavedValue) => {
|
271
|
+
const processRules = useCallback((rules, isSavedValue) => {
|
286
272
|
return rules.map((rule) => {
|
287
273
|
if ('rules' in rule) {
|
288
274
|
return {
|
@@ -309,10 +295,10 @@ const CriteriaBuilder = (props) => {
|
|
309
295
|
};
|
310
296
|
}
|
311
297
|
});
|
312
|
-
};
|
298
|
+
}, [properties]);
|
313
299
|
// this retrieves the properties from a treeview for each property in the query
|
314
300
|
// they are then used in the custom query builder components to determine the input type etc
|
315
|
-
const updatePropertyTreeMap = (q) => {
|
301
|
+
const updatePropertyTreeMap = useCallback((q) => {
|
316
302
|
const ids = [];
|
317
303
|
const traverseRulesForIds = (rules) => {
|
318
304
|
rules.forEach((rule) => {
|
@@ -334,7 +320,21 @@ const CriteriaBuilder = (props) => {
|
|
334
320
|
}
|
335
321
|
setPropertyTreeMap(tempPropertyMap);
|
336
322
|
});
|
337
|
-
};
|
323
|
+
}, [treeViewOpts, propertyTreeMap]);
|
324
|
+
useEffect(() => {
|
325
|
+
if (criteria || originalCriteria) {
|
326
|
+
const criteriaToParse = criteria || originalCriteria || {};
|
327
|
+
const updatedQuery = parseMongoDB(criteriaToParse);
|
328
|
+
!isEmpty(treeViewOpts) && updatePropertyTreeMap(updatedQuery);
|
329
|
+
setQuery({
|
330
|
+
...updatedQuery,
|
331
|
+
rules: processRules(updatedQuery.rules, true),
|
332
|
+
});
|
333
|
+
}
|
334
|
+
else {
|
335
|
+
setQuery({ combinator: 'and', rules: [] });
|
336
|
+
}
|
337
|
+
}, [criteria, originalCriteria, treeViewOpts, processRules, updatePropertyTreeMap]);
|
338
338
|
const handleClearAll = () => {
|
339
339
|
handleQueryChange({ combinator: 'and', rules: [] });
|
340
340
|
};
|
@@ -509,7 +509,7 @@ const CriteriaBuilder = (props) => {
|
|
509
509
|
justifyContent: 'space-between',
|
510
510
|
alignItems: 'center',
|
511
511
|
marginBottom: '10px',
|
512
|
-
|
512
|
+
width: '100%',
|
513
513
|
} },
|
514
514
|
React.createElement(Box, null,
|
515
515
|
React.createElement(Button, { sx: {
|
@@ -23,7 +23,7 @@ const DisplayedProperty = (props) => {
|
|
23
23
|
return stringAddress;
|
24
24
|
};
|
25
25
|
const formatData = (property, value) => {
|
26
|
-
if (property?.objectId && property?.type === 'object') {
|
26
|
+
if (property?.objectId && (property?.type === 'object' || property?.type === 'collection')) {
|
27
27
|
return value?.name ?? value?.id;
|
28
28
|
}
|
29
29
|
switch (property?.type) {
|