@evoke-platform/ui-components 1.5.0-dev.11 → 1.5.0-dev.13
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/index.d.ts +3 -3
- package/dist/published/components/core/index.js +2 -2
- package/dist/published/components/custom/Form/Common/FormComponentWrapper.d.ts +1 -1
- package/dist/published/components/custom/Form/FormComponents/RepeatableFieldComponent/DocumentViewerCell.js +18 -19
- package/dist/published/components/custom/Form/FormComponents/RepeatableFieldComponent/ManyToMany/DropdownRepeatableField.js +29 -31
- package/dist/published/components/custom/Form/FormComponents/RepeatableFieldComponent/RepeatableField.js +4 -7
- package/dist/published/components/custom/Form/FormComponents/ViewOnlyComponent.d.ts +1 -1
- package/dist/published/components/custom/Form/FormComponents/ViewOnlyComponent.js +5 -2
- package/dist/published/components/custom/Form/types.d.ts +2 -0
- package/dist/published/components/custom/Form/utils.d.ts +2 -1
- package/dist/published/components/custom/Form/utils.js +11 -6
- package/dist/published/components/custom/FormField/AddressFieldComponent/addressFieldComponent.js +2 -2
- package/dist/published/components/custom/FormField/BooleanSelect/BooleanSelect.js +2 -13
- package/dist/published/components/custom/FormField/DatePickerSelect/DatePickerSelect.js +1 -1
- package/dist/published/components/custom/FormField/DateTimePickerSelect/DateTimePickerSelect.js +1 -1
- package/dist/published/components/custom/FormField/FileUpload/FileUpload.js +2 -2
- package/dist/published/components/custom/FormField/FormField.d.ts +1 -1
- package/dist/published/components/custom/FormField/InputFieldComponent/InputFieldComponent.js +2 -2
- package/dist/published/components/custom/FormField/Select/Select.js +3 -2
- package/dist/published/components/custom/FormField/TimePickerSelect/TimePickerSelect.js +2 -2
- package/package.json +3 -3
@@ -46,10 +46,10 @@ export { ToggleButtonGroup } from './ToggleButtonGroup';
|
|
46
46
|
export { Tooltip } from './Tooltip';
|
47
47
|
export { Typography } from './Typography';
|
48
48
|
export { TabContext, TabList, TabPanel, TreeItem, TreeView } from '@mui/lab';
|
49
|
-
export { CardActionArea, CardActions, CardContent, CardHeader, CardMedia, Input, InputAdornment, InputLabel, ListItemButton, ListItemText, SvgIcon, TableBody, TableCell, TableContainer, TableHead, TablePagination, TableRow, TableSortLabel, } from '@mui/material';
|
49
|
+
export { CardActionArea, CardActions, CardContent, CardHeader, CardMedia, Input, InputAdornment, InputLabel, ListItemButton, ListItemText, MenuList, SvgIcon, TableBody, TableCell, TableContainer, TableHead, TablePagination, TableRow, TableSortLabel, } from '@mui/material';
|
50
50
|
export { useGridApiRef } from '@mui/x-data-grid';
|
51
|
-
export { TreeItem as RichTreeItem, RichTreeView } from '@mui/x-tree-view';
|
51
|
+
export { TreeItem as RichTreeItem, RichTreeView, TreeItem2Content, TreeItem2DragAndDropOverlay, TreeItem2GroupTransition, TreeItem2Icon, TreeItem2IconContainer, TreeItem2Label, TreeItem2Provider, TreeItem2Root, useTreeItem2, } from '@mui/x-tree-view';
|
52
52
|
export type { GridSize } from '@mui/material';
|
53
53
|
export type { GridCellParams, GridColDef, GridEventListener, GridFilterModel, GridInitialState, GridRowParams, GridSortModel, GridValueFormatterParams, GridValueGetterParams, } from '@mui/x-data-grid';
|
54
|
-
export type { TreeItemProps, TreeViewBaseItem } from '@mui/x-tree-view';
|
54
|
+
export type { TreeItemProps, TreeViewBaseItem, UseTreeItem2Parameters } from '@mui/x-tree-view';
|
55
55
|
export type { AutocompleteOption } from './Autocomplete/Autocomplete';
|
@@ -47,6 +47,6 @@ export { Tooltip } from './Tooltip';
|
|
47
47
|
export { Typography } from './Typography';
|
48
48
|
//TODO: Review following components. They also need theme control:
|
49
49
|
export { TabContext, TabList, TabPanel, TreeItem, TreeView } from '@mui/lab';
|
50
|
-
export { CardActionArea, CardActions, CardContent, CardHeader, CardMedia, Input, InputAdornment, InputLabel, ListItemButton, ListItemText, SvgIcon, TableBody, TableCell, TableContainer, TableHead, TablePagination, TableRow, TableSortLabel, } from '@mui/material';
|
50
|
+
export { CardActionArea, CardActions, CardContent, CardHeader, CardMedia, Input, InputAdornment, InputLabel, ListItemButton, ListItemText, MenuList, SvgIcon, TableBody, TableCell, TableContainer, TableHead, TablePagination, TableRow, TableSortLabel, } from '@mui/material';
|
51
51
|
export { useGridApiRef } from '@mui/x-data-grid';
|
52
|
-
export { TreeItem as RichTreeItem, RichTreeView } from '@mui/x-tree-view';
|
52
|
+
export { TreeItem as RichTreeItem, RichTreeView, TreeItem2Content, TreeItem2DragAndDropOverlay, TreeItem2GroupTransition, TreeItem2Icon, TreeItem2IconContainer, TreeItem2Label, TreeItem2Provider, TreeItem2Root, useTreeItem2, } from '@mui/x-tree-view';
|
@@ -18,7 +18,7 @@ type FormComponentWrapperProps = {
|
|
18
18
|
viewOnly: boolean;
|
19
19
|
children: React.ReactNode;
|
20
20
|
key: string;
|
21
|
-
displayOption?: 'radioButton' | 'dropdown' | 'dialogBox';
|
21
|
+
displayOption?: 'radioButton' | 'dropdown' | 'dialogBox' | 'switch' | 'checkbox';
|
22
22
|
onChange?: (key: string, value: unknown) => void;
|
23
23
|
property?: ObjectProperty;
|
24
24
|
readOnly?: boolean;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import React, { useState } from 'react';
|
2
2
|
import { AutorenewRounded, FileWithExtension, LaunchRounded } from '../../../../../icons';
|
3
|
-
import { Button, Menu, MenuItem, Typography } from '../../../../core';
|
3
|
+
import { Button, Menu, MenuItem, MenuList, Typography } from '../../../../core';
|
4
4
|
import { Grid } from '../../../../layout';
|
5
5
|
import { getPrefixedUrl } from '../../utils';
|
6
6
|
export const DocumentViewerCell = (props) => {
|
@@ -66,24 +66,23 @@ export const DocumentViewerCell = (props) => {
|
|
66
66
|
fontWeight: 400,
|
67
67
|
fontSize: '14px',
|
68
68
|
} }, isLoading ? 'Preparing document...' : 'View Document')),
|
69
|
-
React.createElement(
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
} }, instance[propertyId].map((document) => (React.createElement(MenuItem, { key: document.id, onClick: async (e) => {
|
69
|
+
React.createElement(Menu, { id: `document-menu-${instance.id}-${propertyId}`, anchorEl: anchorEl, open: Boolean(anchorEl), onClose: () => {
|
70
|
+
setAnchorEl(null);
|
71
|
+
}, sx: {
|
72
|
+
'& .MuiPaper-root': {
|
73
|
+
borderRadius: '12px',
|
74
|
+
boxShadow: 'rgba(145, 158, 171, 0.2)',
|
75
|
+
},
|
76
|
+
}, variant: 'menu', PaperProps: {
|
77
|
+
tabIndex: 0,
|
78
|
+
sx: {
|
79
|
+
maxHeight: 200,
|
80
|
+
maxWidth: 300,
|
81
|
+
minWidth: 300,
|
82
|
+
},
|
83
|
+
component: 'nav',
|
84
|
+
} },
|
85
|
+
React.createElement(MenuList, { autoFocusItem: Boolean(anchorEl) }, instance[propertyId].map((document) => (React.createElement(MenuItem, { key: document.id, onClick: async (e) => {
|
87
86
|
setAnchorEl(null);
|
88
87
|
await downloadDocument(document, instance);
|
89
88
|
}, "aria-label": document.name },
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { useNotification, } from '@evoke-platform/context';
|
2
|
-
import { debounce, isEmpty
|
2
|
+
import { debounce, isEmpty } from 'lodash';
|
3
3
|
import React, { useCallback, useEffect, useState } from 'react';
|
4
4
|
import { Skeleton } from '../../../../../core';
|
5
|
-
import { getMiddleObject, getPrefixedUrl, transformToWhere } from '../../../utils';
|
5
|
+
import { getMiddleObject, getPrefixedUrl, retrieveCustomErrorMessage, transformToWhere } from '../../../utils';
|
6
6
|
import { DropdownRepeatableFieldInput } from './DropdownRepeatableFieldInput';
|
7
7
|
export const DropdownRepeatableField = (props) => {
|
8
8
|
const { id, property, criteria, instance, readOnly, apiServices, initialMiddleObjectInstances, middleObject, getMiddleObjectInstances, fieldHeight, viewLayout, } = props;
|
@@ -127,43 +127,41 @@ export const DropdownRepeatableField = (props) => {
|
|
127
127
|
fetchEndObjectInstances();
|
128
128
|
}
|
129
129
|
}, [fetchEndObjectInstances, layoutLoaded]);
|
130
|
-
const saveMiddleInstance = (endObjectId, endObjectName) => {
|
130
|
+
const saveMiddleInstance = async (endObjectId, endObjectName) => {
|
131
131
|
if (property.objectId) {
|
132
132
|
const middleObject = getMiddleObject(instance, property, endObjectId, endObjectName);
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
}
|
140
|
-
else {
|
141
|
-
if (error) {
|
142
|
-
setSnackbarError({
|
143
|
-
showAlert: true,
|
144
|
-
message: 'An error occured while adding an instance',
|
145
|
-
isError: true,
|
146
|
-
});
|
147
|
-
setDropDownSelections(middleObjectInstances);
|
148
|
-
}
|
149
|
-
}
|
150
|
-
});
|
151
|
-
}
|
152
|
-
};
|
153
|
-
const removeMiddleInstance = (instanceId) => {
|
154
|
-
apiServices.post(getPrefixedUrl(`/objects/${property.objectId}/instances/${instanceId}/actions`), { actionId: '_delete' }, (error, res) => {
|
155
|
-
if (!error) {
|
156
|
-
setMiddleObjectInstances((prevInstances) => prevInstances.filter((curr) => curr.id !== instanceId));
|
133
|
+
try {
|
134
|
+
const newInstance = await apiServices.post(getPrefixedUrl(`/objects/${property.objectId}/instances/actions`), { actionId: `_create`, input: middleObject });
|
135
|
+
setMiddleObjectInstances((prevObjectInstances) => [
|
136
|
+
...prevObjectInstances,
|
137
|
+
newInstance,
|
138
|
+
]);
|
157
139
|
}
|
158
|
-
|
159
|
-
setDropDownSelections(middleObjectInstances);
|
140
|
+
catch (err) {
|
160
141
|
setSnackbarError({
|
161
142
|
showAlert: true,
|
162
|
-
message:
|
143
|
+
message: retrieveCustomErrorMessage(err) ??
|
144
|
+
'An error occured while adding an instance',
|
163
145
|
isError: true,
|
164
146
|
});
|
147
|
+
setDropDownSelections(middleObjectInstances);
|
165
148
|
}
|
166
|
-
}
|
149
|
+
}
|
150
|
+
};
|
151
|
+
const removeMiddleInstance = async (instanceId) => {
|
152
|
+
try {
|
153
|
+
await apiServices.post(getPrefixedUrl(`/objects/${property.objectId}/instances/${instanceId}/actions`), { actionId: '_delete' });
|
154
|
+
setMiddleObjectInstances((prevInstances) => prevInstances.filter((curr) => curr.id !== instanceId));
|
155
|
+
}
|
156
|
+
catch (err) {
|
157
|
+
setDropDownSelections(middleObjectInstances);
|
158
|
+
setSnackbarError({
|
159
|
+
showAlert: true,
|
160
|
+
message: retrieveCustomErrorMessage(err) ??
|
161
|
+
'An error occurred while deleting the instance',
|
162
|
+
isError: true,
|
163
|
+
});
|
164
|
+
}
|
167
165
|
};
|
168
166
|
return initialLoading ? (React.createElement(Skeleton, null)) : (React.createElement(React.Fragment, null, middleObjectInstances && endObject && (React.createElement(DropdownRepeatableFieldInput, { id: id, property: property, readOnly: readOnly || !middleObject.actions?.some((action) => action.id === '_create'), layout: layout, middleObjectInstances: middleObjectInstances, endObjectInstances: endObjectInstances ?? [], endObject: endObject, searchValue: searchValue ?? '', loading: loading, handleSaveMiddleInstance: saveMiddleInstance, handleRemoveMiddleInstance: removeMiddleInstance, setSearchValue: setSearchValue, setSnackbarError: setSnackbarError, snackbarError: snackbarError, selectedOptions: selectedOptions, setSelectedOptions: setSelectedOptions, setDropdownSelections: setDropDownSelections, fieldHeight: fieldHeight }))));
|
169
167
|
};
|
@@ -7,7 +7,7 @@ import sift from 'sift';
|
|
7
7
|
import { Edit, TrashCan } from '../../../../../icons';
|
8
8
|
import { Button, IconButton, Skeleton, Snackbar, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, Tooltip, Typography, } from '../../../../core';
|
9
9
|
import { Box } from '../../../../layout';
|
10
|
-
import { getPrefixedUrl, normalizeDateTime } from '../../utils';
|
10
|
+
import { getPrefixedUrl, normalizeDateTime, retrieveCustomErrorMessage } from '../../utils';
|
11
11
|
import { ActionDialog } from './ActionDialog';
|
12
12
|
import { DocumentViewerCell } from './DocumentViewerCell';
|
13
13
|
const styles = {
|
@@ -251,11 +251,10 @@ const RepeatableField = (props) => {
|
|
251
251
|
isSuccessful = true;
|
252
252
|
}
|
253
253
|
catch (err) {
|
254
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
255
|
-
error = err.response?.data?.error;
|
256
254
|
setSnackbarError({
|
257
255
|
showAlert: true,
|
258
|
-
message:
|
256
|
+
message: retrieveCustomErrorMessage(err) ??
|
257
|
+
`An error occurred while creating an instance`,
|
259
258
|
isError: true,
|
260
259
|
});
|
261
260
|
setSubmitting && setSubmitting(false);
|
@@ -285,11 +284,9 @@ const RepeatableField = (props) => {
|
|
285
284
|
isSuccessful = true;
|
286
285
|
}
|
287
286
|
catch (err) {
|
288
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
289
|
-
error = err.response?.data?.error;
|
290
287
|
setSnackbarError({
|
291
288
|
showAlert: true,
|
292
|
-
message:
|
289
|
+
message: retrieveCustomErrorMessage(err) ??
|
293
290
|
`An error occurred while ${actionType === 'delete' ? ' deleting' : ' updating'} an instance`,
|
294
291
|
isError: true,
|
295
292
|
});
|
@@ -15,6 +15,6 @@ export declare class ViewOnlyComponent extends ReactComponent {
|
|
15
15
|
* @param data - The contextual data object (model) used for this component.
|
16
16
|
*/
|
17
17
|
constructor(component: BaseFormComponentProps, options: any, data: any);
|
18
|
-
showValue(value: unknown):
|
18
|
+
showValue(value: unknown): unknown;
|
19
19
|
attachReact(element: Element): void;
|
20
20
|
}
|
@@ -4,6 +4,7 @@ import { DateTime } from 'luxon';
|
|
4
4
|
import React from 'react';
|
5
5
|
import ReactDOM from 'react-dom';
|
6
6
|
import { Link, Typography } from '../../../core';
|
7
|
+
import BooleanSelect from '../../FormField/BooleanSelect/BooleanSelect';
|
7
8
|
import { FormComponentWrapper } from '../Common/FormComponentWrapper';
|
8
9
|
export class ViewOnlyComponent extends ReactComponent {
|
9
10
|
/**
|
@@ -25,7 +26,7 @@ export class ViewOnlyComponent extends ReactComponent {
|
|
25
26
|
this.showValue = this.showValue.bind(this);
|
26
27
|
}
|
27
28
|
showValue(value) {
|
28
|
-
if (value === null || value === undefined)
|
29
|
+
if ((value === null || value === undefined) && this.component.type !== 'ViewOnlyBoolean')
|
29
30
|
return React.createElement("span", null, "\u00A0");
|
30
31
|
switch (this.component.type) {
|
31
32
|
case 'ViewOnlyObject':
|
@@ -63,7 +64,9 @@ export class ViewOnlyComponent extends ReactComponent {
|
|
63
64
|
case 'ViewOnlyTime':
|
64
65
|
return DateTime.fromISO(DateTime.now().toISODate() + 'T' + value).toFormat('hh:mm a');
|
65
66
|
case 'ViewOnlyBoolean':
|
66
|
-
return
|
67
|
+
return (React.createElement(BooleanSelect, { id: this.component.key, readOnly: true, label: this.component.label, required: this.component.validate?.required, description: this.component.description, property: this.component.property, defaultValue: this.component.instance
|
68
|
+
? get(this.component.instance, this.component.key)
|
69
|
+
: this.component.defaultValue, size: this.component.fieldHeight, displayOption: this.component.displayOption }));
|
67
70
|
default:
|
68
71
|
return value;
|
69
72
|
}
|
@@ -50,6 +50,8 @@ export type BaseFormComponentProps = {
|
|
50
50
|
autoSave?: (update: Record<string, unknown>) => void;
|
51
51
|
baseUrl: string;
|
52
52
|
apiServices: ApiServices;
|
53
|
+
description?: string;
|
54
|
+
displayOption?: 'radioButton' | 'dropdown' | 'dialogBox' | 'switch' | 'checkbox';
|
53
55
|
};
|
54
56
|
export type ObjectPropertyInputProps = {
|
55
57
|
id: string;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { ActionInput, ActionInputType, ApiServices, FormEntry, InputParameter, InputParameterReference, Obj, ObjectInstance, Property, PropertyType, UserAccount } from '@evoke-platform/context';
|
1
|
+
import { ActionInput, ActionInputType, ApiServices, AxiosError, FormEntry, InputParameter, InputParameterReference, Obj, ObjectInstance, Property, PropertyType, UserAccount } from '@evoke-platform/context';
|
2
2
|
import { ReactComponent } from '@formio/react';
|
3
3
|
import { LocalDateTime } from '@js-joda/core';
|
4
4
|
import { AutocompleteOption } from '../../core';
|
@@ -50,3 +50,4 @@ export declare function isPropertyVisible(conditional: {
|
|
50
50
|
}, formData: Record<string, unknown>): boolean;
|
51
51
|
export declare function normalizeDateTime(dateTime: LocalDateTime): string;
|
52
52
|
export declare function normalizeDates(instances: ObjectInstance[], object?: Obj): void;
|
53
|
+
export declare function retrieveCustomErrorMessage(error: AxiosError<any>): string | undefined;
|
@@ -129,12 +129,12 @@ export function convertFormToComponents(entries, parameters, object) {
|
|
129
129
|
}
|
130
130
|
else if (entry.type === 'input') {
|
131
131
|
const displayOptions = entry.display;
|
132
|
-
const parameter = parameters.find((parameter) => parameter.id === entry.parameterId);
|
132
|
+
const parameter = parameters.find((parameter) => entry.type === 'input' && parameter.id === entry.parameterId);
|
133
133
|
if (!parameter) {
|
134
134
|
return;
|
135
135
|
}
|
136
|
-
let property = object.properties?.find((p) => p.id === entry.parameterId) ?? {
|
137
|
-
id: entry.parameterId,
|
136
|
+
let property = object.properties?.find((p) => entry.type === 'input' && p.id === entry.parameterId) ?? {
|
137
|
+
id: entry.type === 'input' ? entry.parameterId : undefined,
|
138
138
|
};
|
139
139
|
if (property.id?.includes('.')) {
|
140
140
|
const topLevelProperty = object.properties?.find((p) => p.id === property.id?.split('.')[0] && (p.type === 'address' || p.type === 'user'));
|
@@ -163,7 +163,7 @@ export function convertFormToComponents(entries, parameters, object) {
|
|
163
163
|
type,
|
164
164
|
multiple: ['array', 'document'].includes(parameter.type),
|
165
165
|
data: {
|
166
|
-
values: entry.enumWithLabels,
|
166
|
+
values: entry.type === 'input' ? entry.enumWithLabels : undefined,
|
167
167
|
},
|
168
168
|
property: property,
|
169
169
|
defaultToCurrentTime: displayOptions?.defaultValue === 'currentTime' && parameter.type === 'time' ? true : false,
|
@@ -189,7 +189,7 @@ export function convertFormToComponents(entries, parameters, object) {
|
|
189
189
|
tableView: false,
|
190
190
|
displayOption: parameter.type === 'object'
|
191
191
|
? displayOptions?.relatedObjectDisplay
|
192
|
-
: parameter.type === 'string' && parameter.enum
|
192
|
+
: (parameter.type === 'string' && parameter.enum) || parameter.type === 'boolean'
|
193
193
|
? displayOptions?.choicesDisplay?.type
|
194
194
|
: undefined,
|
195
195
|
labelPosition: 'top',
|
@@ -789,7 +789,9 @@ formComponents, allCriteriaInputs, instance, objectPropertyInputProps, associate
|
|
789
789
|
];
|
790
790
|
}
|
791
791
|
export function getDefaultValue(initialValue, selectOptions) {
|
792
|
-
if (
|
792
|
+
if (typeof initialValue === 'boolean' ||
|
793
|
+
!isEmpty(initialValue) ||
|
794
|
+
(initialValue !== undefined && typeof initialValue === 'number')) {
|
793
795
|
if (Array.isArray(initialValue)) {
|
794
796
|
return initialValue
|
795
797
|
.map((option) => {
|
@@ -1286,6 +1288,9 @@ export function normalizeDates(instances, object) {
|
|
1286
1288
|
});
|
1287
1289
|
});
|
1288
1290
|
}
|
1291
|
+
export function retrieveCustomErrorMessage(error) {
|
1292
|
+
return error?.response?.data?.error?.statusCode !== 500 ? error?.response?.data?.error?.message : undefined;
|
1293
|
+
}
|
1289
1294
|
/**
|
1290
1295
|
* Given an object entry in a JsonLogic object, map it to the correct value.
|
1291
1296
|
* @param entry An entry in a JsonLogic object.
|
package/dist/published/components/custom/FormField/AddressFieldComponent/addressFieldComponent.js
CHANGED
@@ -34,12 +34,12 @@ const AddressFieldComponent = (props) => {
|
|
34
34
|
return { label, sublabel, value: address.address };
|
35
35
|
}));
|
36
36
|
});
|
37
|
-
props.onChange(property.id, inputValue, property, undefined);
|
37
|
+
props.onChange && props.onChange(property.id, inputValue, property, undefined);
|
38
38
|
};
|
39
39
|
const handleClick = (option) => {
|
40
40
|
setAnchorEl(null);
|
41
41
|
setValue(option.value.line1);
|
42
|
-
props.onChange(property.id, option.value, property, undefined);
|
42
|
+
props.onChange && props.onChange(property.id, option.value, property, undefined);
|
43
43
|
};
|
44
44
|
const handleClose = () => {
|
45
45
|
setAnchorEl(null);
|
@@ -17,7 +17,7 @@ const BooleanSelect = (props) => {
|
|
17
17
|
}, [defaultValue]);
|
18
18
|
const handleChange = (value) => {
|
19
19
|
setValue(value);
|
20
|
-
props.onChange(property.id, value, property);
|
20
|
+
props.onChange && props.onChange(property.id, value, property);
|
21
21
|
};
|
22
22
|
const booleanOptions = [
|
23
23
|
{
|
@@ -29,18 +29,7 @@ const BooleanSelect = (props) => {
|
|
29
29
|
value: false,
|
30
30
|
},
|
31
31
|
];
|
32
|
-
return displayOption === 'dropdown' ? (readOnly ? (React.createElement(InputFieldComponent, { ...props })) : (React.createElement(Autocomplete, { renderInput: (params) => (React.createElement(TextField, { ...params, error: error, errorMessage: errorMessage, onBlur: onBlur, fullWidth: true, sx: { background: 'white' }, placeholder: placeholder })), value: value, onChange: (e, selectedValue) => handleChange(selectedValue.value), isOptionEqualToValue: (option, val) => {
|
33
|
-
if (typeof val === 'boolean') {
|
34
|
-
return option?.value === val;
|
35
|
-
}
|
36
|
-
return option?.value === val?.value;
|
37
|
-
}, getOptionLabel: (option) => {
|
38
|
-
if (typeof option === 'boolean') {
|
39
|
-
const opt = booleanOptions.find((o) => o.value === option);
|
40
|
-
return opt?.label ?? '';
|
41
|
-
}
|
42
|
-
return option.label;
|
43
|
-
}, options: booleanOptions, disableClearable: true, sx: { background: 'white', borderRadius: '8px' }, ...(additionalProps ?? {}) }))) : (React.createElement(FormControl, { error: error, fullWidth: true },
|
32
|
+
return displayOption === 'dropdown' ? (readOnly ? (React.createElement(InputFieldComponent, { ...props })) : (React.createElement(Autocomplete, { renderInput: (params) => (React.createElement(TextField, { ...params, error: error, errorMessage: errorMessage, onBlur: onBlur, fullWidth: true, sx: { background: 'white' }, placeholder: placeholder, size: size ?? 'medium' })), value: booleanOptions.find((opt) => opt.value === value) ?? '', onChange: (e, selectedValue) => handleChange(selectedValue.value), isOptionEqualToValue: (option, val) => option?.value === val?.value, options: booleanOptions, disableClearable: true, sx: { background: 'white', borderRadius: '8px' }, ...(additionalProps ?? {}), sortBy: "NONE" }))) : (React.createElement(FormControl, { error: error, fullWidth: true },
|
44
33
|
React.createElement(FormControlLabel, { labelPlacement: "end", label: React.createElement(Typography, { variant: "body2", sx: { wordWrap: 'break-word', fontFamily: 'Public Sans' } },
|
45
34
|
label,
|
46
35
|
tooltip && (React.createElement(Tooltip, { placement: "right", title: tooltip },
|
@@ -33,7 +33,7 @@ const DatePickerSelect = (props) => {
|
|
33
33
|
}, [defaultValue]);
|
34
34
|
const handleChange = (date) => {
|
35
35
|
setValue(date);
|
36
|
-
onChange(property.id, date, property);
|
36
|
+
onChange && onChange(property.id, date, property);
|
37
37
|
};
|
38
38
|
return readOnly ? (React.createElement(InputFieldComponent, { ...{ ...props, defaultValue: asMonthDayYearFormat(value) } })) : (React.createElement(LocalizationProvider, null,
|
39
39
|
React.createElement(DatePicker, { value: value, onChange: handleChange, inputFormat: "MM/dd/yyyy", renderInput: (params) => (React.createElement(TextField, { ...params, id: id, error: error, errorMessage: errorMessage, onBlur: onBlur, fullWidth: true, required: required, sx: { background: 'white', borderRadius: '8px' }, size: size ?? 'medium', ...(additionalProps ?? {}) })) })));
|
package/dist/published/components/custom/FormField/DateTimePickerSelect/DateTimePickerSelect.js
CHANGED
@@ -40,7 +40,7 @@ const DateTimePickerSelect = (props) => {
|
|
40
40
|
date = LocalDateTime.of(date, LocalTime.of(0));
|
41
41
|
}
|
42
42
|
setValue(date);
|
43
|
-
props.onChange(property.id, date, property);
|
43
|
+
props.onChange && props.onChange(property.id, date, property);
|
44
44
|
};
|
45
45
|
return readOnly ? (React.createElement(InputFieldComponent, { ...{ ...props, defaultValue: formatDateTime(value) } })) : (React.createElement(LocalizationProvider, null,
|
46
46
|
React.createElement(DateTimePicker, { value: value, onChange: handleChange, renderInput: (params) => (React.createElement(TextField, { ...params, id: id, error: error, errorMessage: errorMessage, onBlur: onBlur, fullWidth: true, required: required, sx: { background: 'white', borderRadius: '8px' }, size: size ?? 'medium', ...(additionalProps ?? {}) })) })));
|
@@ -30,13 +30,13 @@ const FileUploadControl = (props) => {
|
|
30
30
|
};
|
31
31
|
useEffect(() => {
|
32
32
|
if (uploadedFile) {
|
33
|
-
props.onChange(property.id, uploadedFile, property);
|
33
|
+
props.onChange && props.onChange(property.id, uploadedFile, property);
|
34
34
|
}
|
35
35
|
}, [uploadedFile]);
|
36
36
|
const handleSelectFile = () => {
|
37
37
|
if (uploadedFile) {
|
38
38
|
setUploadedFile(undefined);
|
39
|
-
props.onChange(property.id, undefined, property);
|
39
|
+
props.onChange && props.onChange(property.id, undefined, property);
|
40
40
|
}
|
41
41
|
};
|
42
42
|
const onDrop = useCallback(
|
@@ -6,7 +6,7 @@ import { Address } from './AddressFieldComponent/addressFieldComponent';
|
|
6
6
|
export type FormFieldProps = {
|
7
7
|
id?: string;
|
8
8
|
property: ObjectProperty;
|
9
|
-
onChange
|
9
|
+
onChange?: Function;
|
10
10
|
onBlur?: FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;
|
11
11
|
defaultValue?: unknown;
|
12
12
|
error?: boolean;
|
package/dist/published/components/custom/FormField/InputFieldComponent/InputFieldComponent.js
CHANGED
@@ -26,11 +26,11 @@ const InputFieldComponent = (props) => {
|
|
26
26
|
? parseInt(e.target.value, 10)
|
27
27
|
: e.target.value;
|
28
28
|
setValue(inputValue);
|
29
|
-
props.onChange(property.id, inputValue, property);
|
29
|
+
props.onChange && props.onChange(property.id, inputValue, property);
|
30
30
|
};
|
31
31
|
const handleSelectChange = (e, selected) => {
|
32
32
|
setValue(selected.label);
|
33
|
-
props.onChange(property.id, selected.label, property);
|
33
|
+
props.onChange && props.onChange(property.id, selected.label, property);
|
34
34
|
};
|
35
35
|
const handleInputValueChange = (event, selectValue) => {
|
36
36
|
setInputValue(selectValue);
|
@@ -12,11 +12,12 @@ const Select = (props) => {
|
|
12
12
|
const handleChange = (event, selected) => {
|
13
13
|
if (Array.isArray(selected)) {
|
14
14
|
setValue(selected.map((option) => option.value ?? option));
|
15
|
-
props.onChange
|
15
|
+
props.onChange &&
|
16
|
+
props.onChange(property.id, selected.map((option) => option.value ?? option), property);
|
16
17
|
}
|
17
18
|
else {
|
18
19
|
setValue(selected);
|
19
|
-
props.onChange(property.id, selected, property);
|
20
|
+
props.onChange && props.onChange(property.id, selected, property);
|
20
21
|
}
|
21
22
|
};
|
22
23
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
@@ -32,11 +32,11 @@ const TimePickerSelect = (props) => {
|
|
32
32
|
const hour = padStart(date?.hour().toString(), 2, '0');
|
33
33
|
const minute = padStart(date?.minute().toString(), 2, '0');
|
34
34
|
const second = padStart(date?.second().toString(), 2, '0');
|
35
|
-
props.onChange(property.id, `${hour}:${minute}:${second}`, property);
|
35
|
+
props.onChange && props.onChange(property.id, `${hour}:${minute}:${second}`, property);
|
36
36
|
}
|
37
37
|
else {
|
38
38
|
setValue(null);
|
39
|
-
props.onChange(property.id, date, property);
|
39
|
+
props.onChange && props.onChange(property.id, date, property);
|
40
40
|
}
|
41
41
|
};
|
42
42
|
return (React.createElement(LocalizationProvider, null,
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@evoke-platform/ui-components",
|
3
|
-
"version": "1.5.0-dev.
|
3
|
+
"version": "1.5.0-dev.13",
|
4
4
|
"description": "",
|
5
5
|
"main": "dist/published/index.js",
|
6
6
|
"module": "dist/published/index.js",
|
@@ -18,9 +18,9 @@
|
|
18
18
|
"test": "vitest",
|
19
19
|
"test:ui": "vitest --ui",
|
20
20
|
"copy-styles": "copyfiles -u 1 src/styles/*.css dist/published/",
|
21
|
-
"build": "
|
21
|
+
"build": "rm -rf ./dist && tsc && npm run copy-styles",
|
22
22
|
"build:cjs": "tsc --module CommonJS --outDir dist/cjs",
|
23
|
-
"prepublish": "
|
23
|
+
"prepublish": "rm -rf ./dist && tsc && npm run copy-styles",
|
24
24
|
"storybook": "start-storybook -p 6006",
|
25
25
|
"build-storybook": "build-storybook",
|
26
26
|
"lint": "npm run prettier:check && npm run eslint",
|