@evoke-platform/ui-components 1.0.0-dev.226 → 1.0.0-dev.227
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/core/Accordion/Accordion.js +1 -1
- package/dist/published/components/core/Accordion/AccordionActions/AccordionActions.js +1 -1
- package/dist/published/components/core/Accordion/AccordionDetails/AccordionDetails.js +1 -1
- package/dist/published/components/core/Accordion/AccordionSummary/AccordionSummary.js +1 -1
- package/dist/published/components/core/Alert/Alert.js +8 -9
- package/dist/published/components/core/AlertTitle/AlertTitle.js +1 -1
- package/dist/published/components/core/AppBar/AppBar.js +1 -1
- package/dist/published/components/core/Autocomplete/Autocomplete.js +33 -15
- package/dist/published/components/core/Autocomplete/Autocomplete.test.js +1 -1
- package/dist/published/components/core/Avatar/Avatar.js +7 -4
- package/dist/published/components/core/Backdrop/Backdrop.js +1 -1
- package/dist/published/components/core/Badge/Badge.js +1 -1
- package/dist/published/components/core/Breadcrumbs/Breadcrumbs.js +1 -1
- package/dist/published/components/core/Button/Button.js +1 -1
- package/dist/published/components/core/ButtonGroup/ButtonGroup.js +1 -1
- package/dist/published/components/core/Card/Card.js +1 -1
- package/dist/published/components/core/Checkbox/Checkbox.js +1 -1
- package/dist/published/components/core/Chip/Chip.js +1 -1
- package/dist/published/components/core/CircularProgress/CircularProgress.js +1 -1
- package/dist/published/components/core/Collapse/Collapse.js +1 -1
- package/dist/published/components/core/DatePicker/DatePicker.js +4 -16
- package/dist/published/components/core/DateTimePicker/DateTimePicker.js +3 -15
- package/dist/published/components/core/Dialog/Dialog.js +1 -1
- package/dist/published/components/core/Dialog/DialogActions/DialogActions.js +2 -13
- package/dist/published/components/core/Dialog/DialogContent/DialogContent.js +1 -1
- package/dist/published/components/core/Dialog/DialogContentText/DialogContentText.js +1 -1
- package/dist/published/components/core/Dialog/DialogTitle/DialogTitle.js +1 -1
- package/dist/published/components/core/Divider/Divider.js +1 -1
- package/dist/published/components/core/Drawer/Drawer.js +1 -1
- package/dist/published/components/core/FieldError/FieldError.js +1 -2
- package/dist/published/components/core/FormElements/FormControl/FormControl.js +1 -1
- package/dist/published/components/core/FormElements/FormControlLabel/FormControlLabel.js +1 -1
- package/dist/published/components/core/FormElements/FormGroup/FormGroup.js +1 -1
- package/dist/published/components/core/FormElements/FormHelperText/FormHelperText.js +1 -1
- package/dist/published/components/core/FormElements/FormLabel/FormLabel.js +1 -1
- package/dist/published/components/core/IconButton/IconButton.js +1 -1
- package/dist/published/components/core/LinearProgress/LinearProgress.js +1 -1
- package/dist/published/components/core/Link/Link.js +1 -1
- package/dist/published/components/core/List/List.js +1 -1
- package/dist/published/components/core/List/ListItem.js +1 -1
- package/dist/published/components/core/List/ListItemText/ListItemText.js +1 -1
- package/dist/published/components/core/LoadingButton/LoadingButton.js +1 -1
- package/dist/published/components/core/LocalizationProvider/LocalizationProvider.js +3 -14
- package/dist/published/components/core/Menu/Menu.js +1 -1
- package/dist/published/components/core/Menu/MenuItem/MenuItem.js +1 -1
- package/dist/published/components/core/Paper/Paper.js +1 -1
- package/dist/published/components/core/Popover/Popover.js +1 -1
- package/dist/published/components/core/Popper/Popper.js +1 -1
- package/dist/published/components/core/RadioGroup/Radio.js +1 -1
- package/dist/published/components/core/RadioGroup/RadioGroup.js +1 -1
- package/dist/published/components/core/Select/Select.js +11 -4
- package/dist/published/components/core/Skeleton/Skeleton.js +1 -1
- package/dist/published/components/core/Snackbar/Snackbar.js +2 -2
- package/dist/published/components/core/StaticDatePicker/StaticDatePicker.js +3 -15
- package/dist/published/components/core/Stepper/Step/Step.js +1 -1
- package/dist/published/components/core/Stepper/StepButton/StepButton.js +1 -1
- package/dist/published/components/core/Stepper/StepConnector/StepConnector.js +1 -1
- package/dist/published/components/core/Stepper/StepContent/StepContent.js +1 -1
- package/dist/published/components/core/Stepper/StepIcon/StepIcon.js +1 -1
- package/dist/published/components/core/Stepper/StepLabel/StepLabel.js +1 -1
- package/dist/published/components/core/Stepper/Stepper.js +1 -1
- package/dist/published/components/core/Switch/Switch.js +1 -1
- package/dist/published/components/core/Table/Table.js +1 -1
- package/dist/published/components/core/Tabs/Tab/Tab.js +1 -1
- package/dist/published/components/core/Tabs/Tabs.js +1 -1
- package/dist/published/components/core/TextField/TextField.js +12 -6
- package/dist/published/components/core/ToggleButton/ToggleButton.js +1 -1
- package/dist/published/components/core/ToggleButtonGroup/ToggleButtonGroup.js +1 -1
- package/dist/published/components/core/Tooltip/Tooltip.js +15 -2
- package/dist/published/components/core/Typography/index.js +1 -1
- package/dist/published/components/custom/BuilderGrid/BuilderGrid.js +33 -29
- package/dist/published/components/custom/BuilderGrid/BuilderGridToolbar.js +1 -2
- package/dist/published/components/custom/BuilderGrid/EmptyContent.js +4 -5
- package/dist/published/components/custom/BuilderGrid/EmptyContentIllustration.js +6 -1
- package/dist/published/components/custom/BuilderGrid/ToolbarActions.js +3 -1
- package/dist/published/components/custom/CriteriaBuilder/CriteriaBuilder.js +46 -27
- package/dist/published/components/custom/CriteriaBuilder/CriteriaBuilder.test.js +12 -21
- package/dist/published/components/custom/CriteriaBuilder/ValueEditor.js +27 -34
- package/dist/published/components/custom/DataGrid/DataGrid.js +38 -33
- package/dist/published/components/custom/DataGrid/DateTimeCustomOperator.js +3 -5
- package/dist/published/components/custom/DataGrid/Toolbar.js +3 -4
- package/dist/published/components/custom/ErrorComponent/ErrorComponent.js +11 -1
- package/dist/published/components/custom/Form/Common/Form.js +106 -80
- package/dist/published/components/custom/Form/Common/FormComponentWrapper.js +20 -11
- package/dist/published/components/custom/Form/FormComponents/ButtonComponent.js +9 -20
- package/dist/published/components/custom/Form/FormComponents/DocumentComponent/Document.js +10 -20
- package/dist/published/components/custom/Form/FormComponents/DocumentComponent/DocumentComponent.js +24 -28
- package/dist/published/components/custom/Form/FormComponents/DocumentComponent/DocumentList.js +49 -64
- package/dist/published/components/custom/Form/FormComponents/FormFieldComponent.d.ts +1 -0
- package/dist/published/components/custom/Form/FormComponents/FormFieldComponent.js +109 -34
- package/dist/published/components/custom/Form/FormComponents/ImageComponent/Image.d.ts +2 -0
- package/dist/published/components/custom/Form/FormComponents/ImageComponent/Image.js +13 -25
- package/dist/published/components/custom/Form/FormComponents/ImageComponent/ImageComponent.d.ts +3 -1
- package/dist/published/components/custom/Form/FormComponents/ImageComponent/ImageComponent.js +30 -9
- package/dist/published/components/custom/Form/FormComponents/ObjectComponent/InstanceLookup.js +26 -31
- package/dist/published/components/custom/Form/FormComponents/ObjectComponent/ObjectComponent.d.ts +5 -4
- package/dist/published/components/custom/Form/FormComponents/ObjectComponent/ObjectComponent.js +70 -22
- package/dist/published/components/custom/Form/FormComponents/ObjectComponent/ObjectPropertyInput.js +93 -75
- package/dist/published/components/custom/Form/FormComponents/ObjectComponent/RelatedObjectInstance.d.ts +2 -2
- package/dist/published/components/custom/Form/FormComponents/ObjectComponent/RelatedObjectInstance.js +17 -26
- package/dist/published/components/custom/Form/FormComponents/RepeatableFieldComponent/ActionDialog.js +20 -24
- package/dist/published/components/custom/Form/FormComponents/RepeatableFieldComponent/ManyToMany/DropdownRepeatableField.js +22 -33
- package/dist/published/components/custom/Form/FormComponents/RepeatableFieldComponent/ManyToMany/DropdownRepeatableFieldInput.js +12 -9
- package/dist/published/components/custom/Form/FormComponents/RepeatableFieldComponent/RepeatableField.js +61 -60
- package/dist/published/components/custom/Form/FormComponents/RepeatableFieldComponent/RepeatableFieldComponent.js +8 -6
- package/dist/published/components/custom/Form/FormComponents/UserComponent/UserComponent.d.ts +3 -1
- package/dist/published/components/custom/Form/FormComponents/UserComponent/UserComponent.js +55 -12
- package/dist/published/components/custom/Form/FormComponents/UserComponent/UserProperty.js +32 -30
- package/dist/published/components/custom/Form/FormComponents/ViewOnlyComponent.js +12 -9
- package/dist/published/components/custom/Form/types.d.ts +5 -5
- package/dist/published/components/custom/Form/utils.js +611 -446
- package/dist/published/components/custom/FormField/AddressFieldComponent/AddressFieldComponent.test.js +41 -54
- package/dist/published/components/custom/FormField/AddressFieldComponent/addressFieldComponent.js +7 -8
- package/dist/published/components/custom/FormField/BooleanSelect/BooleanSelect.js +1 -1
- package/dist/published/components/custom/FormField/BooleanSelect/BooleanSelect.test.js +5 -14
- package/dist/published/components/custom/FormField/DatePickerSelect/DatePickerSelect.js +2 -2
- package/dist/published/components/custom/FormField/DatePickerSelect/DatePickerSelect.test.js +12 -21
- package/dist/published/components/custom/FormField/DateTimePickerSelect/DateTimePickerSelect.js +2 -2
- package/dist/published/components/custom/FormField/DateTimePickerSelect/DateTimePickerSelect.test.js +12 -21
- package/dist/published/components/custom/FormField/FileUpload/FileUpload.js +10 -11
- package/dist/published/components/custom/FormField/FormField.js +10 -10
- package/dist/published/components/custom/FormField/InputFieldComponent/InputFieldComponent.js +22 -30
- package/dist/published/components/custom/FormField/InputFieldComponent/InputFieldComponent.test.js +8 -17
- package/dist/published/components/custom/FormField/Select/Select.js +5 -6
- package/dist/published/components/custom/FormField/Select/Select.test.js +18 -27
- package/dist/published/components/custom/FormField/TimePickerSelect/TimePickerSelect.js +4 -4
- package/dist/published/components/custom/HistoryLog/DisplayedProperty.js +12 -13
- package/dist/published/components/custom/HistoryLog/HistoryData.js +49 -45
- package/dist/published/components/custom/HistoryLog/HistoryLoading.js +5 -5
- package/dist/published/components/custom/HistoryLog/index.js +5 -6
- package/dist/published/components/custom/Menubar/Menubar.js +2 -2
- package/dist/published/components/custom/MultiSelect/MultiSelect.js +38 -50
- package/dist/published/components/custom/MultiSelect/SortableItem.js +1 -1
- package/dist/published/components/custom/RepeatableField/RepeatableField.js +14 -16
- package/dist/published/components/custom/UserAvatar/UserAvatar.js +12 -5
- package/dist/published/components/custom/util.js +1 -1
- package/dist/published/components/layout/Box/Box.js +1 -1
- package/dist/published/components/layout/Container/Container.js +1 -1
- package/dist/published/components/layout/Grid/Grid.js +1 -1
- package/dist/published/components/layout/Stack/Stack.js +1 -1
- package/dist/published/icons/custom/FileWithExtension.js +8 -4
- package/dist/published/icons/custom/Inherited.js +8 -6
- package/dist/published/icons/custom/Overrides.js +9 -7
- package/dist/published/icons/custom/TrashCan.js +10 -8
- package/dist/published/icons/custom/UploadCloud.js +9 -7
- package/dist/published/stories/Accordion.stories.js +2 -2
- package/dist/published/stories/Alert.stories.js +1 -1
- package/dist/published/stories/AlertTitle.stories.js +1 -1
- package/dist/published/stories/Autocomplete.stories.js +2 -2
- package/dist/published/stories/Avatar.stories.js +1 -1
- package/dist/published/stories/Backdrop.stories.js +1 -1
- package/dist/published/stories/Badge.stories.js +1 -1
- package/dist/published/stories/Box.stories.js +2 -2
- package/dist/published/stories/Breadcrumbs.stories.js +1 -1
- package/dist/published/stories/Button.stories.js +1 -1
- package/dist/published/stories/ButtonGroup.stories.js +1 -1
- package/dist/published/stories/Card.stories.js +1 -1
- package/dist/published/stories/Checkbox.stories.js +1 -1
- package/dist/published/stories/Chip.stories.js +1 -1
- package/dist/published/stories/CircularProgress.stories.js +1 -1
- package/dist/published/stories/Collapse.stories.js +1 -1
- package/dist/published/stories/Container.stories.js +1 -1
- package/dist/published/stories/CriteriaBuilder.stories.js +7 -3
- package/dist/published/stories/DataGrid.stories.js +3 -3
- package/dist/published/stories/DatePicker.stories.js +3 -14
- package/dist/published/stories/Dialog.stories.js +1 -1
- package/dist/published/stories/Divider.stories.js +1 -1
- package/dist/published/stories/Drawer.stories.js +2 -2
- package/dist/published/stories/FormControl.stories.js +1 -1
- package/dist/published/stories/FormControlLabel.stories.js +1 -1
- package/dist/published/stories/FormField.stories.js +3 -12
- package/dist/published/stories/FormGroup.stories.js +1 -1
- package/dist/published/stories/FormHelperText.stories.js +1 -1
- package/dist/published/stories/FormLabel.stories.js +1 -1
- package/dist/published/stories/Grid.stories.js +1 -1
- package/dist/published/stories/HistoryLog.stories.js +1 -1
- package/dist/published/stories/IconButton.stories.js +4 -4
- package/dist/published/stories/LinearProgress.stories.js +1 -1
- package/dist/published/stories/Link.stories.js +1 -1
- package/dist/published/stories/List.stories.js +2 -2
- package/dist/published/stories/Menu.stories.js +2 -2
- package/dist/published/stories/MenuBar.stories.js +1 -1
- package/dist/published/stories/MultiSelect.stories.js +3 -3
- package/dist/published/stories/Palette.stories.js +11 -11
- package/dist/published/stories/Paper.stories.js +1 -1
- package/dist/published/stories/RadioGroup.stories.js +1 -1
- package/dist/published/stories/RepeatableField.stories.js +6 -7
- package/dist/published/stories/RichTextViewer.stories.js +1 -1
- package/dist/published/stories/Skeleton.stories.js +1 -1
- package/dist/published/stories/Snackbar.stories.js +1 -1
- package/dist/published/stories/Stack.stories.js +1 -1
- package/dist/published/stories/StaticDatePicker.stories.js +3 -14
- package/dist/published/stories/Stepper.stories.js +3 -3
- package/dist/published/stories/Switch.stories.js +1 -1
- package/dist/published/stories/Table.stories.js +2 -2
- package/dist/published/stories/Tabs.stories.js +6 -17
- package/dist/published/stories/TextField.stories.js +1 -1
- package/dist/published/stories/TimePicker.stories.js +3 -14
- package/dist/published/stories/TimePickerSelect.stories.js +3 -14
- package/dist/published/stories/ToggleButton.stories.js +4 -4
- package/dist/published/theme/UIThemeProvider.js +1 -2
- package/package.json +1 -1
@@ -1,12 +1,3 @@
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
8
|
-
});
|
9
|
-
};
|
10
1
|
import { BackupOutlined, ClearRounded } from '@mui/icons-material';
|
11
2
|
import React, { useEffect, useState } from 'react';
|
12
3
|
import { useDropzone } from 'react-dropzone';
|
@@ -62,38 +53,35 @@ const styles = {
|
|
62
53
|
},
|
63
54
|
};
|
64
55
|
export const Image = (props) => {
|
65
|
-
const { id, handleChange, property,
|
66
|
-
const [image, setImage] = useState();
|
56
|
+
const { id, handleChange, property, value, canUpdateProperty, error } = props;
|
57
|
+
const [image, setImage] = useState(value);
|
67
58
|
useEffect(() => {
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
if ((file === null || file === void 0 ? void 0 : file.size) && file.size <= 300000) {
|
75
|
-
const dataUrl = file ? yield blobToDataUrl(file) : null;
|
76
|
-
setImage(dataUrl);
|
59
|
+
setImage(value);
|
60
|
+
}, [value]);
|
61
|
+
const handleUpload = async (file) => {
|
62
|
+
if (file?.size && file.size <= 300000) {
|
63
|
+
const dataUrl = file ? await blobToDataUrl(file) : null;
|
64
|
+
setImage(dataUrl ?? undefined);
|
77
65
|
handleChange(property.id, dataUrl);
|
78
66
|
}
|
79
|
-
}
|
67
|
+
};
|
80
68
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
81
69
|
const handleRemove = (e) => {
|
82
|
-
setImage(
|
70
|
+
setImage(undefined);
|
83
71
|
handleChange(property.id, '');
|
84
72
|
e.stopPropagation();
|
85
73
|
};
|
86
74
|
const { getRootProps, getInputProps, open } = useDropzone({
|
87
75
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
88
|
-
onDrop: (files) => handleUpload(files
|
76
|
+
onDrop: (files) => handleUpload(files?.[0]),
|
89
77
|
accept: { 'image/*': ['.png', '.jpg', '.jpeg', '.gif', '.svg'] },
|
90
78
|
});
|
91
79
|
return (React.createElement(React.Fragment, null, image ? (React.createElement(Box, { sx: styles.imageContainer },
|
92
80
|
React.createElement(Box, { sx: { position: 'relative', left: 0, zIndex: 5 } },
|
93
81
|
React.createElement(CardMedia, { component: "img", image: image, sx: styles.image }),
|
94
82
|
canUpdateProperty && (React.createElement(IconButton, { onClick: handleRemove, "aria-label": "remove image", sx: styles.deleteIcon },
|
95
|
-
React.createElement(ClearRounded, { sx: styles.icon })))))) : canUpdateProperty ? (React.createElement(Box,
|
96
|
-
React.createElement("input",
|
83
|
+
React.createElement(ClearRounded, { sx: styles.icon })))))) : canUpdateProperty ? (React.createElement(Box, { sx: { ...styles.dropzoneContainer, borderColor: error ? 'red' : '#858585' }, ...getRootProps(), onClick: open },
|
84
|
+
React.createElement("input", { ...getInputProps({ id }), multiple: false }),
|
97
85
|
React.createElement(Grid, { container: true, sx: { width: '100%' } },
|
98
86
|
React.createElement(Grid, { item: true, xs: 12, sx: { display: 'flex', justifyContent: 'center', paddingBottom: '5px' } },
|
99
87
|
React.createElement(BackupOutlined, { sx: { color: '#919EAB', height: '1.5em', width: '1.5em' } })),
|
package/dist/published/components/custom/Form/FormComponents/ImageComponent/ImageComponent.d.ts
CHANGED
@@ -4,7 +4,9 @@ import { BaseFormComponentProps } from '../../types';
|
|
4
4
|
export declare class ImageComponent extends ReactComponent {
|
5
5
|
[x: string]: any;
|
6
6
|
static schema: any;
|
7
|
-
component: BaseFormComponentProps
|
7
|
+
component: BaseFormComponentProps & {
|
8
|
+
initialValue?: string;
|
9
|
+
};
|
8
10
|
errorDetails: any;
|
9
11
|
componentRoot?: Root;
|
10
12
|
constructor(component: BaseFormComponentProps, options: any, data: any);
|
package/dist/published/components/custom/Form/FormComponents/ImageComponent/ImageComponent.js
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
2
1
|
import { ReactComponent } from '@formio/react';
|
3
2
|
import { isEmpty } from 'lodash';
|
4
3
|
import React from 'react';
|
@@ -8,7 +7,11 @@ import { isPropertyVisible } from '../../utils';
|
|
8
7
|
import { Image } from './Image';
|
9
8
|
export class ImageComponent extends ReactComponent {
|
10
9
|
constructor(component, options, data) {
|
11
|
-
super(
|
10
|
+
super({
|
11
|
+
...component,
|
12
|
+
canUpdateProperty: !component.readOnly,
|
13
|
+
hideLabel: true,
|
14
|
+
}, options, data);
|
12
15
|
this.handleChange = (key, value) => {
|
13
16
|
delete this.errorDetails['api-error'];
|
14
17
|
this.setValue(value);
|
@@ -43,16 +46,35 @@ export class ImageComponent extends ReactComponent {
|
|
43
46
|
}
|
44
47
|
}
|
45
48
|
});
|
49
|
+
if (this.component.initialValue && /^{{.*}}$/.test(this.component.initialValue)) {
|
50
|
+
const regex = /^{{input\.(?<relatedObjectProperty>[a-zA-Z][a-zA-Z0-9_]*)\.(?<nestedProperty>[a-zA-Z][a-zA-Z0-9_]*)}}$/;
|
51
|
+
const groups = regex.exec(this.component.initialValue)?.groups;
|
52
|
+
if (groups?.relatedObjectProperty && groups?.nestedProperty) {
|
53
|
+
this.on(`changed-${groups.relatedObjectProperty}`, (value) => {
|
54
|
+
if (value) {
|
55
|
+
this.setValue(value?.[groups.nestedProperty]);
|
56
|
+
this.updateValue(value?.[groups.nestedProperty], { modified: true });
|
57
|
+
this.attach(this.element);
|
58
|
+
this.attachReact(this.element);
|
59
|
+
}
|
60
|
+
});
|
61
|
+
}
|
62
|
+
}
|
46
63
|
this.on(`api-error`, (details) => {
|
47
64
|
const error = details.find((detail) => detail.code === 'errorMessage' && detail.path.replace('/', '') === this.component.key);
|
48
65
|
if (error) {
|
49
66
|
if (!this.root.customErrors.find((err) => err.formattedKeyOrPath === this.component.key && err.message === error.message)) {
|
50
67
|
this.root.customErrors = [
|
51
68
|
...this.root.customErrors,
|
52
|
-
|
69
|
+
{
|
70
|
+
...error,
|
71
|
+
code: 'api-error',
|
72
|
+
component: this.component,
|
73
|
+
formattedKeyOrPath: this.component.key,
|
74
|
+
},
|
53
75
|
];
|
54
76
|
}
|
55
|
-
this.errorDetails['api-error'] = error
|
77
|
+
this.errorDetails['api-error'] = error?.message;
|
56
78
|
}
|
57
79
|
else {
|
58
80
|
this.root.customErrors = this.root.customErrors.filter((item) => item.formattedKeyOrPath !== this.component.key);
|
@@ -84,10 +106,9 @@ export class ImageComponent extends ReactComponent {
|
|
84
106
|
* Synchronizes out-of-the-box formio errors with this field's errorDetails object
|
85
107
|
*/
|
86
108
|
manageFormErrors() {
|
87
|
-
|
88
|
-
const outOfTheBoxError = (_a = this.root.errors.find((error) => {
|
109
|
+
const outOfTheBoxError = this.root.errors.find((error) => {
|
89
110
|
return error.component.key === this.component.key;
|
90
|
-
})
|
111
|
+
})?.message;
|
91
112
|
// add OoB formio error to errorDetails object to show under field
|
92
113
|
if (outOfTheBoxError) {
|
93
114
|
this.errorDetails['rootError'] = outOfTheBoxError;
|
@@ -106,7 +127,7 @@ export class ImageComponent extends ReactComponent {
|
|
106
127
|
}
|
107
128
|
// FormIO uses id for an enclosing div, so we need to give the input field a different id.
|
108
129
|
const inputId = `${this.component.id}-input`;
|
109
|
-
return this.componentRoot.render(React.createElement("div", null, !this.component.hidden ? (React.createElement(FormComponentWrapper,
|
110
|
-
React.createElement(Image,
|
130
|
+
return this.componentRoot.render(React.createElement("div", null, !this.component.hidden ? (React.createElement(FormComponentWrapper, { ...this.component, inputId: inputId, viewOnly: !this.component.canUpdateProperty, errorMessage: this.errorMessages() },
|
131
|
+
React.createElement(Image, { ...this.component, id: inputId, value: this.dataValue, handleChange: this.handleChange, error: this.hasErrors() }))) : null));
|
111
132
|
}
|
112
133
|
}
|
package/dist/published/components/custom/Form/FormComponents/ObjectComponent/InstanceLookup.js
CHANGED
@@ -1,12 +1,3 @@
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
8
|
-
});
|
9
|
-
};
|
10
1
|
import { Clear, Search } from '@mui/icons-material';
|
11
2
|
import { debounce, get, startCase } from 'lodash';
|
12
3
|
import { DateTime } from 'luxon';
|
@@ -21,7 +12,7 @@ const SearchField = (props) => {
|
|
21
12
|
setSearchString('');
|
22
13
|
setFilter(undefined);
|
23
14
|
};
|
24
|
-
const handleSearch = (e) =>
|
15
|
+
const handleSearch = async (e) => {
|
25
16
|
const searchProperties = searchableColumns.map((column) => {
|
26
17
|
const columnId = column.id;
|
27
18
|
return {
|
@@ -36,11 +27,15 @@ const SearchField = (props) => {
|
|
36
27
|
}
|
37
28
|
else {
|
38
29
|
setSearchString(e.target.value);
|
39
|
-
setFilter(
|
30
|
+
setFilter({
|
31
|
+
...filter,
|
32
|
+
where: {
|
40
33
|
or: searchProperties,
|
41
|
-
},
|
34
|
+
},
|
35
|
+
limit: 100,
|
36
|
+
});
|
42
37
|
}
|
43
|
-
}
|
38
|
+
};
|
44
39
|
return (React.createElement(TextField, { autoFocus: true, placeholder: "Search", value: searchString, onChange: (e) => handleSearch(e), size: "medium", fullWidth: true, sx: { marginBottom: '15px', marginTop: '15px' }, InputProps: {
|
45
40
|
endAdornment: (React.createElement(InputAdornment, { position: "end" },
|
46
41
|
React.createElement(IconButton, { sx: {
|
@@ -54,20 +49,18 @@ const SearchField = (props) => {
|
|
54
49
|
} }));
|
55
50
|
};
|
56
51
|
export const InstanceLookup = (props) => {
|
57
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
58
52
|
const { object, apiServices, setSelectedInstance, mode, nestedFieldsView, setRelationType, filter: criteriaFilter, layout, } = props;
|
59
53
|
const [rows, setRows] = useState([]);
|
60
54
|
const [loading, setLoading] = useState(false);
|
61
55
|
const [filter, setFilter] = useState();
|
62
56
|
const [searchString, setSearchString] = useState('');
|
63
|
-
const [searchableColumns] = useState(
|
57
|
+
const [searchableColumns] = useState(object.properties?.filter((property) => property.searchable) ?? []);
|
64
58
|
const retrieveColumns = (tableViewLayout) => {
|
65
|
-
var _a, _b, _c, _d;
|
66
59
|
let columns = [];
|
67
|
-
if (
|
60
|
+
if (tableViewLayout?.properties?.length) {
|
68
61
|
for (const prop of tableViewLayout.properties) {
|
69
62
|
const propertyId = prop.id.split('.')[0];
|
70
|
-
const property =
|
63
|
+
const property = object.properties?.find((p) => p.id === propertyId);
|
71
64
|
if (property) {
|
72
65
|
if (property.type === 'address') {
|
73
66
|
columns.push({
|
@@ -76,8 +69,7 @@ export const InstanceLookup = (props) => {
|
|
76
69
|
type: 'string',
|
77
70
|
flex: 1,
|
78
71
|
valueGetter: (params) => {
|
79
|
-
|
80
|
-
return (_a = get(params.row, prop.id)) !== null && _a !== void 0 ? _a : '';
|
72
|
+
return get(params.row, prop.id) ?? '';
|
81
73
|
},
|
82
74
|
});
|
83
75
|
}
|
@@ -88,8 +80,7 @@ export const InstanceLookup = (props) => {
|
|
88
80
|
type: 'string',
|
89
81
|
flex: 1,
|
90
82
|
valueGetter: (params) => {
|
91
|
-
|
92
|
-
return ((_a = get(params.row, !prop.id.includes('.') ? `${prop.id}.name` : prop.id)) !== null && _a !== void 0 ? _a : '');
|
83
|
+
return (get(params.row, !prop.id.includes('.') ? `${prop.id}.name` : prop.id) ?? '');
|
93
84
|
},
|
94
85
|
});
|
95
86
|
}
|
@@ -100,9 +91,9 @@ export const InstanceLookup = (props) => {
|
|
100
91
|
type: 'string',
|
101
92
|
flex: 1,
|
102
93
|
valueGetter: (params) => {
|
103
|
-
var _a, _b;
|
104
94
|
const row = params.row;
|
105
|
-
return (
|
95
|
+
return (row[prop.id]?.map((v) => v.name).join(', ') ??
|
96
|
+
'');
|
106
97
|
},
|
107
98
|
});
|
108
99
|
}
|
@@ -166,18 +157,22 @@ export const InstanceLookup = (props) => {
|
|
166
157
|
}
|
167
158
|
}
|
168
159
|
else {
|
169
|
-
const name =
|
170
|
-
columns = [{ field: 'name', headerName:
|
160
|
+
const name = object.properties?.find((property) => property.id == 'name');
|
161
|
+
columns = [{ field: 'name', headerName: name?.name ?? 'Name', type: 'string', flex: 1 }];
|
171
162
|
}
|
172
163
|
return columns;
|
173
164
|
};
|
174
165
|
function fetchObjectInstance() {
|
175
166
|
setLoading(true);
|
176
|
-
const combinedFilter =
|
167
|
+
const combinedFilter = {
|
168
|
+
...criteriaFilter,
|
169
|
+
...filter,
|
170
|
+
where: criteriaFilter?.where
|
177
171
|
? {
|
178
|
-
and: [criteriaFilter.where, filter
|
172
|
+
and: [criteriaFilter.where, filter?.where],
|
179
173
|
}
|
180
|
-
: filter
|
174
|
+
: filter?.where,
|
175
|
+
};
|
181
176
|
apiServices.get(getPrefixedUrl(`/objects/${object.id}/instances`), { params: { filter: JSON.stringify(combinedFilter) } }, (error, objectInstances) => {
|
182
177
|
if (error) {
|
183
178
|
console.error(error);
|
@@ -200,8 +195,8 @@ export const InstanceLookup = (props) => {
|
|
200
195
|
return (React.createElement(Grid, { container: true, sx: { paddingBottom: '30px' } },
|
201
196
|
React.createElement(Grid, { item: true, xs: 12 }, searchableColumns.length ? (React.createElement(SearchField, { searchString: searchString, setSearchString: setSearchString, filter: filter, setFilter: setFilter, searchableColumns: searchableColumns })) : (React.createElement(Typography, { sx: { fontSize: '16px', fontWeight: '700' } }, "There are no searchable properties configured for this object"))),
|
202
197
|
React.createElement(BuilderGrid, { item: 'instances', rows: rows, columns: columns, onRowClick: (params) => setSelectedInstance(params.row), initialSort: {
|
203
|
-
field:
|
204
|
-
sort:
|
198
|
+
field: object.viewLayout?.table?.sort?.colId ?? 'name',
|
199
|
+
sort: object.viewLayout?.table?.sort?.sort ?? 'asc',
|
205
200
|
}, sx: {
|
206
201
|
height: '360px',
|
207
202
|
width: '100%',
|
package/dist/published/components/custom/Form/FormComponents/ObjectComponent/ObjectComponent.d.ts
CHANGED
@@ -1,11 +1,12 @@
|
|
1
|
-
import { Obj,
|
1
|
+
import { Obj, ObjectInstance } from '@evoke-platform/context';
|
2
2
|
import { ReactComponent } from '@formio/react';
|
3
3
|
import { Root } from 'react-dom/client';
|
4
4
|
import { BaseFormComponentProps } from '../../types';
|
5
|
-
|
5
|
+
interface ObjectComponentProps extends BaseFormComponentProps {
|
6
6
|
mode: 'default' | 'existingOnly';
|
7
7
|
defaultValueCriteria?: Record<string, unknown>;
|
8
|
-
|
8
|
+
initialValue?: string;
|
9
|
+
}
|
9
10
|
export declare class ObjectComponent extends ReactComponent {
|
10
11
|
relatedObject?: Obj;
|
11
12
|
[x: string]: any;
|
@@ -27,7 +28,7 @@ export declare class ObjectComponent extends ReactComponent {
|
|
27
28
|
* Synchronizes out-of-the-box formio errors with this field's errorDetails object
|
28
29
|
*/
|
29
30
|
manageFormErrors(): void;
|
30
|
-
handleChangeObjectProperty: (key: string, value?:
|
31
|
+
handleChangeObjectProperty: (key: string, value?: ObjectInstance | null) => void;
|
31
32
|
beforeSubmit(): void;
|
32
33
|
attachReact(element: Element): void;
|
33
34
|
}
|
package/dist/published/components/custom/Form/FormComponents/ObjectComponent/ObjectComponent.js
CHANGED
@@ -1,34 +1,38 @@
|
|
1
1
|
import { ReactComponent } from '@formio/react';
|
2
2
|
import dot from 'dot-object';
|
3
|
-
import { cloneDeep, isEmpty } from 'lodash';
|
3
|
+
import { cloneDeep, isEmpty, pick } from 'lodash';
|
4
4
|
import React from 'react';
|
5
5
|
import { createRoot } from 'react-dom/client';
|
6
6
|
import { FormComponentWrapper } from '../../Common';
|
7
|
-
import { getAllCriteriaInputs, isPropertyVisible, transformToWhere, updateCriteriaInputs } from '../../utils';
|
7
|
+
import { getAllCriteriaInputs, getPrefixedUrl, isPropertyVisible, transformToWhere, updateCriteriaInputs, } from '../../utils';
|
8
8
|
import { ObjectPropertyInput } from './ObjectPropertyInput';
|
9
9
|
export class ObjectComponent extends ReactComponent {
|
10
10
|
constructor(component, options, data) {
|
11
|
-
|
12
|
-
|
11
|
+
super({
|
12
|
+
...component,
|
13
|
+
canUpdateProperty: !component.readOnly,
|
14
|
+
hideLabel: true,
|
15
|
+
}, options, data);
|
13
16
|
this.handleChangeObjectProperty = (key, value) => {
|
17
|
+
delete this.errorDetails['api-error'];
|
18
|
+
const updatedValue = pick(value, 'id', 'name');
|
14
19
|
// set the value on the form instance at this.root.data
|
15
|
-
this.setValue(
|
20
|
+
this.setValue(updatedValue ?? '');
|
16
21
|
// update the value in the component instance
|
17
|
-
this.updateValue(
|
22
|
+
this.updateValue(updatedValue ?? {}, { modified: true });
|
18
23
|
this.handleValidation();
|
19
24
|
this.emit('changed-' + this.component.key, value);
|
20
25
|
this.attach(this.element);
|
21
|
-
this.component.autoSave && this.component.autoSave({ [key]:
|
26
|
+
this.component.autoSave && this.component.autoSave({ [key]: updatedValue });
|
22
27
|
};
|
23
28
|
this.errorDetails = {};
|
24
29
|
this.criteria = component.validate.criteria;
|
25
|
-
this.updatedCriteria =
|
30
|
+
this.updatedCriteria = cloneDeep(component.validate.criteria) ?? {};
|
26
31
|
this.defaultValueCriteria = component.defaultValueCriteria;
|
27
|
-
this.updatedDefaultValueCriteria =
|
32
|
+
this.updatedDefaultValueCriteria = cloneDeep(component.defaultValueCriteria) ?? {};
|
28
33
|
this.handleChangeObjectProperty = this.handleChangeObjectProperty.bind(this);
|
29
34
|
}
|
30
35
|
init() {
|
31
|
-
var _a, _b;
|
32
36
|
this.on('changed-' + this.component.conditional.when, (value) => {
|
33
37
|
//set default value when conditional field is shown
|
34
38
|
if (this.component.defaultValue && value === this.component.conditional.eq) {
|
@@ -62,9 +66,8 @@ export class ObjectComponent extends ReactComponent {
|
|
62
66
|
compKey = inputProp;
|
63
67
|
}
|
64
68
|
this.on(`changed-${compKey}`, () => {
|
65
|
-
var _a;
|
66
69
|
const data = dot.dot(this.root._data);
|
67
|
-
this.updatedCriteria =
|
70
|
+
this.updatedCriteria = cloneDeep(this.criteria) ?? {};
|
68
71
|
for (const inputProp of inputProps) {
|
69
72
|
updateCriteriaInputs(this.updatedCriteria, inputProp, data[inputProp], true);
|
70
73
|
}
|
@@ -76,7 +79,7 @@ export class ObjectComponent extends ReactComponent {
|
|
76
79
|
}
|
77
80
|
if (this.defaultValueCriteria) {
|
78
81
|
const inputProps = getAllCriteriaInputs(this.defaultValueCriteria);
|
79
|
-
updateCriteriaInputs(this.updatedDefaultValueCriteria, 'user.id',
|
82
|
+
updateCriteriaInputs(this.updatedDefaultValueCriteria, 'user.id', this.component.user?.id ?? '');
|
80
83
|
for (const inputProp of inputProps) {
|
81
84
|
// Parse data to update criteria when form is loaded.
|
82
85
|
updateCriteriaInputs(this.updatedDefaultValueCriteria, inputProp, data[inputProp], true);
|
@@ -88,10 +91,9 @@ export class ObjectComponent extends ReactComponent {
|
|
88
91
|
compKey = inputProp;
|
89
92
|
}
|
90
93
|
this.on(`changed-${compKey}`, () => {
|
91
|
-
var _a, _b, _c;
|
92
94
|
const data = dot.dot(this.root._data);
|
93
|
-
this.updatedDefaultValueCriteria =
|
94
|
-
updateCriteriaInputs(this.updatedDefaultValueCriteria, 'user.id',
|
95
|
+
this.updatedDefaultValueCriteria = cloneDeep(this.defaultValueCriteria) ?? {};
|
96
|
+
updateCriteriaInputs(this.updatedDefaultValueCriteria, 'user.id', this.component.user?.id ?? '');
|
95
97
|
for (const inputProp of inputProps) {
|
96
98
|
updateCriteriaInputs(this.updatedDefaultValueCriteria, inputProp, data[inputProp], true);
|
97
99
|
}
|
@@ -101,6 +103,46 @@ export class ObjectComponent extends ReactComponent {
|
|
101
103
|
});
|
102
104
|
}
|
103
105
|
}
|
106
|
+
if (this.component.initialValue && /^{{.*}}$/.test(this.component.initialValue)) {
|
107
|
+
const regex = /^{{input\.(?<relatedObjectProperty>[a-zA-Z][a-zA-Z0-9_]*)\.(?<nestedProperty>[a-zA-Z][a-zA-Z0-9_]*)}}$/;
|
108
|
+
const groups = regex.exec(this.component.initialValue)?.groups;
|
109
|
+
if (groups?.relatedObjectProperty && groups?.nestedProperty) {
|
110
|
+
this.on(`changed-${groups.relatedObjectProperty}`, async (value) => {
|
111
|
+
if (value) {
|
112
|
+
const instanceReference = value[groups.nestedProperty];
|
113
|
+
this.setValue(instanceReference);
|
114
|
+
this.updateValue(instanceReference, { modified: true });
|
115
|
+
this.attach(this.element);
|
116
|
+
const apiServices = this.component.apiServices;
|
117
|
+
const relatedInstance = await apiServices?.get(getPrefixedUrl(`/objects/${this.component.property.objectId}/instances/${instanceReference.id}`));
|
118
|
+
this.emit(`changed-${this.component.key}`, relatedInstance);
|
119
|
+
}
|
120
|
+
});
|
121
|
+
}
|
122
|
+
}
|
123
|
+
this.on(`api-error`, (details) => {
|
124
|
+
const error = details.find((detail) => detail.code === 'errorMessage' && detail.path.replace('/', '') === this.component.key);
|
125
|
+
if (error) {
|
126
|
+
if (!this.root.customErrors.find((err) => err.formattedKeyOrPath === this.component.key && err.message === error.message)) {
|
127
|
+
this.root.customErrors = [
|
128
|
+
...this.root.customErrors,
|
129
|
+
{
|
130
|
+
...error,
|
131
|
+
code: 'api-error',
|
132
|
+
component: this.component,
|
133
|
+
formattedKeyOrPath: this.component.key,
|
134
|
+
},
|
135
|
+
];
|
136
|
+
}
|
137
|
+
this.errorDetails['api-error'] = error?.message;
|
138
|
+
}
|
139
|
+
else {
|
140
|
+
this.root.customErrors = this.root.customErrors.filter((item) => item.formattedKeyOrPath !== this.component.key);
|
141
|
+
delete this.errorDetails['api-error'];
|
142
|
+
}
|
143
|
+
this.attach(this.element);
|
144
|
+
this.attachReact(this.element);
|
145
|
+
});
|
104
146
|
}
|
105
147
|
clearErrors() {
|
106
148
|
this.errorDetails = {};
|
@@ -124,10 +166,9 @@ export class ObjectComponent extends ReactComponent {
|
|
124
166
|
* Synchronizes out-of-the-box formio errors with this field's errorDetails object
|
125
167
|
*/
|
126
168
|
manageFormErrors() {
|
127
|
-
|
128
|
-
const outOfTheBoxError = (_a = this.root.errors.find((error) => {
|
169
|
+
const outOfTheBoxError = this.root.errors.find((error) => {
|
129
170
|
return error.component.key === this.component.key;
|
130
|
-
})
|
171
|
+
})?.message;
|
131
172
|
//add OoB formio error to errorDetails object to show under field
|
132
173
|
if (outOfTheBoxError) {
|
133
174
|
this.errorDetails['rootError'] = outOfTheBoxError;
|
@@ -141,14 +182,21 @@ export class ObjectComponent extends ReactComponent {
|
|
141
182
|
this.element && this.attach(this.element);
|
142
183
|
}
|
143
184
|
attachReact(element) {
|
144
|
-
const updatedComponent =
|
185
|
+
const updatedComponent = {
|
186
|
+
...this.component,
|
187
|
+
instance: {
|
188
|
+
...this.component.instance,
|
189
|
+
[this.component.key]: isEmpty(this.dataValue) ? null : this.dataValue,
|
190
|
+
},
|
191
|
+
defaultValueCriteria: this.updatedDefaultValueCriteria,
|
192
|
+
};
|
145
193
|
if (!this.componentRoot) {
|
146
194
|
this.componentRoot = createRoot(element);
|
147
195
|
}
|
148
196
|
// FormIO uses id for an enclosing div, so we need to give the input field a different id.
|
149
197
|
const inputId = `${this.component.id}-input`;
|
150
198
|
return this.componentRoot.render(React.createElement("div", null,
|
151
|
-
React.createElement(FormComponentWrapper,
|
152
|
-
React.createElement(ObjectPropertyInput,
|
199
|
+
React.createElement(FormComponentWrapper, { ...updatedComponent, inputId: inputId, errorMessage: this.errorMessages() },
|
200
|
+
React.createElement(ObjectPropertyInput, { ...updatedComponent, id: inputId, handleChangeObjectProperty: this.handleChangeObjectProperty, error: this.hasErrors(), filter: this.criteria ? { where: transformToWhere(this.updatedCriteria) } : undefined }))));
|
153
201
|
}
|
154
202
|
}
|