@evoke-platform/ui-components 1.4.0 → 1.5.0-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/core/List/ListItemIcon/ListItemIcon.d.ts +4 -0
- package/dist/published/components/core/List/ListItemIcon/ListItemIcon.js +6 -0
- package/dist/published/components/core/List/ListItemIcon/index.d.ts +3 -0
- package/dist/published/components/core/List/ListItemIcon/index.js +3 -0
- package/dist/published/components/core/List/index.d.ts +2 -1
- package/dist/published/components/core/List/index.js +2 -1
- package/dist/published/components/core/index.d.ts +4 -2
- package/dist/published/components/core/index.js +2 -1
- package/dist/published/components/custom/CriteriaBuilder/CriteriaBuilder.js +6 -6
- package/dist/published/components/custom/CriteriaBuilder/ValueEditor.d.ts +2 -3
- package/dist/published/components/custom/CriteriaBuilder/ValueEditor.js +87 -62
- package/dist/published/components/custom/Form/Common/FormComponentWrapper.js +18 -17
- package/dist/published/components/custom/Form/FormComponents/FormFieldComponent.d.ts +1 -1
- package/dist/published/components/custom/Form/FormComponents/FormFieldComponent.js +7 -10
- package/dist/published/components/custom/Form/FormComponents/ObjectComponent/RelatedObjectInstance.js +3 -3
- package/dist/published/components/custom/Form/FormComponents/RepeatableFieldComponent/DocumentViewerCell.d.ts +13 -0
- package/dist/published/components/custom/Form/FormComponents/RepeatableFieldComponent/DocumentViewerCell.js +115 -0
- package/dist/published/components/custom/Form/FormComponents/RepeatableFieldComponent/RepeatableField.js +25 -26
- package/dist/published/components/custom/Form/FormComponents/RepeatableFieldComponent/RepeatableFieldComponent.js +1 -1
- package/dist/published/components/custom/Form/utils.js +1 -1
- package/dist/published/components/custom/FormField/BooleanSelect/BooleanSelect.js +24 -21
- package/dist/published/components/custom/FormField/BooleanSelect/BooleanSelect.test.js +50 -8
- package/dist/published/components/custom/FormField/FormField.d.ts +4 -1
- package/dist/published/components/custom/FormField/FormField.js +5 -2
- package/dist/published/components/custom/Menubar/Menubar.d.ts +14 -1
- package/dist/published/components/custom/Menubar/Menubar.js +9 -2
- package/dist/published/components/custom/Menubar/Menubar.test.js +5 -0
- package/dist/published/components/layout/Box/Box.d.ts +3 -3
- package/dist/published/components/layout/Box/Box.js +4 -4
- package/dist/published/icons/custom/NoNavigation.d.ts +3 -0
- package/dist/published/icons/custom/NoNavigation.js +10 -0
- package/dist/published/icons/custom/SideNavigation.d.ts +3 -0
- package/dist/published/icons/custom/SideNavigation.js +11 -0
- package/dist/published/icons/custom/TopNavigation.d.ts +3 -0
- package/dist/published/icons/custom/TopNavigation.js +11 -0
- package/dist/published/icons/custom/index.d.ts +3 -0
- package/dist/published/icons/custom/index.js +3 -0
- package/dist/published/index.d.ts +1 -1
- package/dist/published/index.js +1 -1
- package/dist/published/stories/Box.stories.d.ts +3 -12
- package/dist/published/stories/CriteriaBuilder.stories.js +6 -0
- package/dist/published/stories/Form.stories.js +7 -2
- package/dist/published/stories/FormField.stories.js +2 -0
- package/dist/published/stories/MenuBar.stories.js +13 -18
- package/dist/published/stories/Palette.stories.d.ts +2 -12
- package/package.json +7 -4
@@ -24,7 +24,7 @@ export { FormControl, FormControlLabel, FormGroup, FormHelperText, FormLabel } f
|
|
24
24
|
export { IconButton } from './IconButton';
|
25
25
|
export { LinearProgress } from './LinearProgress';
|
26
26
|
export { Link } from './Link';
|
27
|
-
export { List, ListItem } from './List';
|
27
|
+
export { List, ListItem, ListItemIcon } from './List';
|
28
28
|
export { LoadingButton } from './LoadingButton';
|
29
29
|
export * from './LocalizationProvider';
|
30
30
|
export { Menu, MenuItem } from './Menu';
|
@@ -48,6 +48,8 @@ export { Typography } from './Typography';
|
|
48
48
|
export { TabContext, TabList, TabPanel, TreeItem, TreeView } from '@mui/lab';
|
49
49
|
export { CardActionArea, CardActions, CardContent, CardHeader, CardMedia, Input, InputAdornment, InputLabel, ListItemButton, ListItemText, 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
52
|
export type { GridSize } from '@mui/material';
|
52
|
-
export type { GridCellParams, GridColDef, GridEventListener, GridFilterModel, GridInitialState, GridRowParams, GridValueFormatterParams, GridValueGetterParams, } from '@mui/x-data-grid';
|
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';
|
53
55
|
export type { AutocompleteOption } from './Autocomplete/Autocomplete';
|
@@ -24,7 +24,7 @@ export { FormControl, FormControlLabel, FormGroup, FormHelperText, FormLabel } f
|
|
24
24
|
export { IconButton } from './IconButton';
|
25
25
|
export { LinearProgress } from './LinearProgress';
|
26
26
|
export { Link } from './Link';
|
27
|
-
export { List, ListItem } from './List';
|
27
|
+
export { List, ListItem, ListItemIcon } from './List';
|
28
28
|
export { LoadingButton } from './LoadingButton';
|
29
29
|
export * from './LocalizationProvider';
|
30
30
|
export { Menu, MenuItem } from './Menu';
|
@@ -49,3 +49,4 @@ export { Typography } from './Typography';
|
|
49
49
|
export { TabContext, TabList, TabPanel, TreeItem, TreeView } from '@mui/lab';
|
50
50
|
export { CardActionArea, CardActions, CardContent, CardHeader, CardMedia, Input, InputAdornment, InputLabel, ListItemButton, ListItemText, 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';
|
@@ -155,7 +155,7 @@ const customSelector = (props) => {
|
|
155
155
|
}));
|
156
156
|
}
|
157
157
|
else if (inputType === 'integer' || inputType === 'number') {
|
158
|
-
opts = options.filter((option) => ['=', '!=', '<', '<=', '>', '>=', 'null', 'notNull'].includes(option.name));
|
158
|
+
opts = options.filter((option) => ['=', '!=', '<', '<=', '>', '>=', 'null', 'notNull', 'in', 'notIn'].includes(option.name));
|
159
159
|
// checks if it is a single-select property
|
160
160
|
}
|
161
161
|
else if (inputType === 'string' && isArray(props.fieldData?.values)) {
|
@@ -164,7 +164,7 @@ const customSelector = (props) => {
|
|
164
164
|
else if (inputType === 'string') {
|
165
165
|
opts = options.filter((option) => !['>', '<', '<=', '>='].includes(option.name));
|
166
166
|
}
|
167
|
-
else if (inputType === 'image') {
|
167
|
+
else if (inputType === 'image' || inputType === 'boolean') {
|
168
168
|
opts = options.filter((option) => ['=', '!=', 'null', 'notNull'].includes(option.name));
|
169
169
|
}
|
170
170
|
break;
|
@@ -267,12 +267,12 @@ export const valueEditor = (props) => {
|
|
267
267
|
const CriteriaBuilder = (props) => {
|
268
268
|
const { properties, criteria, setCriteria, originalCriteria, enablePresetValues, presetValues, operators, disabled, disabledCriteria, hideBorder, presetGroupLabel, customValueEditor, treeViewOpts, disableRegexEscapeChars, } = props;
|
269
269
|
const [propertyTreeMap, setPropertyTreeMap] = useState();
|
270
|
-
const processRules = (rules
|
270
|
+
const processRules = (rules) => {
|
271
271
|
return rules.map((rule) => {
|
272
272
|
if ('rules' in rule) {
|
273
273
|
return {
|
274
274
|
...rule,
|
275
|
-
rules: processRules(rule.rules
|
275
|
+
rules: processRules(rule.rules),
|
276
276
|
};
|
277
277
|
}
|
278
278
|
else {
|
@@ -345,7 +345,7 @@ const CriteriaBuilder = (props) => {
|
|
345
345
|
return updatedQuery
|
346
346
|
? {
|
347
347
|
...updatedQuery,
|
348
|
-
rules: processRules(updatedQuery.rules
|
348
|
+
rules: processRules(updatedQuery.rules),
|
349
349
|
}
|
350
350
|
: { combinator: 'and', rules: [] };
|
351
351
|
};
|
@@ -371,7 +371,7 @@ const CriteriaBuilder = (props) => {
|
|
371
371
|
const handleQueryChange = (q) => {
|
372
372
|
const processedQuery = {
|
373
373
|
...q,
|
374
|
-
rules: processRules(q.rules
|
374
|
+
rules: processRules(q.rules),
|
375
375
|
};
|
376
376
|
setQuery(processedQuery);
|
377
377
|
const newCriteria = JSON.parse(formatQuery(processedQuery, {
|
@@ -1,8 +1,7 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
import { ValueEditorProps as ValueEditorBaseProps } from 'react-querybuilder';
|
3
|
-
import { AutocompleteOption } from '../../core';
|
2
|
+
import { Option, ValueEditorProps as ValueEditorBaseProps } from 'react-querybuilder';
|
4
3
|
export type ValueEditorProps = ValueEditorBaseProps & {
|
5
|
-
values?:
|
4
|
+
values?: Option[];
|
6
5
|
};
|
7
6
|
declare const ValueEditor: (props: ValueEditorProps) => React.JSX.Element;
|
8
7
|
export default ValueEditor;
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { Instant, LocalDate, LocalDateTime, LocalTime, ZoneId } from '@js-joda/core';
|
2
|
-
import { ClearRounded, CodeRounded } from '@mui/icons-material';
|
3
2
|
import { Box, darken, lighten, styled } from '@mui/material';
|
4
3
|
import { TimePicker } from '@mui/x-date-pickers';
|
5
4
|
import React, { useEffect, useRef, useState } from 'react';
|
5
|
+
import { ClearRounded, CodeRounded } from '../../../icons';
|
6
6
|
import { InvalidDate } from '../../../util';
|
7
7
|
import { Autocomplete, Chip, DatePicker, DateTimePicker, IconButton, LocalizationProvider, Menu, MenuItem, TextField, Typography, } from '../../core';
|
8
8
|
import { NumericFormat } from '../FormField/InputFieldComponent';
|
@@ -18,16 +18,22 @@ const GroupHeader = styled('div')(({ theme }) => ({
|
|
18
18
|
: darken(theme.palette.primary.main, 0.8),
|
19
19
|
}));
|
20
20
|
const GroupItems = styled('ul')({ padding: 0 });
|
21
|
+
const isPresetValue = (value) => typeof value === 'string' && value.startsWith('{{{') && value.endsWith('}}}');
|
21
22
|
const ValueEditor = (props) => {
|
22
23
|
const { handleOnChange, value, operator, context, level, rule, fieldData } = props;
|
23
24
|
let inputType = props.inputType;
|
24
|
-
let values = props.values
|
25
|
+
let values = (props.values ?? [])
|
26
|
+
.map((item) => ({
|
27
|
+
value: item.name,
|
28
|
+
label: item.label,
|
29
|
+
}))
|
30
|
+
.sort((a, b) => a.label.localeCompare(b.label));
|
25
31
|
const property = context.propertyTreeMap?.[rule.field];
|
26
32
|
// for tree view / related object properties, the properties are stored in the propertyTreeMap upon selection
|
27
33
|
if (!!context.treeViewOpts && !!property) {
|
28
34
|
inputType = property.type;
|
29
35
|
if (property.enum) {
|
30
|
-
values = property.enum.map((item) => ({
|
36
|
+
values = property.enum.map((item) => ({ value: item, label: item }));
|
31
37
|
}
|
32
38
|
}
|
33
39
|
const [invalidDateTime, setInvalidDateTime] = useState(false);
|
@@ -37,10 +43,17 @@ const ValueEditor = (props) => {
|
|
37
43
|
// Manages input value for Autocomplete when using 'in/not in' operators, ensuring correct handling on blur.
|
38
44
|
const [inputValue, setInputValue] = useState('');
|
39
45
|
const disabled = ['null', 'notNull'].includes(operator);
|
40
|
-
const presetValues = context.presetValues
|
41
|
-
|
42
|
-
|
43
|
-
|
46
|
+
const presetValues = context.presetValues
|
47
|
+
?.filter((val) => !val.type || val.type === inputType)
|
48
|
+
?.map((val) => {
|
49
|
+
return {
|
50
|
+
label: val.label,
|
51
|
+
value: val.value?.name,
|
52
|
+
sublabel: val.value?.sublabel,
|
53
|
+
type: val.type,
|
54
|
+
};
|
55
|
+
})
|
56
|
+
?.sort((a, b) => a.label.localeCompare(b.label)) ?? [];
|
44
57
|
let readOnly = context.disabled;
|
45
58
|
if (!readOnly && context.disabledCriteria) {
|
46
59
|
readOnly =
|
@@ -54,11 +67,12 @@ const ValueEditor = (props) => {
|
|
54
67
|
'& .MuiAutocomplete-tag': { backgroundColor: '#edeff1' },
|
55
68
|
},
|
56
69
|
};
|
70
|
+
const isMultipleOperator = ['in', 'notIn'].includes(operator);
|
57
71
|
useEffect(() => {
|
58
|
-
if (!
|
72
|
+
if (!isMultipleOperator && Array.isArray(value)) {
|
59
73
|
handleOnChange('');
|
60
74
|
}
|
61
|
-
else if (
|
75
|
+
else if (isMultipleOperator && !Array.isArray(value)) {
|
62
76
|
handleOnChange([]);
|
63
77
|
}
|
64
78
|
}, [operator]);
|
@@ -75,6 +89,7 @@ const ValueEditor = (props) => {
|
|
75
89
|
};
|
76
90
|
const clearValue = () => {
|
77
91
|
handleOnChange('');
|
92
|
+
setInputValue('');
|
78
93
|
};
|
79
94
|
const setPresetValue = (value) => {
|
80
95
|
handleOnChange(value);
|
@@ -126,9 +141,6 @@ const ValueEditor = (props) => {
|
|
126
141
|
}
|
127
142
|
}
|
128
143
|
const getEditor = () => {
|
129
|
-
if (isPresetValueSelected) {
|
130
|
-
return;
|
131
|
-
}
|
132
144
|
if (disabled) {
|
133
145
|
return React.createElement(React.Fragment, null);
|
134
146
|
}
|
@@ -180,18 +192,36 @@ const ValueEditor = (props) => {
|
|
180
192
|
React.createElement(TextField, { ...params, disabled: disabled, onClick: onClick, placeholder: "Value", size: "small", inputRef: inputRef, error: invalidDateTime }))), readOnly: readOnly })));
|
181
193
|
}
|
182
194
|
else if (inputType === 'number' || inputType === 'integer') {
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
+
if (isMultipleOperator) {
|
196
|
+
const options = presetValues;
|
197
|
+
return (React.createElement(Autocomplete, { freeSolo: true, multiple: true, options: options, value: Array.isArray(value)
|
198
|
+
? disabled
|
199
|
+
? []
|
200
|
+
: value.map((v) => {
|
201
|
+
const found = options.find((o) => o.value === v);
|
202
|
+
return found ? found : { label: v, value: v };
|
203
|
+
})
|
204
|
+
: [], disabled: disabled, onChange: (event, newValue) => {
|
205
|
+
const uniqueSelections = newValue
|
206
|
+
.map((item) => {
|
207
|
+
if (typeof item === 'object' && 'value' in item) {
|
208
|
+
return item.value;
|
209
|
+
}
|
210
|
+
else if (typeof item === 'string') {
|
211
|
+
if (isPresetValue(item)) {
|
212
|
+
return item;
|
213
|
+
}
|
214
|
+
else if (item.match(/^(\+|-){0,1}\d*(\.\d+)?$/)) {
|
215
|
+
const value = Number(item);
|
216
|
+
return Number.isNaN(value) ? '' : value;
|
217
|
+
}
|
218
|
+
return '';
|
219
|
+
}
|
220
|
+
return item;
|
221
|
+
})
|
222
|
+
.filter((item) => item !== '');
|
223
|
+
handleOnChange(uniqueSelections.length ? Array.from(new Set(uniqueSelections)) : '');
|
224
|
+
}, isOptionEqualToValue: (option, value) => option.value === value.value, renderInput: (params) => (React.createElement(TextField, { label: params.label, ...params, size: "small" })), groupBy: (option) => isPresetValue(option.value) ? context.presetGroupLabel || 'Preset Values' : 'Options', renderGroup: groupRenderGroup, sx: styles.input, readOnly: readOnly }));
|
195
225
|
}
|
196
226
|
else {
|
197
227
|
return (React.createElement(TextField, { inputRef: inputRef, value: ['null', 'notNull'].includes(operator) ? '' : value, disabled: disabled || ['null', 'notNull'].includes(operator), onChange: (e) => {
|
@@ -206,29 +236,39 @@ const ValueEditor = (props) => {
|
|
206
236
|
: { type: 'number' }), placeholder: "Value", size: "small", onClick: onClick, sx: styles.input, readOnly: readOnly }));
|
207
237
|
}
|
208
238
|
}
|
239
|
+
else if (inputType === 'boolean') {
|
240
|
+
const options = [{ label: 'True', value: true }, { label: 'False', value: false }, ...presetValues];
|
241
|
+
return (React.createElement(Autocomplete, { options: options, value: options.find((opt) => opt.value === value) ?? value, onChange: (event, newValue) => {
|
242
|
+
handleOnChange(newValue ? newValue.value : '');
|
243
|
+
}, isOptionEqualToValue: (option, value) => option.value === value.value, renderInput: (params) => (React.createElement(TextField, { inputRef: inputRef, label: params.label, ...params, size: "small" })), groupBy: (option) => isPresetValue(option.value) ? context.presetGroupLabel || 'Preset Values' : 'Options', renderGroup: groupRenderGroup, sortBy: "NONE", sx: styles.input, readOnly: readOnly }));
|
244
|
+
}
|
209
245
|
else {
|
210
|
-
const isMultiple = inputType === 'array' ||
|
211
|
-
|
212
|
-
...
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
246
|
+
const isMultiple = inputType === 'array' || isMultipleOperator || values?.length;
|
247
|
+
if (isMultiple) {
|
248
|
+
const options = [...values, ...presetValues];
|
249
|
+
return (React.createElement(Autocomplete, { freeSolo: inputType !== 'array' && fieldData.valueEditorType !== 'select', multiple: isMultiple, options: options, value: isMultiple
|
250
|
+
? Array.isArray(value)
|
251
|
+
? value.map((item) => {
|
252
|
+
const found = options.find((o) => o.value === item);
|
253
|
+
return found ? found : { label: item, value: item };
|
254
|
+
})
|
255
|
+
: []
|
256
|
+
: Array.isArray(value)
|
257
|
+
? ''
|
258
|
+
: value, onChange: (event, newValue) => {
|
219
259
|
let value;
|
220
260
|
if (isMultiple) {
|
221
|
-
|
222
|
-
const values = newValue.map((item) => item.name || item.value?.name || item);
|
261
|
+
const values = newValue.map((item) => typeof item === 'string' ? item : item.value);
|
223
262
|
value = Array.from(new Set(values));
|
224
263
|
}
|
225
264
|
else {
|
226
|
-
value =
|
265
|
+
value =
|
266
|
+
typeof newValue === 'string' ? newValue : newValue.value;
|
227
267
|
}
|
228
268
|
handleOnChange(value);
|
229
269
|
}, onBlur: () => {
|
230
270
|
if (inputValue &&
|
231
|
-
(options.some((option) => option.
|
271
|
+
(options.some((option) => option.value === inputValue) || !options.length) &&
|
232
272
|
(operator === 'in' || operator === 'notIn')) {
|
233
273
|
const newValues = Array.isArray(value) ? [...value, inputValue] : [inputValue];
|
234
274
|
handleOnChange(Array.from(new Set(newValues)));
|
@@ -237,7 +277,7 @@ const ValueEditor = (props) => {
|
|
237
277
|
}, onKeyDown: (event) => {
|
238
278
|
if (event.key === 'Enter' &&
|
239
279
|
inputValue &&
|
240
|
-
(options.some((option) => option.
|
280
|
+
(options.some((option) => option.value === inputValue) || !options.length) &&
|
241
281
|
(operator === 'in' || operator === 'notIn')) {
|
242
282
|
const newValues = Array.isArray(value) ? [...value, inputValue] : [inputValue];
|
243
283
|
handleOnChange(Array.from(new Set(newValues)));
|
@@ -245,32 +285,16 @@ const ValueEditor = (props) => {
|
|
245
285
|
}
|
246
286
|
}, onInputChange: (event, newInputValue) => {
|
247
287
|
setInputValue(newInputValue);
|
248
|
-
}, inputValue: inputValue, renderInput: (params) => (React.createElement(TextField, { inputRef: inputRef, label: params
|
249
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
250
|
-
getOptionLabel: (option) => {
|
251
|
-
if (typeof option === 'string') {
|
252
|
-
const found = options.find((o) => option === o.name || option === o.value?.name);
|
253
|
-
return found?.label || option;
|
254
|
-
}
|
255
|
-
return option?.label;
|
256
|
-
},
|
257
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
258
|
-
isOptionEqualToValue: (option, value) => {
|
259
|
-
if (typeof value === 'string') {
|
260
|
-
return option?.name === value || option?.value?.name === value;
|
261
|
-
}
|
262
|
-
else {
|
263
|
-
return option?.label === value?.label;
|
264
|
-
}
|
265
|
-
}, groupBy: (option) => isPresetValue(option.value?.name) ? context.presetGroupLabel || 'Preset Values' : 'Options', renderGroup: groupRenderGroup, sortBy: "NONE", sx: styles.input, readOnly: readOnly }));
|
288
|
+
}, inputValue: inputValue, renderInput: (params) => (React.createElement(TextField, { inputRef: inputRef, label: params.label, ...params, size: "small" })), isOptionEqualToValue: (option, value) => option?.value === value.value, groupBy: (option) => isPresetValue(option.value) ? context.presetGroupLabel || 'Preset Values' : 'Options', renderGroup: groupRenderGroup, sortBy: "NONE", sx: styles.input, readOnly: readOnly }));
|
266
289
|
}
|
267
290
|
else {
|
268
291
|
return (React.createElement(TextField, { inputRef: inputRef, value: ['null', 'notNull'].includes(operator) ? '' : value, disabled: ['null', 'notNull'].includes(operator), onChange: (e) => handleOnChange(e.target.value), onClick: onClick, placeholder: "Value", size: "small", sx: styles.input, readOnly: readOnly }));
|
269
292
|
}
|
270
293
|
}
|
271
294
|
};
|
295
|
+
const presetDisplayValue = React.useMemo(() => presetValues?.find((option) => option.value === value)?.label || value, [presetValues, value]);
|
272
296
|
return (React.createElement(React.Fragment, null,
|
273
|
-
|
297
|
+
isPresetValue(value) ? (React.createElement(Box, { ref: inputRef, sx: {
|
274
298
|
width: '33%',
|
275
299
|
display: 'flex',
|
276
300
|
justifyContent: 'space-between',
|
@@ -291,10 +315,11 @@ const ValueEditor = (props) => {
|
|
291
315
|
!readOnly && (React.createElement(IconButton, { onClick: clearValue, sx: { padding: '3px', margin: '3px' } },
|
292
316
|
React.createElement(ClearRounded, { fontSize: "small", sx: { color: 'rgba(0, 0, 0, 0.54)' } }))))) : (getEditor()),
|
293
317
|
!!presetValues?.length && (React.createElement(Menu, { open: openPresetValues, anchorEl: inputRef?.current, PaperProps: { sx: { borderRadius: '8px', width: inputRef?.current?.offsetWidth } }, onClose: onClose }, presetValues &&
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
318
|
+
presetValues.map((option) => {
|
319
|
+
return (React.createElement(MenuItem, { ...props, onClick: () => setPresetValue(option.value), sx: { padding: '8px', minHeight: '25px' } },
|
320
|
+
React.createElement(Box, { padding: 0, margin: 0 },
|
321
|
+
React.createElement(Typography, { fontSize: '14px', fontWeight: 500, sx: { lineHeight: '20px' } }, option.label),
|
322
|
+
!!option.sublabel && (React.createElement(Typography, { fontSize: '14px', fontWeight: 500, color: 'rgba(145, 158, 171)', sx: { lineHeight: '20px' } }, option.sublabel)))));
|
323
|
+
})))));
|
299
324
|
};
|
300
325
|
export default ValueEditor;
|
@@ -67,25 +67,26 @@ export const FormComponentWrapper = (props) => {
|
|
67
67
|
charCount = maxLength - charCount;
|
68
68
|
return (React.createElement(Box, null,
|
69
69
|
React.createElement(Box, { sx: { padding: '10px 0' } },
|
70
|
-
|
71
|
-
label,
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
React.createElement(
|
77
|
-
React.createElement(
|
78
|
-
|
79
|
-
React.createElement(
|
80
|
-
React.createElement(
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
React.createElement(
|
70
|
+
property?.type !== 'boolean' && (React.createElement(React.Fragment, null,
|
71
|
+
React.createElement(Typography, { variant: "body2", color: viewOnly ? 'textSecondary' : 'textPrimary', component: "label", htmlFor: inputId, sx: { ...(displayOption === 'radioButton' && value && { marginRight: '8px' }) } },
|
72
|
+
label,
|
73
|
+
validate.required ? (React.createElement(Typography, { component: 'span', sx: { color: 'red', fontSize: '12px' } },
|
74
|
+
` *`,
|
75
|
+
' ')) : null,
|
76
|
+
tooltip && (React.createElement(Tooltip, { placement: "right", title: tooltip },
|
77
|
+
React.createElement(IconButton, null,
|
78
|
+
React.createElement(Help, { sx: { fontSize: '14px' } }))))),
|
79
|
+
displayOption === 'radioButton' && onChange && !viewOnly && !readOnly && value && (React.createElement(Tooltip, { title: `Clear` },
|
80
|
+
React.createElement("span", null,
|
81
|
+
React.createElement(IconButton, { "aria-label": `Clear`, sx: { padding: '0px' }, onClick: () => {
|
82
|
+
property && onChange(property.id, '');
|
83
|
+
} },
|
84
|
+
React.createElement(HighlightOffOutlined, { sx: clearBtnStyles }))))),
|
85
|
+
React.createElement(Box, { sx: { ...(displayOption === 'radioButton' && { display: 'flex' }) } },
|
86
|
+
React.createElement(Typography, { variant: "caption", sx: descriptionStyles }, description)))),
|
86
87
|
React.createElement(Box, { sx: { display: 'flex', flexDirection: 'row' } },
|
87
88
|
React.createElement(PrefixSuffix, { prefix: prefix, height: fieldHeight }),
|
88
|
-
React.createElement(Box, { sx: { width: '100%', paddingTop: '6px' } }, children),
|
89
|
+
React.createElement(Box, { sx: { width: '100%', paddingTop: property?.type !== 'boolean' ? '6px' : undefined } }, children),
|
89
90
|
React.createElement(PrefixSuffix, { suffix: suffix, height: fieldHeight }))),
|
90
91
|
React.createElement(Box, { sx: underFieldStyles },
|
91
92
|
React.createElement(Box, { sx: { width: '100%', display: 'flex', justifyContent: 'space-between' } },
|
@@ -35,7 +35,7 @@ export declare class FormFieldComponent extends ReactComponent {
|
|
35
35
|
*/
|
36
36
|
manageFormErrors(): void;
|
37
37
|
beforeSubmit(): void;
|
38
|
-
|
38
|
+
handleAddressChange: (components: any, value: any) => void;
|
39
39
|
handleChange: (key: string, value: any) => void;
|
40
40
|
attachReact(element: Element): void;
|
41
41
|
}
|
@@ -61,13 +61,13 @@ export class FormFieldComponent extends ReactComponent {
|
|
61
61
|
selectOptions,
|
62
62
|
inputMaskPlaceholderChar: component.inputMaskPlaceholderChar || '_',
|
63
63
|
}, options, data);
|
64
|
-
this.
|
64
|
+
this.handleAddressChange = (components, value) => {
|
65
65
|
if (isArray(components)) {
|
66
66
|
if (components.filter((component) => Object.hasOwnProperty.call(component, 'components'))) {
|
67
67
|
components
|
68
68
|
.filter((component) => Object.hasOwnProperty.call(component, 'components'))
|
69
69
|
.forEach((comp) => {
|
70
|
-
this.
|
70
|
+
this.handleAddressChange(comp.components, value);
|
71
71
|
});
|
72
72
|
}
|
73
73
|
components
|
@@ -93,12 +93,7 @@ export class FormFieldComponent extends ReactComponent {
|
|
93
93
|
else {
|
94
94
|
selectedValue = value.line1;
|
95
95
|
label = value.line1;
|
96
|
-
this.
|
97
|
-
this.root.components
|
98
|
-
.filter((component) => Object.prototype.hasOwnProperty.call(component, 'components'))
|
99
|
-
.forEach((section) => {
|
100
|
-
this.handleComponentChange(section.components, value);
|
101
|
-
});
|
96
|
+
this.handleAddressChange(this.root.components, value);
|
102
97
|
}
|
103
98
|
}
|
104
99
|
else if (this.component.property.type === 'choices' || this.component.property.type === 'array') {
|
@@ -152,7 +147,9 @@ export class FormFieldComponent extends ReactComponent {
|
|
152
147
|
this.on('changed-' + this.component.key, (value) => {
|
153
148
|
this.setValue(value ?? '');
|
154
149
|
this.updateValue(value, { modified: true });
|
155
|
-
|
150
|
+
if (this.element) {
|
151
|
+
this.attach(this.element);
|
152
|
+
}
|
156
153
|
});
|
157
154
|
}
|
158
155
|
if (this.component.type === 'Date') {
|
@@ -465,6 +462,6 @@ export class FormFieldComponent extends ReactComponent {
|
|
465
462
|
falsePositiveMaskError &&
|
466
463
|
isEmpty(this.errorDetails) &&
|
467
464
|
this.emit('changed-' + this.component.key, e.target.value);
|
468
|
-
}, ...this.component, id: inputId, defaultValue: this.dataValue, mask: this.component.inputMask, error: this.hasErrors(), size: this.component.fieldHeight ?? 'medium' }))), root);
|
465
|
+
}, ...this.component, id: inputId, defaultValue: this.dataValue, mask: this.component.inputMask, error: this.hasErrors(), size: this.component.fieldHeight ?? 'medium', required: this.component.validate?.required }))), root);
|
469
466
|
}
|
470
467
|
}
|
@@ -41,7 +41,7 @@ export const RelatedObjectInstance = (props) => {
|
|
41
41
|
handleClose();
|
42
42
|
setErrors([]);
|
43
43
|
};
|
44
|
-
const createNewInstance = async (submission) => {
|
44
|
+
const createNewInstance = async (submission, setSubmitting) => {
|
45
45
|
if (!relatedObject) {
|
46
46
|
// Handle the case where relatedObject is undefined
|
47
47
|
return { isSuccessful: false };
|
@@ -74,12 +74,12 @@ export const RelatedObjectInstance = (props) => {
|
|
74
74
|
setSnackbarError({
|
75
75
|
showAlert: true,
|
76
76
|
message: err.response?.data?.error?.details?.[0]?.message ??
|
77
|
-
err.data?.error?.message ??
|
77
|
+
err.response?.data?.error?.message ??
|
78
78
|
`An error occurred. The new instance was not created.`,
|
79
79
|
isError: true,
|
80
80
|
});
|
81
81
|
error = err.response?.data?.error;
|
82
|
-
|
82
|
+
setSubmitting && setSubmitting(false);
|
83
83
|
}
|
84
84
|
return { isSuccessful, error };
|
85
85
|
};
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { ApiServices, ObjectInstance } from '@evoke-platform/context';
|
2
|
+
import React from 'react';
|
3
|
+
export type DocumentViewerCellProps = {
|
4
|
+
instance: ObjectInstance;
|
5
|
+
propertyId: string;
|
6
|
+
apiServices: ApiServices;
|
7
|
+
setSnackbarError: (error: {
|
8
|
+
showAlert: boolean;
|
9
|
+
message?: string;
|
10
|
+
isError?: boolean;
|
11
|
+
}) => void;
|
12
|
+
};
|
13
|
+
export declare const DocumentViewerCell: (props: DocumentViewerCellProps) => React.JSX.Element;
|