@evoke-platform/ui-components 1.0.1 → 1.0.2-dev.0
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/dist/published/components/custom/CriteriaBuilder/CriteriaBuilder.js +15 -5
- package/dist/published/components/custom/CriteriaBuilder/PropertyTree.js +0 -2
- package/dist/published/components/custom/CriteriaBuilder/ValueEditor.js +12 -3
- package/dist/published/components/custom/Form/Common/Form.js +5 -3
- package/dist/published/components/custom/Form/FormComponents/FormFieldComponent.js +3 -3
- package/dist/published/components/custom/Form/FormComponents/ObjectComponent/ObjectPropertyInput.js +2 -2
- package/dist/published/components/custom/Form/FormComponents/RepeatableFieldComponent/ManyToMany/DropdownRepeatableFieldInput.js +2 -2
- package/package.json +2 -2
@@ -108,7 +108,7 @@ const customSelector = (props) => {
|
|
108
108
|
let opts = options;
|
109
109
|
let inputType = props.fieldData?.inputType;
|
110
110
|
// for tree view / related object properties, the properties are stored in the propertyTreeMap upon selection
|
111
|
-
if (!!context.treeViewOpts && !!context.propertyTreeMap[rule.field]) {
|
111
|
+
if (!!context.treeViewOpts && !!context.propertyTreeMap?.[rule.field]) {
|
112
112
|
inputType = context.propertyTreeMap[rule.field].type;
|
113
113
|
}
|
114
114
|
let readOnly = false;
|
@@ -274,7 +274,7 @@ export const valueEditor = (props) => {
|
|
274
274
|
const CriteriaBuilder = (props) => {
|
275
275
|
const { properties, criteria, setCriteria, originalCriteria, enablePresetValues, presetValues, operators, dynamicContentInput, disabled, disabledCriteria, hideBorder, presetGroupLabel, treeViewOpts, disableRegexEscapeChars, } = props;
|
276
276
|
const [query, setQuery] = useState(undefined);
|
277
|
-
const [propertyTreeMap, setPropertyTreeMap] = useState(
|
277
|
+
const [propertyTreeMap, setPropertyTreeMap] = useState();
|
278
278
|
useEffect(() => {
|
279
279
|
if (criteria || originalCriteria) {
|
280
280
|
const criteriaToParse = criteria || originalCriteria || {};
|
@@ -326,7 +326,7 @@ const CriteriaBuilder = (props) => {
|
|
326
326
|
traverseRulesForIds(q.rules);
|
327
327
|
const tempPropertyMap = { ...propertyTreeMap };
|
328
328
|
ids.forEach(async (id) => {
|
329
|
-
if (!propertyTreeMap[id] && treeViewOpts?.object && treeViewOpts?.fetchObject) {
|
329
|
+
if (!propertyTreeMap?.[id] && treeViewOpts?.object && treeViewOpts?.fetchObject) {
|
330
330
|
const prop = await traversePropertyPath(id, treeViewOpts?.object, treeViewOpts?.fetchObject);
|
331
331
|
if (prop)
|
332
332
|
tempPropertyMap[id] = prop;
|
@@ -365,7 +365,9 @@ const CriteriaBuilder = (props) => {
|
|
365
365
|
}
|
366
366
|
};
|
367
367
|
const fields = useMemo(() => {
|
368
|
-
return properties
|
368
|
+
return properties
|
369
|
+
.filter(({ type }) => type !== 'collection')
|
370
|
+
.map((property) => {
|
369
371
|
return {
|
370
372
|
name: property.type === 'object' ? `${property.id}.id` : property.id,
|
371
373
|
label: property.name,
|
@@ -466,7 +468,15 @@ const CriteriaBuilder = (props) => {
|
|
466
468
|
enablePresetValues,
|
467
469
|
presetGroupLabel,
|
468
470
|
disabledCriteria,
|
469
|
-
treeViewOpts
|
471
|
+
treeViewOpts: treeViewOpts
|
472
|
+
? {
|
473
|
+
...treeViewOpts,
|
474
|
+
object: {
|
475
|
+
...treeViewOpts?.object,
|
476
|
+
properties: treeViewOpts?.object.properties.filter(({ type }) => type !== 'collection'),
|
477
|
+
},
|
478
|
+
}
|
479
|
+
: undefined,
|
470
480
|
propertyTreeMap,
|
471
481
|
setPropertyTreeMap,
|
472
482
|
}, controlClassnames: {
|
@@ -49,8 +49,6 @@ const PropertyTree = ({ fetchObject, handleTreePropertySelect, rootObject, value
|
|
49
49
|
if (originalValue.includes('.')) {
|
50
50
|
const parts = originalValue.split('.');
|
51
51
|
if (parts.length >= 2) {
|
52
|
-
const parentId = parts.slice(0, -1).join('.');
|
53
|
-
await fetchObject(parentId);
|
54
52
|
if (!newObjectPropertyNamePathMap[originalValue]) {
|
55
53
|
const fieldNamePath = await fetchDisplayNamePath(originalValue, rootObject, fetchObject);
|
56
54
|
newObjectPropertyNamePathMap = {
|
@@ -17,10 +17,10 @@ const GroupHeader = styled('div')(({ theme }) => ({
|
|
17
17
|
}));
|
18
18
|
const GroupItems = styled('ul')({ padding: 0 });
|
19
19
|
const ValueEditor = (props) => {
|
20
|
-
const { handleOnChange, value, operator, context, level, rule } = props;
|
20
|
+
const { handleOnChange, value, operator, context, level, rule, fieldData } = props;
|
21
21
|
let inputType = props.inputType;
|
22
22
|
let values = props.values;
|
23
|
-
const property = context.propertyTreeMap[rule.field];
|
23
|
+
const property = context.propertyTreeMap?.[rule.field];
|
24
24
|
// for tree view / related object properties, the properties are stored in the propertyTreeMap upon selection
|
25
25
|
if (!!context.treeViewOpts && !!property) {
|
26
26
|
inputType = property.type;
|
@@ -111,12 +111,21 @@ const ValueEditor = (props) => {
|
|
111
111
|
}
|
112
112
|
else {
|
113
113
|
const isMultiple = inputType === 'array' || ['in', 'notIn'].includes(operator);
|
114
|
+
const isSelectType = fieldData.valueEditorType === 'select';
|
114
115
|
const options = [
|
115
116
|
...(values?.sort((a, b) => a.label.localeCompare(b.label)) ?? []),
|
116
117
|
...(presetValues?.sort((a, b) => a.label.localeCompare(b.label)) ?? []),
|
117
118
|
];
|
118
119
|
if (isMultiple || values?.length) {
|
119
|
-
return (React.createElement(Autocomplete, { freeSolo: inputType !== 'array' &&
|
120
|
+
return (React.createElement(Autocomplete, { freeSolo: inputType !== 'array' && !isSelectType, multiple: isMultiple, options: options, value: isMultiple
|
121
|
+
? Array.isArray(value)
|
122
|
+
? value
|
123
|
+
: isSelectType && value && typeof value === 'string'
|
124
|
+
? [value]
|
125
|
+
: []
|
126
|
+
: Array.isArray(value)
|
127
|
+
? value.join(',')
|
128
|
+
: value,
|
120
129
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
121
130
|
onChange: (event, newValue) => {
|
122
131
|
let value;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { useApp, useAuthenticationContext, } from '@evoke-platform/context';
|
2
2
|
import { Components, Form as FormIO, Utils } from '@formio/react';
|
3
3
|
import { flatten } from 'flat';
|
4
|
-
import { isEqual, toPairs } from 'lodash';
|
4
|
+
import { isEmpty, isEqual, toPairs } from 'lodash';
|
5
5
|
import React, { useEffect, useRef, useState } from 'react';
|
6
6
|
import '../../../../styles/form-component.css';
|
7
7
|
import { Skeleton, Snackbar } from '../../../core';
|
@@ -320,7 +320,9 @@ export function Form(props) {
|
|
320
320
|
const submittedFields = {};
|
321
321
|
for (const field in submission.data) {
|
322
322
|
const value = submission.data[field];
|
323
|
-
if (value === '' ||
|
323
|
+
if (value === '' ||
|
324
|
+
(Array.isArray(value) && !value.length) ||
|
325
|
+
(typeof value === 'object' && isEmpty(value))) {
|
324
326
|
submittedFields[field] = null;
|
325
327
|
}
|
326
328
|
else {
|
@@ -424,7 +426,7 @@ export function Form(props) {
|
|
424
426
|
},
|
425
427
|
],
|
426
428
|
};
|
427
|
-
return (React.createElement(Box,
|
429
|
+
return (React.createElement(Box, null,
|
428
430
|
componentProps.length ? (React.createElement(FormIO, { key: closeModal ? undefined : formKey, form: {
|
429
431
|
display: 'form',
|
430
432
|
components: componentProps,
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { ReactComponent } from '@formio/react';
|
2
|
-
import Handlebars from 'handlebars';
|
3
2
|
import { isArray, isEmpty, isNil, uniq } from 'lodash';
|
4
3
|
import { DateTime } from 'luxon';
|
4
|
+
import Handlebars from 'no-eval-handlebars';
|
5
5
|
import React from 'react';
|
6
6
|
import ReactDOM from 'react-dom';
|
7
7
|
import { FormField } from '../../../custom';
|
@@ -354,7 +354,7 @@ export class FormFieldComponent extends ReactComponent {
|
|
354
354
|
let { minDate, maxDate } = validate;
|
355
355
|
if (minDate && !dateRegex.test(minDate)) {
|
356
356
|
try {
|
357
|
-
minDate = Handlebars.
|
357
|
+
minDate = Handlebars.compileAST(minDate)(data);
|
358
358
|
}
|
359
359
|
catch (err) {
|
360
360
|
console.log(err);
|
@@ -362,7 +362,7 @@ export class FormFieldComponent extends ReactComponent {
|
|
362
362
|
}
|
363
363
|
if (maxDate && !dateRegex.test(maxDate)) {
|
364
364
|
try {
|
365
|
-
maxDate = Handlebars.
|
365
|
+
maxDate = Handlebars.compileAST(maxDate)(data);
|
366
366
|
}
|
367
367
|
catch (err) {
|
368
368
|
console.log(err);
|
package/dist/published/components/custom/Form/FormComponents/ObjectComponent/ObjectPropertyInput.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import cleanDeep from 'clean-deep';
|
2
|
-
import Handlebars from 'handlebars';
|
3
2
|
import { cloneDeep, debounce, isEmpty, isNil } from 'lodash';
|
3
|
+
import Handlebars from 'no-eval-handlebars';
|
4
4
|
import React, { useCallback, useEffect, useState } from 'react';
|
5
5
|
import { Close } from '../../../../../icons';
|
6
6
|
import { Autocomplete, Button, Dialog, IconButton, Link, Paper, TextField, Tooltip, Typography, } from '../../../../core';
|
@@ -132,7 +132,7 @@ export const ObjectPropertyInput = (props) => {
|
|
132
132
|
setOpenCreateDialog(false);
|
133
133
|
};
|
134
134
|
const compileExpression = (expression, instance) => {
|
135
|
-
const template = Handlebars.
|
135
|
+
const template = Handlebars.compileAST(expression);
|
136
136
|
return instance ? template(instance) : undefined;
|
137
137
|
};
|
138
138
|
const navigationSlug = defaultPages && property.objectId && defaultPages[property.objectId];
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import Handlebars from 'handlebars';
|
2
1
|
import { difference, isEmpty, isObject } from 'lodash';
|
2
|
+
import Handlebars from 'no-eval-handlebars';
|
3
3
|
import React, { useEffect, useState } from 'react';
|
4
4
|
import { FormField } from '../../../..';
|
5
5
|
import { Snackbar, TextField, Typography } from '../../../../../core';
|
@@ -60,7 +60,7 @@ export const DropdownRepeatableFieldInput = (props) => {
|
|
60
60
|
}
|
61
61
|
};
|
62
62
|
const compileExpression = (instance, expression) => {
|
63
|
-
const template = Handlebars.
|
63
|
+
const template = Handlebars.compileAST(expression);
|
64
64
|
return template(instance);
|
65
65
|
};
|
66
66
|
return (React.createElement(React.Fragment, null, !readOnly ? (property && (React.createElement(React.Fragment, null,
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@evoke-platform/ui-components",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.2-dev.0",
|
4
4
|
"description": "",
|
5
5
|
"main": "dist/published/index.js",
|
6
6
|
"module": "dist/published/index.js",
|
@@ -114,11 +114,11 @@
|
|
114
114
|
"eslint-plugin-no-inline-styles": "^1.0.5",
|
115
115
|
"flat": "^6.0.1",
|
116
116
|
"formiojs": "^4.15.0-rc.23",
|
117
|
-
"handlebars": "^4.7.8",
|
118
117
|
"html-react-parser": "^5.1.18",
|
119
118
|
"luxon": "^2.5.2",
|
120
119
|
"nanoid": "^5.0.8",
|
121
120
|
"nanoid-dictionary": "^4.3.0",
|
121
|
+
"no-eval-handlebars": "^1.0.2",
|
122
122
|
"pluralize": "^8.0.0",
|
123
123
|
"pretty-bytes": "^6.1.1",
|
124
124
|
"react-dropzone": "^14.2.2",
|