@evoke-platform/ui-components 1.6.0-dev.3 → 1.6.0-dev.30
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/SwipeableDrawer/SwipeableDrawer.d.ts +4 -0
- package/dist/published/components/core/SwipeableDrawer/SwipeableDrawer.js +8 -0
- package/dist/published/components/core/SwipeableDrawer/index.d.ts +3 -0
- package/dist/published/components/core/SwipeableDrawer/index.js +3 -0
- package/dist/published/components/core/index.d.ts +1 -0
- package/dist/published/components/core/index.js +1 -0
- package/dist/published/components/custom/CriteriaBuilder/CriteriaBuilder.js +1 -1
- package/dist/published/components/custom/Form/FormComponents/DocumentComponent/Document.d.ts +1 -0
- package/dist/published/components/custom/Form/FormComponents/DocumentComponent/Document.js +45 -5
- package/dist/published/components/custom/Form/FormComponents/DocumentComponent/DocumentComponent.d.ts +1 -0
- package/dist/published/components/custom/Form/FormComponents/DocumentComponent/DocumentComponent.js +8 -1
- package/dist/published/components/custom/Form/FormComponents/ImageComponent/Image.js +2 -2
- package/dist/published/components/custom/Form/FormComponents/RepeatableFieldComponent/RepeatableField.js +87 -57
- package/dist/published/components/custom/Form/tests/Form.test.js +1 -1
- package/dist/published/components/custom/Form/utils.js +6 -0
- package/dist/published/components/custom/FormField/AddressFieldComponent/addressFieldComponent.js +1 -1
- package/dist/published/components/custom/FormField/BooleanSelect/BooleanSelect.js +3 -3
- package/dist/published/components/custom/FormField/DatePickerSelect/DatePickerSelect.js +7 -1
- package/dist/published/components/custom/FormField/DateTimePickerSelect/DateTimePickerSelect.js +7 -1
- package/dist/published/components/custom/FormField/InputFieldComponent/InputFieldComponent.js +6 -3
- package/dist/published/components/custom/FormField/Select/Select.js +17 -5
- package/dist/published/components/custom/FormField/TimePickerSelect/TimePickerSelect.js +13 -3
- package/dist/published/components/custom/FormV2/FormRenderer.d.ts +19 -0
- package/dist/published/components/custom/FormV2/FormRenderer.js +183 -0
- package/dist/published/components/custom/FormV2/components/AccordionSections.d.ts +4 -0
- package/dist/published/components/custom/FormV2/components/AccordionSections.js +131 -0
- package/dist/published/components/custom/FormV2/components/ActionButtons.d.ts +19 -0
- package/dist/published/components/custom/FormV2/components/ActionButtons.js +106 -0
- package/dist/published/components/custom/FormV2/components/FieldWrapper.d.ts +24 -0
- package/dist/published/components/custom/FormV2/components/FieldWrapper.js +100 -0
- package/dist/published/components/custom/FormV2/components/FormContext.d.ts +12 -0
- package/dist/published/components/custom/FormV2/components/FormContext.js +8 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/AddressFields.d.ts +17 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/AddressFields.js +50 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/CollectionFiles/ActionDialog.d.ts +14 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/CollectionFiles/ActionDialog.js +88 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/CollectionFiles/DocumentViewerCell.d.ts +13 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/CollectionFiles/DocumentViewerCell.js +140 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/CollectionFiles/DropdownRepeatableField.d.ts +17 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/CollectionFiles/DropdownRepeatableField.js +233 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/CollectionFiles/DropdownRepeatableFieldInput.d.ts +40 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/CollectionFiles/DropdownRepeatableFieldInput.js +95 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/CollectionFiles/RepeatableField.d.ts +12 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/CollectionFiles/RepeatableField.js +526 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/Criteria.d.ts +12 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/Criteria.js +93 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/DocumentFiles/Document.d.ts +16 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/DocumentFiles/Document.js +113 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/DocumentFiles/DocumentList.d.ts +13 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/DocumentFiles/DocumentList.js +179 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/Image.d.ts +12 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/Image.js +108 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/UserProperty.d.ts +16 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/UserProperty.js +129 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/relatedObjectFiles/InstanceLookup.d.ts +15 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/relatedObjectFiles/InstanceLookup.js +226 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/relatedObjectFiles/ObjectPropertyInput.d.ts +4 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/relatedObjectFiles/ObjectPropertyInput.js +439 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/relatedObjectFiles/RelatedObjectInstance.d.ts +29 -0
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/relatedObjectFiles/RelatedObjectInstance.js +74 -0
- package/dist/published/components/custom/FormV2/components/FormSections.d.ts +4 -0
- package/dist/published/components/custom/FormV2/components/FormSections.js +104 -0
- package/dist/published/components/custom/FormV2/components/RecursiveEntryRenderer.d.ts +2 -0
- package/dist/published/components/custom/FormV2/components/RecursiveEntryRenderer.js +209 -0
- package/dist/published/components/custom/FormV2/components/TabNav.d.ts +10 -0
- package/dist/published/components/custom/FormV2/components/TabNav.js +23 -0
- package/dist/published/components/custom/FormV2/components/ValidationFiles/Validation.d.ts +3 -0
- package/dist/published/components/custom/FormV2/components/ValidationFiles/Validation.js +176 -0
- package/dist/published/components/custom/FormV2/components/ValidationFiles/ValidationErrorDisplay.d.ts +10 -0
- package/dist/published/components/custom/FormV2/components/ValidationFiles/ValidationErrorDisplay.js +45 -0
- package/dist/published/components/custom/FormV2/components/types.d.ts +122 -0
- package/dist/published/components/custom/FormV2/components/types.js +1 -0
- package/dist/published/components/custom/FormV2/components/utils.d.ts +47 -0
- package/dist/published/components/custom/FormV2/components/utils.js +434 -0
- package/dist/published/components/custom/FormV2/index.d.ts +1 -0
- package/dist/published/components/custom/FormV2/index.js +1 -0
- package/dist/published/components/custom/HistoryLog/HistoryData.d.ts +1 -0
- package/dist/published/components/custom/HistoryLog/HistoryData.js +14 -6
- package/dist/published/components/custom/HistoryLog/HistoryLoading.d.ts +4 -1
- package/dist/published/components/custom/HistoryLog/HistoryLoading.js +14 -8
- package/dist/published/components/custom/HistoryLog/index.d.ts +2 -0
- package/dist/published/components/custom/HistoryLog/index.js +4 -4
- package/dist/published/components/custom/ResponsiveOverflow/ResponsiveOverflow.d.ts +33 -0
- package/dist/published/components/custom/ResponsiveOverflow/ResponsiveOverflow.js +140 -0
- package/dist/published/components/custom/ResponsiveOverflow/ResponsiveOverflow.test.d.ts +1 -0
- package/dist/published/components/custom/ResponsiveOverflow/ResponsiveOverflow.test.js +100 -0
- package/dist/published/components/custom/ResponsiveOverflow/index.d.ts +4 -0
- package/dist/published/components/custom/ResponsiveOverflow/index.js +3 -0
- package/dist/published/components/custom/index.d.ts +2 -0
- package/dist/published/components/custom/index.js +2 -0
- package/dist/published/components/custom/util.d.ts +1 -0
- package/dist/published/components/custom/util.js +28 -0
- package/dist/published/index.d.ts +1 -1
- package/dist/published/index.js +1 -1
- package/dist/published/stories/ResponsiveOverflow.stories.d.ts +8 -0
- package/dist/published/stories/ResponsiveOverflow.stories.js +91 -0
- package/dist/published/theme/hooks.d.ts +7 -0
- package/dist/published/theme/hooks.js +9 -0
- package/package.json +6 -2
|
@@ -0,0 +1,439 @@
|
|
|
1
|
+
import { useApiServices, useApp, useNavigate, } from '@evoke-platform/context';
|
|
2
|
+
import cleanDeep from 'clean-deep';
|
|
3
|
+
import { cloneDeep, debounce, isEmpty, isNil } from 'lodash';
|
|
4
|
+
import Handlebars from 'no-eval-handlebars';
|
|
5
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
6
|
+
import { Close } from '../../../../../../icons';
|
|
7
|
+
import { useFormContext } from '../../../../../../theme/hooks';
|
|
8
|
+
import { Autocomplete, Button, Dialog, IconButton, Link, Paper, Snackbar, TextField, Tooltip, Typography, } from '../../../../../core';
|
|
9
|
+
import { Box } from '../../../../../layout';
|
|
10
|
+
import { encodePageSlug, getDefaultPages, getPrefixedUrl, transformToWhere } from '../../utils';
|
|
11
|
+
import RelatedObjectInstance from './RelatedObjectInstance';
|
|
12
|
+
const ObjectPropertyInput = (props) => {
|
|
13
|
+
const { id, instance, fieldDefinition, handleChangeObjectProperty, nestedFieldsView, readOnly, error, mode, parameters, displayOption, filter, defaultValueCriteria, sortBy, orderBy, isModal, initialValue, fieldHeight, richTextEditor, viewLayout, hasDescription, } = props;
|
|
14
|
+
const { fetchedOptions, setFetchedOptions } = useFormContext();
|
|
15
|
+
const { defaultPages, findDefaultPageSlugFor } = useApp();
|
|
16
|
+
const [selectedInstance, setSelectedInstance] = useState(initialValue || undefined);
|
|
17
|
+
const [openCreateDialog, setOpenCreateDialog] = useState(false);
|
|
18
|
+
const [allDefaultPages, setAllDefaultPages] = useState(defaultPages ?? {});
|
|
19
|
+
const [loadingOptions, setLoadingOptions] = useState(false);
|
|
20
|
+
const [navigationSlug, setNavigationSlug] = useState(fetchedOptions[`${id}NavigationSlug`]);
|
|
21
|
+
const [relatedObject, setRelatedObject] = useState(fetchedOptions[`${id}RelatedObject`]);
|
|
22
|
+
const [dropdownInput, setDropdownInput] = useState();
|
|
23
|
+
const [openOptions, setOpenOptions] = useState(false);
|
|
24
|
+
const [hasFetched, setHasFetched] = useState(fetchedOptions[`${id}OptionsHaveFetched`] || false);
|
|
25
|
+
const [options, setOptions] = useState(fetchedOptions[`${id}Options`] || []);
|
|
26
|
+
const [layout, setLayout] = useState();
|
|
27
|
+
const [appId, setAppId] = useState(fetchedOptions[`${id}AppId`]);
|
|
28
|
+
const [form, setForm] = useState();
|
|
29
|
+
const [snackbarError, setSnackbarError] = useState({
|
|
30
|
+
showAlert: false,
|
|
31
|
+
isError: true,
|
|
32
|
+
});
|
|
33
|
+
const DEFAULT_CREATE_ACTION = '_create';
|
|
34
|
+
const action = relatedObject?.actions?.find((action) => action.id === DEFAULT_CREATE_ACTION);
|
|
35
|
+
const apiServices = useApiServices();
|
|
36
|
+
const navigateTo = useNavigate();
|
|
37
|
+
const updatedCriteria = filter
|
|
38
|
+
? {
|
|
39
|
+
where: transformToWhere(filter),
|
|
40
|
+
}
|
|
41
|
+
: undefined;
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
if (relatedObject) {
|
|
44
|
+
let defaultViewLayout;
|
|
45
|
+
if (relatedObject?.viewLayout?.dropdown && displayOption === 'dropdown') {
|
|
46
|
+
defaultViewLayout = {
|
|
47
|
+
id: 'default',
|
|
48
|
+
name: 'Default',
|
|
49
|
+
objectId: relatedObject.id,
|
|
50
|
+
...relatedObject.viewLayout.dropdown,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
else if (relatedObject?.viewLayout?.table && displayOption === 'dialogBox') {
|
|
54
|
+
defaultViewLayout = {
|
|
55
|
+
id: 'default',
|
|
56
|
+
name: 'Default',
|
|
57
|
+
objectId: relatedObject.id,
|
|
58
|
+
...relatedObject.viewLayout.table,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
if (viewLayout) {
|
|
62
|
+
apiServices
|
|
63
|
+
.get(getPrefixedUrl(`/objects/${viewLayout.objectId}/${displayOption === 'dropdown' ? 'dropdown' : 'table'}Layouts/${viewLayout.id}`))
|
|
64
|
+
.then(setLayout)
|
|
65
|
+
.catch((err) => setLayout(defaultViewLayout));
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
setLayout(defaultViewLayout);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}, [displayOption, relatedObject, viewLayout]);
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
// setting the default value when there is default criteria
|
|
74
|
+
if (!isEmpty(defaultValueCriteria) && !selectedInstance && (!instance || !instance[id])) {
|
|
75
|
+
const updatedFilter = cleanDeep({
|
|
76
|
+
where: transformToWhere({ $and: [defaultValueCriteria, updatedCriteria?.where ?? {}] }),
|
|
77
|
+
order: orderBy && sortBy ? encodeURIComponent(sortBy + ' ' + orderBy) : undefined,
|
|
78
|
+
limit: 1,
|
|
79
|
+
});
|
|
80
|
+
if (updatedFilter.where) {
|
|
81
|
+
setLoadingOptions(true);
|
|
82
|
+
apiServices.get(getPrefixedUrl(`/objects/${fieldDefinition.objectId}/instances?filter=${encodeURIComponent(JSON.stringify(updatedFilter))}`), (error, instances) => {
|
|
83
|
+
if (error) {
|
|
84
|
+
console.error(error);
|
|
85
|
+
setLoadingOptions(false);
|
|
86
|
+
}
|
|
87
|
+
if (instances && instances.length > 0) {
|
|
88
|
+
setSelectedInstance(instances[0]);
|
|
89
|
+
handleChangeObjectProperty(id, instances[0]);
|
|
90
|
+
}
|
|
91
|
+
setLoadingOptions(false);
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}, [fieldDefinition, defaultValueCriteria, sortBy, orderBy]);
|
|
96
|
+
const getDropdownOptions = useCallback((name) => {
|
|
97
|
+
if ((!fetchedOptions[`${id}Options`] ||
|
|
98
|
+
fetchedOptions[`${id}Options`].length === 0) &&
|
|
99
|
+
!hasFetched) {
|
|
100
|
+
setLoadingOptions(true);
|
|
101
|
+
const updatedFilter = cloneDeep(updatedCriteria) || {};
|
|
102
|
+
updatedFilter.limit = 100;
|
|
103
|
+
const { propertyId, direction } = layout?.sort ?? {
|
|
104
|
+
propertyId: 'name',
|
|
105
|
+
direction: 'asc',
|
|
106
|
+
};
|
|
107
|
+
updatedFilter.order = `${propertyId} ${direction}`;
|
|
108
|
+
const where = name
|
|
109
|
+
? transformToWhere({
|
|
110
|
+
name: {
|
|
111
|
+
like: name,
|
|
112
|
+
options: 'i',
|
|
113
|
+
},
|
|
114
|
+
})
|
|
115
|
+
: {};
|
|
116
|
+
updatedFilter.where = updatedFilter.where
|
|
117
|
+
? {
|
|
118
|
+
and: [updatedFilter.where, where],
|
|
119
|
+
}
|
|
120
|
+
: where;
|
|
121
|
+
apiServices.get(getPrefixedUrl(`/objects/${fieldDefinition.objectId}/instances?filter=${JSON.stringify(updatedFilter)}`), (error, instances) => {
|
|
122
|
+
if (error) {
|
|
123
|
+
console.error(error);
|
|
124
|
+
setLoadingOptions(false);
|
|
125
|
+
}
|
|
126
|
+
if (instances) {
|
|
127
|
+
setOptions(instances);
|
|
128
|
+
setLoadingOptions(false);
|
|
129
|
+
// so if you go off a section too quickly and it doesn't fetch it re-fetches but doesn't cause an infinite loop
|
|
130
|
+
setHasFetched(true);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
}, [relatedObject, setLoadingOptions, setOptions, fieldDefinition, updatedCriteria, layout]);
|
|
135
|
+
useEffect(() => {
|
|
136
|
+
if (displayOption === 'dropdown') {
|
|
137
|
+
getDropdownOptions();
|
|
138
|
+
}
|
|
139
|
+
}, [fieldDefinition, updatedCriteria, displayOption]);
|
|
140
|
+
useEffect(() => {
|
|
141
|
+
setSelectedInstance(initialValue);
|
|
142
|
+
}, [initialValue]);
|
|
143
|
+
const debouncedGetDropdownOptions = useCallback(debounce(getDropdownOptions, 200), [updatedCriteria]);
|
|
144
|
+
useEffect(() => {
|
|
145
|
+
debouncedGetDropdownOptions(dropdownInput);
|
|
146
|
+
return () => debouncedGetDropdownOptions.cancel();
|
|
147
|
+
}, [dropdownInput]);
|
|
148
|
+
useEffect(() => {
|
|
149
|
+
if (action?.defaultFormId) {
|
|
150
|
+
apiServices
|
|
151
|
+
.get(getPrefixedUrl(`data/forms/${action.defaultFormId}`))
|
|
152
|
+
.then((evokeForm) => {
|
|
153
|
+
setForm(evokeForm);
|
|
154
|
+
})
|
|
155
|
+
.catch((error) => {
|
|
156
|
+
console.error('Error fetching form:', error);
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
}, [action]);
|
|
160
|
+
useEffect(() => {
|
|
161
|
+
if (!fetchedOptions[`${id}RelatedObject`]) {
|
|
162
|
+
apiServices.get(getPrefixedUrl(`/objects/${fieldDefinition.objectId}/effective?sanitizedVersion=true`), (error, object) => {
|
|
163
|
+
if (error) {
|
|
164
|
+
console.error(error);
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
setRelatedObject(object);
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
}, [fieldDefinition]);
|
|
172
|
+
useEffect(() => {
|
|
173
|
+
const fetchDefaultPages = async () => {
|
|
174
|
+
if (parameters) {
|
|
175
|
+
const pages = await getDefaultPages(parameters, defaultPages, findDefaultPageSlugFor);
|
|
176
|
+
setAllDefaultPages(pages);
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
fetchDefaultPages();
|
|
180
|
+
}, []);
|
|
181
|
+
useEffect(() => {
|
|
182
|
+
if (fieldDefinition.objectId &&
|
|
183
|
+
allDefaultPages &&
|
|
184
|
+
allDefaultPages[fieldDefinition.objectId] &&
|
|
185
|
+
(!fetchedOptions?.[`${id}NavigationSlug`] || !fetchedOptions[`${id}AppId`])) {
|
|
186
|
+
apiServices.get(getPrefixedUrl(`/apps/${allDefaultPages[fieldDefinition.objectId].split('/').slice(1, 2)}/pages/${encodePageSlug(allDefaultPages[fieldDefinition.objectId].split('/').slice(2).join('/'))}`), (error, page) => {
|
|
187
|
+
if (error) {
|
|
188
|
+
console.error(error);
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
setAppId(page?.appId);
|
|
192
|
+
setNavigationSlug(page?.slug);
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
}, []);
|
|
197
|
+
const handleClose = () => {
|
|
198
|
+
setOpenCreateDialog(false);
|
|
199
|
+
};
|
|
200
|
+
const compileExpression = (expression, instance) => {
|
|
201
|
+
const template = Handlebars.compileAST(expression);
|
|
202
|
+
return instance ? template(instance) : undefined;
|
|
203
|
+
};
|
|
204
|
+
useEffect(() => {
|
|
205
|
+
if (relatedObject && !fetchedOptions[`${id}RelatedObject`]) {
|
|
206
|
+
setFetchedOptions({
|
|
207
|
+
[`${id}RelatedObject`]: relatedObject,
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
if (options &&
|
|
211
|
+
(!fetchedOptions[`${id}Options`] || fetchedOptions[`${id}Options`].length === 0) &&
|
|
212
|
+
hasFetched &&
|
|
213
|
+
!fetchedOptions[`${id}OptionsHaveFetched`]) {
|
|
214
|
+
setFetchedOptions({
|
|
215
|
+
[`${id}Options`]: options,
|
|
216
|
+
[`${id}OptionsHaveFetched`]: hasFetched,
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
if (navigationSlug && !fetchedOptions[`${id}NavigationSlug`]) {
|
|
220
|
+
setFetchedOptions({
|
|
221
|
+
[`${id}NavigationSlug`]: navigationSlug,
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
}, [relatedObject, options, hasFetched]);
|
|
225
|
+
return (React.createElement(React.Fragment, null,
|
|
226
|
+
displayOption === 'dropdown' ? (React.createElement(React.Fragment, null,
|
|
227
|
+
React.createElement(Autocomplete, { id: id, fullWidth: true, sortBy: "NONE", open: openOptions, size: fieldHeight, componentsProps: {
|
|
228
|
+
popper: {
|
|
229
|
+
modifiers: [
|
|
230
|
+
{
|
|
231
|
+
name: 'flip',
|
|
232
|
+
enabled: false,
|
|
233
|
+
},
|
|
234
|
+
],
|
|
235
|
+
},
|
|
236
|
+
}, PaperComponent: ({ children }) => {
|
|
237
|
+
return (React.createElement(Paper, { sx: {
|
|
238
|
+
borderRadius: '12px',
|
|
239
|
+
boxShadow: '0px 24px 48px 0px rgba(145, 158, 171, 0.2)',
|
|
240
|
+
'& .MuiAutocomplete-listbox': {
|
|
241
|
+
maxHeight: '25vh',
|
|
242
|
+
},
|
|
243
|
+
'& .MuiAutocomplete-noOptions': {
|
|
244
|
+
fontFamily: 'sans-serif',
|
|
245
|
+
fontSize: '14px',
|
|
246
|
+
paddingLeft: '24px',
|
|
247
|
+
color: 'rgba(145, 158, 171, 1)',
|
|
248
|
+
},
|
|
249
|
+
'& .MuiAutocomplete-loading': {
|
|
250
|
+
fontFamily: 'sans-serif',
|
|
251
|
+
fontSize: '14px',
|
|
252
|
+
paddingLeft: '24px',
|
|
253
|
+
color: 'rgba(145, 158, 171, 1)',
|
|
254
|
+
},
|
|
255
|
+
} },
|
|
256
|
+
mode !== 'newOnly' && children,
|
|
257
|
+
mode !== 'existingOnly' && form && (React.createElement(Button, { fullWidth: true, sx: {
|
|
258
|
+
justifyContent: 'flex-start',
|
|
259
|
+
pl: 2,
|
|
260
|
+
minHeight: '48px',
|
|
261
|
+
borderTop: '1px solid rgba(145, 158, 171, 0.24)',
|
|
262
|
+
borderRadius: '0p 0pc 6px 6px',
|
|
263
|
+
paddingLeft: '22px',
|
|
264
|
+
fontWeight: 400,
|
|
265
|
+
}, onMouseDown: (e) => {
|
|
266
|
+
setOpenCreateDialog(true);
|
|
267
|
+
}, color: 'inherit' }, "+ Add New"))));
|
|
268
|
+
}, sx: {
|
|
269
|
+
'& button.MuiButtonBase-root': {
|
|
270
|
+
...(!loadingOptions &&
|
|
271
|
+
(instance?.[id]?.id || selectedInstance?.id)
|
|
272
|
+
? {
|
|
273
|
+
visibility: 'visible',
|
|
274
|
+
}
|
|
275
|
+
: {}),
|
|
276
|
+
},
|
|
277
|
+
backgroundColor: 'white', // prevents the field flickering gray when loading in the value and options when it's a read only
|
|
278
|
+
}, noOptionsText: 'No options available', renderOption: (props, option) => {
|
|
279
|
+
return (React.createElement("li", { ...props, key: option.id },
|
|
280
|
+
React.createElement(Box, null,
|
|
281
|
+
React.createElement(Typography, { sx: { marginLeft: '8px', fontSize: '14px' } }, option.label),
|
|
282
|
+
layout?.secondaryTextExpression ? (React.createElement(Typography, { sx: { marginLeft: '8px', fontSize: '14px', color: '#637381' } }, compileExpression(layout?.secondaryTextExpression, options.find((o) => o.id === option.value)))) : null)));
|
|
283
|
+
}, onOpen: () => {
|
|
284
|
+
if (instance?.[id]?.id || selectedInstance?.id) {
|
|
285
|
+
setOpenOptions(false);
|
|
286
|
+
}
|
|
287
|
+
else {
|
|
288
|
+
setOpenOptions(true);
|
|
289
|
+
}
|
|
290
|
+
}, onClose: () => setOpenOptions(false), value: selectedInstance?.id
|
|
291
|
+
? {
|
|
292
|
+
value: selectedInstance?.id ?? '',
|
|
293
|
+
label: selectedInstance?.name ?? '',
|
|
294
|
+
}
|
|
295
|
+
: null, isOptionEqualToValue: (option, value) => {
|
|
296
|
+
if (typeof value === 'string') {
|
|
297
|
+
return option.value === value;
|
|
298
|
+
}
|
|
299
|
+
return option.value === value?.value;
|
|
300
|
+
}, options: options.map((o) => ({ label: o.name, value: o.id })), getOptionLabel: (option) => {
|
|
301
|
+
return typeof option === 'string'
|
|
302
|
+
? (options.find((o) => o.id === option)?.name ?? '')
|
|
303
|
+
: option.label;
|
|
304
|
+
}, onKeyDownCapture: (e) => {
|
|
305
|
+
// prevents keyboard trap
|
|
306
|
+
if (e.key === 'Tab') {
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
if (selectedInstance?.id) {
|
|
310
|
+
e.preventDefault();
|
|
311
|
+
}
|
|
312
|
+
}, loading: loadingOptions, onChange: (event, value) => {
|
|
313
|
+
if (isNil(value)) {
|
|
314
|
+
setDropdownInput(undefined);
|
|
315
|
+
setSelectedInstance(undefined);
|
|
316
|
+
handleChangeObjectProperty(id, null);
|
|
317
|
+
}
|
|
318
|
+
else {
|
|
319
|
+
const selectedInstance = options.find((o) => o.id === value?.value);
|
|
320
|
+
setSelectedInstance(selectedInstance);
|
|
321
|
+
handleChangeObjectProperty(id, selectedInstance);
|
|
322
|
+
}
|
|
323
|
+
}, selectOnFocus: false, onBlur: () => setDropdownInput(undefined), renderInput: (params) => (React.createElement(TextField, { ...params, placeholder: selectedInstance?.id || readOnly ? '' : 'Select', readOnly: !loadingOptions && !selectedInstance?.id && readOnly, onChange: (event) => setDropdownInput(event.target.value), onClick: (e) => {
|
|
324
|
+
if (openOptions &&
|
|
325
|
+
e.target?.nodeName === 'svg') {
|
|
326
|
+
setOpenOptions(false);
|
|
327
|
+
}
|
|
328
|
+
else {
|
|
329
|
+
setOptions(options);
|
|
330
|
+
setOpenOptions(true);
|
|
331
|
+
}
|
|
332
|
+
}, sx: {
|
|
333
|
+
...(!loadingOptions && selectedInstance?.id
|
|
334
|
+
? {
|
|
335
|
+
'.MuiOutlinedInput-root': {
|
|
336
|
+
background: 'white',
|
|
337
|
+
border: 'auto',
|
|
338
|
+
'.MuiOutlinedInput-input': {
|
|
339
|
+
...(navigationSlug
|
|
340
|
+
? {
|
|
341
|
+
color: 'rgb(1, 78, 123)',
|
|
342
|
+
textDecoration: 'underline',
|
|
343
|
+
cursor: 'pointer',
|
|
344
|
+
}
|
|
345
|
+
: {}),
|
|
346
|
+
},
|
|
347
|
+
},
|
|
348
|
+
'& fieldset': {
|
|
349
|
+
border: readOnly ? 'none' : 'auto',
|
|
350
|
+
borderColor: 'auto',
|
|
351
|
+
},
|
|
352
|
+
'&:hover .MuiOutlinedInput-notchedOutline': {
|
|
353
|
+
border: 'auto',
|
|
354
|
+
},
|
|
355
|
+
'& svg': {
|
|
356
|
+
display: readOnly ? 'none' : 'block',
|
|
357
|
+
},
|
|
358
|
+
caretColor: 'white',
|
|
359
|
+
}
|
|
360
|
+
: {}),
|
|
361
|
+
}, InputProps: {
|
|
362
|
+
...params.InputProps,
|
|
363
|
+
startAdornment: selectedInstance?.id ? (React.createElement(Typography, { onClick: (e) => {
|
|
364
|
+
if (navigationSlug && selectedInstance?.id) {
|
|
365
|
+
navigateTo(`/${appId}/${navigationSlug.replace(':instanceId', selectedInstance.id)}`);
|
|
366
|
+
}
|
|
367
|
+
}, sx: {
|
|
368
|
+
cursor: navigationSlug ? 'pointer' : 'default',
|
|
369
|
+
color: navigationSlug ? 'rgb(1, 78, 123)' : 'inherit',
|
|
370
|
+
textDecoration: navigationSlug ? 'underline' : 'none',
|
|
371
|
+
paddingLeft: '5px',
|
|
372
|
+
} }, selectedInstance?.name || '')) : null,
|
|
373
|
+
}, inputProps: {
|
|
374
|
+
...params.inputProps,
|
|
375
|
+
value: selectedInstance?.id ? '' : params.inputProps.value,
|
|
376
|
+
...(hasDescription ? { 'aria-describedby': `${id}-description` } : undefined),
|
|
377
|
+
} })), readOnly: readOnly, error: error }))) : (React.createElement(Box, { sx: {
|
|
378
|
+
padding: selectedInstance?.name ? '16.5px 14px' : '10.5px 0',
|
|
379
|
+
} },
|
|
380
|
+
(selectedInstance?.name || readOnly) && (React.createElement(Link, { sx: {
|
|
381
|
+
textDecoration: 'none',
|
|
382
|
+
marginRight: 1,
|
|
383
|
+
textDecorationLine: navigationSlug && instance?.[id] && !isModal ? 'underline' : 'none',
|
|
384
|
+
cursor: navigationSlug && instance?.[id] && !isModal ? 'pointer' : 'auto',
|
|
385
|
+
fontSize: '16px',
|
|
386
|
+
fontWeight: 400,
|
|
387
|
+
lineHeight: '24px',
|
|
388
|
+
textAlign: 'left',
|
|
389
|
+
color: navigationSlug && instance?.[id] && !isModal
|
|
390
|
+
? '#0075A7'
|
|
391
|
+
: !selectedInstance?.id
|
|
392
|
+
? '#999'
|
|
393
|
+
: '#212B36',
|
|
394
|
+
}, variant: "body2", href: navigationSlug && !isModal
|
|
395
|
+
? `${'/app'}/${appId}/${navigationSlug.replace(':instanceId', selectedInstance?.id ?? '')}`
|
|
396
|
+
: undefined, "aria-label": selectedInstance?.name }, selectedInstance?.name ? selectedInstance?.name : readOnly && 'None')),
|
|
397
|
+
!readOnly && (selectedInstance || (nestedFieldsView && instance?.id)) ? (React.createElement(Tooltip, { title: `Unlink` },
|
|
398
|
+
React.createElement("span", null,
|
|
399
|
+
React.createElement(IconButton, { onClick: (event) => {
|
|
400
|
+
event.stopPropagation();
|
|
401
|
+
handleChangeObjectProperty(id, null);
|
|
402
|
+
setSelectedInstance(undefined);
|
|
403
|
+
}, sx: { p: 0, marginBottom: '4px' }, "aria-label": `Unlink` },
|
|
404
|
+
React.createElement(Close, { sx: { width: '20px', height: '20px' } }))))) : (React.createElement(Button, { sx: {
|
|
405
|
+
backgroundColor: '#DFE3E8',
|
|
406
|
+
color: '#212B36',
|
|
407
|
+
fontWeight: '700',
|
|
408
|
+
textTransform: 'capitalize',
|
|
409
|
+
'&:hover': {
|
|
410
|
+
backgroundColor: '#e6eaf0',
|
|
411
|
+
boxShadow: 'none',
|
|
412
|
+
},
|
|
413
|
+
'&:disabled': {
|
|
414
|
+
cursor: 'not-allowed',
|
|
415
|
+
pointerEvents: 'all',
|
|
416
|
+
},
|
|
417
|
+
boxShadow: 'none',
|
|
418
|
+
lineHeight: '2.75',
|
|
419
|
+
padding: '0 23px',
|
|
420
|
+
display: readOnly ? 'none' : 'block',
|
|
421
|
+
}, size: "small", variant: "contained", disableElevation: true, onClick: (event) => {
|
|
422
|
+
event.stopPropagation();
|
|
423
|
+
setOpenCreateDialog(true);
|
|
424
|
+
}, "aria-label": `Add` }, "Add")))),
|
|
425
|
+
openCreateDialog && (React.createElement(React.Fragment, null, nestedFieldsView ? (React.createElement(RelatedObjectInstance, { id: id, handleClose: handleClose, handleChangeObjectProperty: handleChangeObjectProperty, setSelectedInstance: setSelectedInstance, relatedObject: relatedObject, nestedFieldsView: nestedFieldsView, mode: mode, displayOption: displayOption, setOptions: setOptions, options: options, filter: updatedCriteria, layout: layout, fieldHeight: fieldHeight, richTextEditor: richTextEditor, form: form, action: action, setSnackbarError: setSnackbarError, selectedInstance: selectedInstance })) : (React.createElement(Dialog, { fullWidth: true, maxWidth: "md", open: openCreateDialog, onClose: (e, reason) => reason !== 'backdropClick' && handleClose },
|
|
426
|
+
React.createElement(Typography, { sx: {
|
|
427
|
+
marginTop: '28px',
|
|
428
|
+
fontSize: '22px',
|
|
429
|
+
fontWeight: 700,
|
|
430
|
+
marginLeft: '24px',
|
|
431
|
+
marginBottom: '10px',
|
|
432
|
+
} }, `Add ${fieldDefinition.name}`),
|
|
433
|
+
React.createElement(RelatedObjectInstance, { handleClose: handleClose, handleChangeObjectProperty: handleChangeObjectProperty, setSelectedInstance: setSelectedInstance, nestedFieldsView: nestedFieldsView, relatedObject: relatedObject, id: id, mode: mode, displayOption: displayOption, setOptions: setOptions, options: options, filter: updatedCriteria, layout: layout, fieldHeight: fieldHeight, richTextEditor: richTextEditor, form: form, action: action, setSnackbarError: setSnackbarError, selectedInstance: selectedInstance }))))),
|
|
434
|
+
React.createElement(Snackbar, { open: snackbarError.showAlert, handleClose: () => setSnackbarError({
|
|
435
|
+
isError: snackbarError.isError,
|
|
436
|
+
showAlert: false,
|
|
437
|
+
}), message: snackbarError.message, error: snackbarError.isError })));
|
|
438
|
+
};
|
|
439
|
+
export default ObjectPropertyInput;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Action, EvokeForm, Obj, ObjectInstance, TableViewLayout } from '@evoke-platform/context';
|
|
2
|
+
import React, { ComponentType } from 'react';
|
|
3
|
+
import { BaseProps, SimpleEditorProps } from '../../types';
|
|
4
|
+
export type RelatedObjectInstanceProps = BaseProps & {
|
|
5
|
+
relatedObject: Obj | undefined;
|
|
6
|
+
id: string;
|
|
7
|
+
setSelectedInstance: (selectedInstance: ObjectInstance) => void;
|
|
8
|
+
handleChangeObjectProperty: (propertyId: string, instance?: any) => void;
|
|
9
|
+
handleClose: () => void;
|
|
10
|
+
mode: 'default' | 'existingOnly' | 'newOnly';
|
|
11
|
+
setSnackbarError: React.Dispatch<React.SetStateAction<{
|
|
12
|
+
showAlert: boolean;
|
|
13
|
+
message?: string;
|
|
14
|
+
isError: boolean;
|
|
15
|
+
}>>;
|
|
16
|
+
nestedFieldsView?: boolean;
|
|
17
|
+
displayOption?: 'dropdown' | 'dialogBox';
|
|
18
|
+
setOptions: (options: ObjectInstance[]) => void;
|
|
19
|
+
options: ObjectInstance[];
|
|
20
|
+
filter?: Record<string, unknown>;
|
|
21
|
+
layout?: TableViewLayout;
|
|
22
|
+
fieldHeight?: 'small' | 'medium';
|
|
23
|
+
richTextEditor?: ComponentType<SimpleEditorProps>;
|
|
24
|
+
form?: EvokeForm;
|
|
25
|
+
action?: Action;
|
|
26
|
+
selectedInstance?: ObjectInstance;
|
|
27
|
+
};
|
|
28
|
+
declare const RelatedObjectInstance: (props: RelatedObjectInstanceProps) => React.JSX.Element;
|
|
29
|
+
export default RelatedObjectInstance;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { InfoRounded } from '@mui/icons-material';
|
|
2
|
+
import React, { useState } from 'react';
|
|
3
|
+
import { Alert, Button, FormControlLabel, Radio, RadioGroup } from '../../../../../core';
|
|
4
|
+
import { Box, Grid } from '../../../../../layout';
|
|
5
|
+
import InstanceLookup from './InstanceLookup';
|
|
6
|
+
const styles = {
|
|
7
|
+
actionButtons: {
|
|
8
|
+
padding: '8px 8px 24px 8px',
|
|
9
|
+
marginRight: '18px',
|
|
10
|
+
display: 'flex',
|
|
11
|
+
justifyContent: 'flex-end',
|
|
12
|
+
alignItems: 'center',
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
const RelatedObjectInstance = (props) => {
|
|
16
|
+
const { relatedObject, id, setSelectedInstance, handleChangeObjectProperty, handleClose, nestedFieldsView, mode, displayOption, filter, layout, form, } = props;
|
|
17
|
+
const [errors, setErrors] = useState([]);
|
|
18
|
+
const [selectedRow, setSelectedRow] = useState();
|
|
19
|
+
const [relationType, setRelationType] = useState(displayOption === 'dropdown' ? 'new' : 'existing');
|
|
20
|
+
const linkExistingInstance = async () => {
|
|
21
|
+
if (selectedRow) {
|
|
22
|
+
setSelectedInstance(selectedRow);
|
|
23
|
+
handleChangeObjectProperty(id, selectedRow);
|
|
24
|
+
}
|
|
25
|
+
onClose();
|
|
26
|
+
};
|
|
27
|
+
const onClose = () => {
|
|
28
|
+
handleClose();
|
|
29
|
+
setErrors([]);
|
|
30
|
+
};
|
|
31
|
+
return (React.createElement(Box, { sx: {
|
|
32
|
+
background: nestedFieldsView ? '#F4F6F8' : 'none',
|
|
33
|
+
borderRadius: '8px',
|
|
34
|
+
} },
|
|
35
|
+
React.createElement(Box, { sx: {
|
|
36
|
+
padding: '8px 24px 0px',
|
|
37
|
+
'.MuiInputBase-root': { background: '#FFFF', borderRadius: '8px' },
|
|
38
|
+
} },
|
|
39
|
+
!nestedFieldsView &&
|
|
40
|
+
displayOption !== 'dropdown' &&
|
|
41
|
+
mode !== 'existingOnly' &&
|
|
42
|
+
mode !== 'newOnly' &&
|
|
43
|
+
form && (React.createElement(Grid, { container: true },
|
|
44
|
+
React.createElement(Grid, { container: true, item: true },
|
|
45
|
+
React.createElement(RadioGroup, { row: true, "aria-labelledby": "related-object-link-type", onChange: (event) => {
|
|
46
|
+
event.target.value === 'existing' && setErrors([]);
|
|
47
|
+
setRelationType(event.target.value);
|
|
48
|
+
}, value: relationType },
|
|
49
|
+
React.createElement(FormControlLabel, { value: "existing", control: React.createElement(Radio, { sx: { '&.Mui-checked': { color: 'primary' } } }), label: "Existing" }),
|
|
50
|
+
React.createElement(FormControlLabel, { value: "new", control: React.createElement(Radio, { sx: { '&.Mui-checked': { color: 'primary' } } }), label: "New" }))))),
|
|
51
|
+
errors?.length ? (React.createElement(Alert, { severity: "error", sx: { margin: '10px 0', borderRadius: '8px' }, icon: React.createElement(InfoRounded, { sx: { color: '#A22723' } }) }, errors.length === 1 ? (React.createElement(React.Fragment, null,
|
|
52
|
+
"There is ",
|
|
53
|
+
React.createElement("strong", null, "1"),
|
|
54
|
+
" error")) : (React.createElement(React.Fragment, null,
|
|
55
|
+
"There are ",
|
|
56
|
+
React.createElement("strong", null, errors.length),
|
|
57
|
+
" errors")))) : undefined,
|
|
58
|
+
(relationType === 'new' || mode === 'newOnly') && form ? (React.createElement(Box, { id: 'related-object-wrapper', sx: { width: '100%' } })) : (relatedObject &&
|
|
59
|
+
mode !== 'newOnly' && (React.createElement(React.Fragment, null,
|
|
60
|
+
React.createElement(InstanceLookup, { colspan: 12, nestedFieldsView: nestedFieldsView, setRelationType: setRelationType, object: relatedObject, setSelectedInstance: setSelectedRow, mode: mode, filter: filter, layout: layout }))))),
|
|
61
|
+
relationType !== 'new' && mode !== 'newOnly' && (React.createElement(Box, { sx: styles.actionButtons },
|
|
62
|
+
React.createElement(Button, { onClick: onClose, color: 'inherit', sx: {
|
|
63
|
+
border: '1px solid #ced4da',
|
|
64
|
+
width: '75px',
|
|
65
|
+
marginRight: '0px',
|
|
66
|
+
color: 'black',
|
|
67
|
+
} }, "Cancel"),
|
|
68
|
+
React.createElement(Button, { sx: {
|
|
69
|
+
marginLeft: '8px',
|
|
70
|
+
width: '85px',
|
|
71
|
+
'&:hover': { boxShadow: 'none' },
|
|
72
|
+
}, onClick: linkExistingInstance, variant: "contained", disabled: !selectedRow, "aria-label": `Add` }, "Add")))));
|
|
73
|
+
};
|
|
74
|
+
export default RelatedObjectInstance;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import RadioButtonCheckedIcon from '@mui/icons-material/RadioButtonChecked';
|
|
2
|
+
import { TabContext, TabPanel } from '@mui/lab';
|
|
3
|
+
import React, { useRef, useState } from 'react';
|
|
4
|
+
import { Tab, Tabs, Typography } from '../../../core';
|
|
5
|
+
import { Box } from '../../../layout';
|
|
6
|
+
import { RecursiveEntryRenderer } from './RecursiveEntryRenderer';
|
|
7
|
+
import TabNav from './TabNav';
|
|
8
|
+
import { getErrorCountForSection, scrollIntoViewWithOffset } from './utils';
|
|
9
|
+
function FormSections(props) {
|
|
10
|
+
const { entry, errors, handleChange, showSubmitError, fieldHeight, richTextEditor, instance, expandedSections, setExpandedSections, expandAll, setExpandAll, parameters, triggerFieldReset, } = props;
|
|
11
|
+
const tabPanelsRef = useRef(null);
|
|
12
|
+
const [tabValue, setTabValue] = useState(0);
|
|
13
|
+
const handleTabChange = (type, newValue) => {
|
|
14
|
+
setTabValue(Number(newValue));
|
|
15
|
+
if (tabPanelsRef.current && type === 'buttonNav') {
|
|
16
|
+
scrollIntoViewWithOffset(tabPanelsRef.current, 170);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
const prevTabLabel = tabValue > 0 ? entry.sections[tabValue - 1].label : '';
|
|
20
|
+
const nextTabLabel = tabValue < entry.sections.length - 1 ? entry.sections[tabValue + 1].label : '';
|
|
21
|
+
return (React.createElement(React.Fragment, null,
|
|
22
|
+
React.createElement(TabContext, { value: tabValue?.toString() || '0' },
|
|
23
|
+
React.createElement(Box, { sx: {
|
|
24
|
+
display: 'flex',
|
|
25
|
+
minHeight: '150px',
|
|
26
|
+
} },
|
|
27
|
+
React.createElement(Tabs, { value: tabValue?.toString(), onChange: (e, value) => handleTabChange('tabNav', value), orientation: "vertical", sx: {
|
|
28
|
+
overflow: 'visible',
|
|
29
|
+
paddingTop: '10px',
|
|
30
|
+
flex: 1,
|
|
31
|
+
borderRight: '1px solid #e9ecef',
|
|
32
|
+
minWidth: '190px',
|
|
33
|
+
maxWidth: '264px',
|
|
34
|
+
}, TabIndicatorProps: {
|
|
35
|
+
sx: {
|
|
36
|
+
display: 'none',
|
|
37
|
+
},
|
|
38
|
+
} }, entry.sections.map((section, sectionIndex) => {
|
|
39
|
+
const errorCount = getErrorCountForSection(section, errors);
|
|
40
|
+
const isSelected = tabValue?.toString() === sectionIndex.toString();
|
|
41
|
+
return (React.createElement(Tab, { disableRipple: true, key: section.label + sectionIndex, label: React.createElement(Box, { sx: {
|
|
42
|
+
display: 'flex',
|
|
43
|
+
alignItems: 'center',
|
|
44
|
+
width: '100%',
|
|
45
|
+
minWidth: '168px',
|
|
46
|
+
justifyContent: 'space-between',
|
|
47
|
+
} },
|
|
48
|
+
React.createElement(Box, { sx: { display: 'flex', alignItems: 'center' } },
|
|
49
|
+
React.createElement(Box, { sx: { width: '28px', display: 'flex' } }, isSelected ? (React.createElement(RadioButtonCheckedIcon, { color: errorCount > 0 && showSubmitError ? 'error' : 'primary', sx: {
|
|
50
|
+
fontSize: 'medium',
|
|
51
|
+
} })) : (React.createElement(Box, { sx: {
|
|
52
|
+
width: '8px',
|
|
53
|
+
height: '8px',
|
|
54
|
+
borderRadius: '50%',
|
|
55
|
+
backgroundColor: '#dfe3e8',
|
|
56
|
+
marginLeft: '4.25px',
|
|
57
|
+
} }))),
|
|
58
|
+
React.createElement(Typography, { sx: {
|
|
59
|
+
fontSize: '16px',
|
|
60
|
+
fontWeight: isSelected ? 'bold' : 'normal',
|
|
61
|
+
} }, section.label)),
|
|
62
|
+
errorCount > 0 && showSubmitError && (React.createElement(Box, { sx: {
|
|
63
|
+
ml: 1,
|
|
64
|
+
bgcolor: '#FF4842',
|
|
65
|
+
color: 'white',
|
|
66
|
+
borderRadius: '50%',
|
|
67
|
+
minWidth: '20px',
|
|
68
|
+
minHeight: '20px',
|
|
69
|
+
display: 'flex',
|
|
70
|
+
justifyContent: 'center',
|
|
71
|
+
alignItems: 'center',
|
|
72
|
+
fontSize: '12px',
|
|
73
|
+
margin: '0px',
|
|
74
|
+
marginRight: '16px',
|
|
75
|
+
} }, errorCount))), value: sectionIndex.toString(), tabIndex: -1, sx: {
|
|
76
|
+
textAlign: 'left',
|
|
77
|
+
display: 'flex',
|
|
78
|
+
textTransform: 'none',
|
|
79
|
+
color: '#212B36',
|
|
80
|
+
'&.Mui-selected': {
|
|
81
|
+
fontWeight: 'bold',
|
|
82
|
+
color: '#212B36',
|
|
83
|
+
},
|
|
84
|
+
padding: '14px 10px 14px 4px',
|
|
85
|
+
} }));
|
|
86
|
+
})),
|
|
87
|
+
entry.sections.map((section, sectionIndex) => (React.createElement(TabPanel, { key: section.label + sectionIndex, value: sectionIndex.toString(), ref: tabPanelsRef, sx: {
|
|
88
|
+
padding: '10px 20px 0px 40px',
|
|
89
|
+
width: '100%',
|
|
90
|
+
flex: 4,
|
|
91
|
+
} },
|
|
92
|
+
React.createElement(Box, { sx: {
|
|
93
|
+
display: 'flex',
|
|
94
|
+
flexDirection: 'column',
|
|
95
|
+
justifyContent: section.entries && section?.entries.length > 0 ? 'space-between' : 'flex-end',
|
|
96
|
+
height: '100%',
|
|
97
|
+
} },
|
|
98
|
+
React.createElement(Box, null, section.entries &&
|
|
99
|
+
section.entries.map((sectionEntry, index) => {
|
|
100
|
+
return (React.createElement(RecursiveEntryRenderer, { key: sectionEntry.type + index, entry: sectionEntry, handleChange: handleChange, errors: errors, showSubmitError: showSubmitError, fieldHeight: fieldHeight, richTextEditor: richTextEditor, instance: instance, expandedSections: expandedSections, setExpandedSections: setExpandedSections, expandAll: expandAll, setExpandAll: setExpandAll, parameters: parameters, triggerFieldReset: triggerFieldReset }));
|
|
101
|
+
})),
|
|
102
|
+
React.createElement(TabNav, { prevTabLabel: prevTabLabel, nextTabLabel: nextTabLabel, numberOfTabs: entry.sections.length, tabValue: tabValue, handleTabChange: handleTabChange })))))))));
|
|
103
|
+
}
|
|
104
|
+
export default FormSections;
|