@evoke-platform/ui-components 1.0.0-dev.226 → 1.0.0-dev.227

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (202) hide show
  1. package/dist/published/components/core/Accordion/Accordion.js +1 -1
  2. package/dist/published/components/core/Accordion/AccordionActions/AccordionActions.js +1 -1
  3. package/dist/published/components/core/Accordion/AccordionDetails/AccordionDetails.js +1 -1
  4. package/dist/published/components/core/Accordion/AccordionSummary/AccordionSummary.js +1 -1
  5. package/dist/published/components/core/Alert/Alert.js +8 -9
  6. package/dist/published/components/core/AlertTitle/AlertTitle.js +1 -1
  7. package/dist/published/components/core/AppBar/AppBar.js +1 -1
  8. package/dist/published/components/core/Autocomplete/Autocomplete.js +33 -15
  9. package/dist/published/components/core/Autocomplete/Autocomplete.test.js +1 -1
  10. package/dist/published/components/core/Avatar/Avatar.js +7 -4
  11. package/dist/published/components/core/Backdrop/Backdrop.js +1 -1
  12. package/dist/published/components/core/Badge/Badge.js +1 -1
  13. package/dist/published/components/core/Breadcrumbs/Breadcrumbs.js +1 -1
  14. package/dist/published/components/core/Button/Button.js +1 -1
  15. package/dist/published/components/core/ButtonGroup/ButtonGroup.js +1 -1
  16. package/dist/published/components/core/Card/Card.js +1 -1
  17. package/dist/published/components/core/Checkbox/Checkbox.js +1 -1
  18. package/dist/published/components/core/Chip/Chip.js +1 -1
  19. package/dist/published/components/core/CircularProgress/CircularProgress.js +1 -1
  20. package/dist/published/components/core/Collapse/Collapse.js +1 -1
  21. package/dist/published/components/core/DatePicker/DatePicker.js +4 -16
  22. package/dist/published/components/core/DateTimePicker/DateTimePicker.js +3 -15
  23. package/dist/published/components/core/Dialog/Dialog.js +1 -1
  24. package/dist/published/components/core/Dialog/DialogActions/DialogActions.js +2 -13
  25. package/dist/published/components/core/Dialog/DialogContent/DialogContent.js +1 -1
  26. package/dist/published/components/core/Dialog/DialogContentText/DialogContentText.js +1 -1
  27. package/dist/published/components/core/Dialog/DialogTitle/DialogTitle.js +1 -1
  28. package/dist/published/components/core/Divider/Divider.js +1 -1
  29. package/dist/published/components/core/Drawer/Drawer.js +1 -1
  30. package/dist/published/components/core/FieldError/FieldError.js +1 -2
  31. package/dist/published/components/core/FormElements/FormControl/FormControl.js +1 -1
  32. package/dist/published/components/core/FormElements/FormControlLabel/FormControlLabel.js +1 -1
  33. package/dist/published/components/core/FormElements/FormGroup/FormGroup.js +1 -1
  34. package/dist/published/components/core/FormElements/FormHelperText/FormHelperText.js +1 -1
  35. package/dist/published/components/core/FormElements/FormLabel/FormLabel.js +1 -1
  36. package/dist/published/components/core/IconButton/IconButton.js +1 -1
  37. package/dist/published/components/core/LinearProgress/LinearProgress.js +1 -1
  38. package/dist/published/components/core/Link/Link.js +1 -1
  39. package/dist/published/components/core/List/List.js +1 -1
  40. package/dist/published/components/core/List/ListItem.js +1 -1
  41. package/dist/published/components/core/List/ListItemText/ListItemText.js +1 -1
  42. package/dist/published/components/core/LoadingButton/LoadingButton.js +1 -1
  43. package/dist/published/components/core/LocalizationProvider/LocalizationProvider.js +3 -14
  44. package/dist/published/components/core/Menu/Menu.js +1 -1
  45. package/dist/published/components/core/Menu/MenuItem/MenuItem.js +1 -1
  46. package/dist/published/components/core/Paper/Paper.js +1 -1
  47. package/dist/published/components/core/Popover/Popover.js +1 -1
  48. package/dist/published/components/core/Popper/Popper.js +1 -1
  49. package/dist/published/components/core/RadioGroup/Radio.js +1 -1
  50. package/dist/published/components/core/RadioGroup/RadioGroup.js +1 -1
  51. package/dist/published/components/core/Select/Select.js +11 -4
  52. package/dist/published/components/core/Skeleton/Skeleton.js +1 -1
  53. package/dist/published/components/core/Snackbar/Snackbar.js +2 -2
  54. package/dist/published/components/core/StaticDatePicker/StaticDatePicker.js +3 -15
  55. package/dist/published/components/core/Stepper/Step/Step.js +1 -1
  56. package/dist/published/components/core/Stepper/StepButton/StepButton.js +1 -1
  57. package/dist/published/components/core/Stepper/StepConnector/StepConnector.js +1 -1
  58. package/dist/published/components/core/Stepper/StepContent/StepContent.js +1 -1
  59. package/dist/published/components/core/Stepper/StepIcon/StepIcon.js +1 -1
  60. package/dist/published/components/core/Stepper/StepLabel/StepLabel.js +1 -1
  61. package/dist/published/components/core/Stepper/Stepper.js +1 -1
  62. package/dist/published/components/core/Switch/Switch.js +1 -1
  63. package/dist/published/components/core/Table/Table.js +1 -1
  64. package/dist/published/components/core/Tabs/Tab/Tab.js +1 -1
  65. package/dist/published/components/core/Tabs/Tabs.js +1 -1
  66. package/dist/published/components/core/TextField/TextField.js +12 -6
  67. package/dist/published/components/core/ToggleButton/ToggleButton.js +1 -1
  68. package/dist/published/components/core/ToggleButtonGroup/ToggleButtonGroup.js +1 -1
  69. package/dist/published/components/core/Tooltip/Tooltip.js +15 -2
  70. package/dist/published/components/core/Typography/index.js +1 -1
  71. package/dist/published/components/custom/BuilderGrid/BuilderGrid.js +33 -29
  72. package/dist/published/components/custom/BuilderGrid/BuilderGridToolbar.js +1 -2
  73. package/dist/published/components/custom/BuilderGrid/EmptyContent.js +4 -5
  74. package/dist/published/components/custom/BuilderGrid/EmptyContentIllustration.js +6 -1
  75. package/dist/published/components/custom/BuilderGrid/ToolbarActions.js +3 -1
  76. package/dist/published/components/custom/CriteriaBuilder/CriteriaBuilder.js +46 -27
  77. package/dist/published/components/custom/CriteriaBuilder/CriteriaBuilder.test.js +12 -21
  78. package/dist/published/components/custom/CriteriaBuilder/ValueEditor.js +27 -34
  79. package/dist/published/components/custom/DataGrid/DataGrid.js +38 -33
  80. package/dist/published/components/custom/DataGrid/DateTimeCustomOperator.js +3 -5
  81. package/dist/published/components/custom/DataGrid/Toolbar.js +3 -4
  82. package/dist/published/components/custom/ErrorComponent/ErrorComponent.js +11 -1
  83. package/dist/published/components/custom/Form/Common/Form.js +106 -80
  84. package/dist/published/components/custom/Form/Common/FormComponentWrapper.js +20 -11
  85. package/dist/published/components/custom/Form/FormComponents/ButtonComponent.js +9 -20
  86. package/dist/published/components/custom/Form/FormComponents/DocumentComponent/Document.js +10 -20
  87. package/dist/published/components/custom/Form/FormComponents/DocumentComponent/DocumentComponent.js +24 -28
  88. package/dist/published/components/custom/Form/FormComponents/DocumentComponent/DocumentList.js +49 -64
  89. package/dist/published/components/custom/Form/FormComponents/FormFieldComponent.d.ts +1 -0
  90. package/dist/published/components/custom/Form/FormComponents/FormFieldComponent.js +109 -34
  91. package/dist/published/components/custom/Form/FormComponents/ImageComponent/Image.d.ts +2 -0
  92. package/dist/published/components/custom/Form/FormComponents/ImageComponent/Image.js +13 -25
  93. package/dist/published/components/custom/Form/FormComponents/ImageComponent/ImageComponent.d.ts +3 -1
  94. package/dist/published/components/custom/Form/FormComponents/ImageComponent/ImageComponent.js +30 -9
  95. package/dist/published/components/custom/Form/FormComponents/ObjectComponent/InstanceLookup.js +26 -31
  96. package/dist/published/components/custom/Form/FormComponents/ObjectComponent/ObjectComponent.d.ts +5 -4
  97. package/dist/published/components/custom/Form/FormComponents/ObjectComponent/ObjectComponent.js +70 -22
  98. package/dist/published/components/custom/Form/FormComponents/ObjectComponent/ObjectPropertyInput.js +93 -75
  99. package/dist/published/components/custom/Form/FormComponents/ObjectComponent/RelatedObjectInstance.d.ts +2 -2
  100. package/dist/published/components/custom/Form/FormComponents/ObjectComponent/RelatedObjectInstance.js +17 -26
  101. package/dist/published/components/custom/Form/FormComponents/RepeatableFieldComponent/ActionDialog.js +20 -24
  102. package/dist/published/components/custom/Form/FormComponents/RepeatableFieldComponent/ManyToMany/DropdownRepeatableField.js +22 -33
  103. package/dist/published/components/custom/Form/FormComponents/RepeatableFieldComponent/ManyToMany/DropdownRepeatableFieldInput.js +12 -9
  104. package/dist/published/components/custom/Form/FormComponents/RepeatableFieldComponent/RepeatableField.js +61 -60
  105. package/dist/published/components/custom/Form/FormComponents/RepeatableFieldComponent/RepeatableFieldComponent.js +8 -6
  106. package/dist/published/components/custom/Form/FormComponents/UserComponent/UserComponent.d.ts +3 -1
  107. package/dist/published/components/custom/Form/FormComponents/UserComponent/UserComponent.js +55 -12
  108. package/dist/published/components/custom/Form/FormComponents/UserComponent/UserProperty.js +32 -30
  109. package/dist/published/components/custom/Form/FormComponents/ViewOnlyComponent.js +12 -9
  110. package/dist/published/components/custom/Form/types.d.ts +5 -5
  111. package/dist/published/components/custom/Form/utils.js +611 -446
  112. package/dist/published/components/custom/FormField/AddressFieldComponent/AddressFieldComponent.test.js +41 -54
  113. package/dist/published/components/custom/FormField/AddressFieldComponent/addressFieldComponent.js +7 -8
  114. package/dist/published/components/custom/FormField/BooleanSelect/BooleanSelect.js +1 -1
  115. package/dist/published/components/custom/FormField/BooleanSelect/BooleanSelect.test.js +5 -14
  116. package/dist/published/components/custom/FormField/DatePickerSelect/DatePickerSelect.js +2 -2
  117. package/dist/published/components/custom/FormField/DatePickerSelect/DatePickerSelect.test.js +12 -21
  118. package/dist/published/components/custom/FormField/DateTimePickerSelect/DateTimePickerSelect.js +2 -2
  119. package/dist/published/components/custom/FormField/DateTimePickerSelect/DateTimePickerSelect.test.js +12 -21
  120. package/dist/published/components/custom/FormField/FileUpload/FileUpload.js +10 -11
  121. package/dist/published/components/custom/FormField/FormField.js +10 -10
  122. package/dist/published/components/custom/FormField/InputFieldComponent/InputFieldComponent.js +22 -30
  123. package/dist/published/components/custom/FormField/InputFieldComponent/InputFieldComponent.test.js +8 -17
  124. package/dist/published/components/custom/FormField/Select/Select.js +5 -6
  125. package/dist/published/components/custom/FormField/Select/Select.test.js +18 -27
  126. package/dist/published/components/custom/FormField/TimePickerSelect/TimePickerSelect.js +4 -4
  127. package/dist/published/components/custom/HistoryLog/DisplayedProperty.js +12 -13
  128. package/dist/published/components/custom/HistoryLog/HistoryData.js +49 -45
  129. package/dist/published/components/custom/HistoryLog/HistoryLoading.js +5 -5
  130. package/dist/published/components/custom/HistoryLog/index.js +5 -6
  131. package/dist/published/components/custom/Menubar/Menubar.js +2 -2
  132. package/dist/published/components/custom/MultiSelect/MultiSelect.js +38 -50
  133. package/dist/published/components/custom/MultiSelect/SortableItem.js +1 -1
  134. package/dist/published/components/custom/RepeatableField/RepeatableField.js +14 -16
  135. package/dist/published/components/custom/UserAvatar/UserAvatar.js +12 -5
  136. package/dist/published/components/custom/util.js +1 -1
  137. package/dist/published/components/layout/Box/Box.js +1 -1
  138. package/dist/published/components/layout/Container/Container.js +1 -1
  139. package/dist/published/components/layout/Grid/Grid.js +1 -1
  140. package/dist/published/components/layout/Stack/Stack.js +1 -1
  141. package/dist/published/icons/custom/FileWithExtension.js +8 -4
  142. package/dist/published/icons/custom/Inherited.js +8 -6
  143. package/dist/published/icons/custom/Overrides.js +9 -7
  144. package/dist/published/icons/custom/TrashCan.js +10 -8
  145. package/dist/published/icons/custom/UploadCloud.js +9 -7
  146. package/dist/published/stories/Accordion.stories.js +2 -2
  147. package/dist/published/stories/Alert.stories.js +1 -1
  148. package/dist/published/stories/AlertTitle.stories.js +1 -1
  149. package/dist/published/stories/Autocomplete.stories.js +2 -2
  150. package/dist/published/stories/Avatar.stories.js +1 -1
  151. package/dist/published/stories/Backdrop.stories.js +1 -1
  152. package/dist/published/stories/Badge.stories.js +1 -1
  153. package/dist/published/stories/Box.stories.js +2 -2
  154. package/dist/published/stories/Breadcrumbs.stories.js +1 -1
  155. package/dist/published/stories/Button.stories.js +1 -1
  156. package/dist/published/stories/ButtonGroup.stories.js +1 -1
  157. package/dist/published/stories/Card.stories.js +1 -1
  158. package/dist/published/stories/Checkbox.stories.js +1 -1
  159. package/dist/published/stories/Chip.stories.js +1 -1
  160. package/dist/published/stories/CircularProgress.stories.js +1 -1
  161. package/dist/published/stories/Collapse.stories.js +1 -1
  162. package/dist/published/stories/Container.stories.js +1 -1
  163. package/dist/published/stories/CriteriaBuilder.stories.js +7 -3
  164. package/dist/published/stories/DataGrid.stories.js +3 -3
  165. package/dist/published/stories/DatePicker.stories.js +3 -14
  166. package/dist/published/stories/Dialog.stories.js +1 -1
  167. package/dist/published/stories/Divider.stories.js +1 -1
  168. package/dist/published/stories/Drawer.stories.js +2 -2
  169. package/dist/published/stories/FormControl.stories.js +1 -1
  170. package/dist/published/stories/FormControlLabel.stories.js +1 -1
  171. package/dist/published/stories/FormField.stories.js +3 -12
  172. package/dist/published/stories/FormGroup.stories.js +1 -1
  173. package/dist/published/stories/FormHelperText.stories.js +1 -1
  174. package/dist/published/stories/FormLabel.stories.js +1 -1
  175. package/dist/published/stories/Grid.stories.js +1 -1
  176. package/dist/published/stories/HistoryLog.stories.js +1 -1
  177. package/dist/published/stories/IconButton.stories.js +4 -4
  178. package/dist/published/stories/LinearProgress.stories.js +1 -1
  179. package/dist/published/stories/Link.stories.js +1 -1
  180. package/dist/published/stories/List.stories.js +2 -2
  181. package/dist/published/stories/Menu.stories.js +2 -2
  182. package/dist/published/stories/MenuBar.stories.js +1 -1
  183. package/dist/published/stories/MultiSelect.stories.js +3 -3
  184. package/dist/published/stories/Palette.stories.js +11 -11
  185. package/dist/published/stories/Paper.stories.js +1 -1
  186. package/dist/published/stories/RadioGroup.stories.js +1 -1
  187. package/dist/published/stories/RepeatableField.stories.js +6 -7
  188. package/dist/published/stories/RichTextViewer.stories.js +1 -1
  189. package/dist/published/stories/Skeleton.stories.js +1 -1
  190. package/dist/published/stories/Snackbar.stories.js +1 -1
  191. package/dist/published/stories/Stack.stories.js +1 -1
  192. package/dist/published/stories/StaticDatePicker.stories.js +3 -14
  193. package/dist/published/stories/Stepper.stories.js +3 -3
  194. package/dist/published/stories/Switch.stories.js +1 -1
  195. package/dist/published/stories/Table.stories.js +2 -2
  196. package/dist/published/stories/Tabs.stories.js +6 -17
  197. package/dist/published/stories/TextField.stories.js +1 -1
  198. package/dist/published/stories/TimePicker.stories.js +3 -14
  199. package/dist/published/stories/TimePickerSelect.stories.js +3 -14
  200. package/dist/published/stories/ToggleButton.stories.js +4 -4
  201. package/dist/published/theme/UIThemeProvider.js +1 -2
  202. package/package.json +1 -1
@@ -16,13 +16,13 @@ export const DropdownRepeatableFieldInput = (props) => {
16
16
  if (manyToManyPropertyId) {
17
17
  const enums = endObjectInstances
18
18
  .map((endObjectInstance) => {
19
- const normalizedInstance = Object.assign({}, endObjectInstance);
19
+ const normalizedInstance = { ...endObjectInstance };
20
20
  normalizeDates([normalizedInstance], endObject);
21
21
  return normalizedInstance;
22
22
  })
23
23
  .map((endObjectInstance) => ({
24
24
  label: endObjectInstance.name,
25
- subLabel: (layout === null || layout === void 0 ? void 0 : layout.secondaryTextExpression)
25
+ subLabel: layout?.secondaryTextExpression
26
26
  ? compileExpression(endObjectInstance, layout.secondaryTextExpression)
27
27
  : undefined,
28
28
  endObjectId: endObjectInstance.id,
@@ -32,7 +32,7 @@ export const DropdownRepeatableFieldInput = (props) => {
32
32
  ...enums,
33
33
  ...selectedOptions
34
34
  .filter((selectedOption) => !enums.find((availableOption) => availableOption.endObjectId === selectedOption.endObjectId))
35
- .map((option) => (Object.assign(Object.assign({}, option), { hidden: true }))),
35
+ .map((option) => ({ ...option, hidden: true })),
36
36
  ]);
37
37
  }
38
38
  }, [endObjectInstances, layout]);
@@ -64,12 +64,15 @@ export const DropdownRepeatableFieldInput = (props) => {
64
64
  return template(instance);
65
65
  };
66
66
  return (React.createElement(React.Fragment, null, !readOnly ? (property && (React.createElement(React.Fragment, null,
67
- React.createElement(FormField, { id: id, property: Object.assign(Object.assign({}, property), { type: 'array',
67
+ React.createElement(FormField, { id: id, property: {
68
+ ...property,
69
+ type: 'array',
68
70
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
69
- enum: selectOptions }), onChange: handleChange, defaultValue: selectedOptions, isOptionEqualToValue: (option, value) => isDropdownRepeatableFieldInputOption(value) &&
71
+ enum: selectOptions,
72
+ }, onChange: handleChange, defaultValue: selectedOptions, isOptionEqualToValue: (option, value) => isDropdownRepeatableFieldInputOption(value) &&
70
73
  isDropdownRepeatableFieldInputOption(option) &&
71
- option.endObjectId === value.endObjectId, size: fieldHeight !== null && fieldHeight !== void 0 ? fieldHeight : 'medium', renderOption: (props, option) => {
72
- return isObject(props) && isDropdownRepeatableFieldInputOption(option) ? (React.createElement("li", Object.assign({}, props, { key: option.endObjectId }),
74
+ option.endObjectId === value.endObjectId, size: fieldHeight ?? 'medium', renderOption: (props, option) => {
75
+ return isObject(props) && isDropdownRepeatableFieldInputOption(option) ? (React.createElement("li", { ...props, key: option.endObjectId },
73
76
  React.createElement(Typography, null,
74
77
  option.label,
75
78
  React.createElement("br", null),
@@ -79,9 +82,9 @@ export const DropdownRepeatableFieldInput = (props) => {
79
82
  return options.filter((option) => !option.hidden);
80
83
  },
81
84
  inputValue: searchValue,
82
- renderInput: (params) => (React.createElement(TextField, Object.assign({}, params, { onChange: (event) => {
85
+ renderInput: (params) => (React.createElement(TextField, { ...params, onChange: (event) => {
83
86
  setSearchValue(event.target.value);
84
- } }))),
87
+ } })),
85
88
  loading: loading,
86
89
  } }),
87
90
  React.createElement(Snackbar, { open: snackbarError.showAlert, handleClose: () => setSnackbarError({ isError: snackbarError.isError, showAlert: false }), message: snackbarError.message, error: snackbarError.isError })))) : (React.createElement(Typography, null, selectedOptions && selectedOptions.map((option) => option.label).join(', ')))));
@@ -1,12 +1,3 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import { useNotification, } from '@evoke-platform/context';
11
2
  import { LocalDateTime } from '@js-joda/core';
12
3
  import { get, isObject, pick, startCase } from 'lodash';
@@ -40,7 +31,6 @@ const styles = {
40
31
  },
41
32
  };
42
33
  const RepeatableField = (props) => {
43
- var _a, _b;
44
34
  const { property, instance, canUpdateProperty, apiServices, queryAddresses, user, viewLayout } = props;
45
35
  const [relatedInstances, setRelatedInstances] = useState([]);
46
36
  const [relatedObject, setRelatedObject] = useState();
@@ -59,17 +49,21 @@ const RepeatableField = (props) => {
59
49
  const [error, setError] = useState(false);
60
50
  const DEFAULT_CREATE_ACTION = '_create';
61
51
  const { instanceChanges } = useNotification();
62
- const fetchRelatedInstances = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
63
- var _c;
52
+ const fetchRelatedInstances = useCallback(async () => {
64
53
  if (openDialog)
65
54
  return;
66
55
  let relatedObject;
67
56
  if (property.objectId) {
68
57
  try {
69
- relatedObject = yield apiServices.get(getPrefixedUrl(`/objects/${property.objectId}/effective`));
58
+ relatedObject = await apiServices.get(getPrefixedUrl(`/objects/${property.objectId}/effective`));
70
59
  let defaultTableViewLayout;
71
- if ((_c = relatedObject.viewLayout) === null || _c === void 0 ? void 0 : _c.table) {
72
- defaultTableViewLayout = Object.assign({ id: 'default', name: 'Default', objectId: relatedObject.id }, relatedObject === null || relatedObject === void 0 ? void 0 : relatedObject.viewLayout.table);
60
+ if (relatedObject.viewLayout?.table) {
61
+ defaultTableViewLayout = {
62
+ id: 'default',
63
+ name: 'Default',
64
+ objectId: relatedObject.id,
65
+ ...relatedObject?.viewLayout.table,
66
+ };
73
67
  }
74
68
  if (viewLayout) {
75
69
  apiServices
@@ -85,16 +79,16 @@ const RepeatableField = (props) => {
85
79
  catch (err) {
86
80
  console.error(error);
87
81
  }
88
- if (property.relatedPropertyId && (instance === null || instance === void 0 ? void 0 : instance.id)) {
82
+ if (property.relatedPropertyId && instance?.id) {
89
83
  const filterProperty = `${property.relatedPropertyId}.id`;
90
- const filter = { where: { [filterProperty]: instance === null || instance === void 0 ? void 0 : instance.id }, limit: 100 };
84
+ const filter = { where: { [filterProperty]: instance?.id }, limit: 100 };
91
85
  const objectId = property.objectId;
92
86
  try {
93
87
  const timeout = setTimeout(() => {
94
88
  setLoading(false);
95
89
  }, 300);
96
90
  setLoading(true);
97
- const instances = yield apiServices.get(getPrefixedUrl(`/objects/${objectId}/instances`), {
91
+ const instances = await apiServices.get(getPrefixedUrl(`/objects/${objectId}/instances`), {
98
92
  params: { filter: JSON.stringify(filter) },
99
93
  });
100
94
  clearTimeout(timeout);
@@ -109,7 +103,7 @@ const RepeatableField = (props) => {
109
103
  }
110
104
  }
111
105
  relatedObject && checkCreateAccess(relatedObject);
112
- }), [apiServices, property, viewLayout]);
106
+ }, [apiServices, property, viewLayout]);
113
107
  const checkCreateAccess = (relatedObject) => {
114
108
  if (property.objectId && canUpdateProperty) {
115
109
  apiServices
@@ -117,22 +111,21 @@ const RepeatableField = (props) => {
117
111
  params: { action: 'execute', field: '_create', scope: 'data' },
118
112
  })
119
113
  .then((checkAccess) => {
120
- var _a, _b, _c, _d, _e;
121
- const action = (_a = relatedObject.actions) === null || _a === void 0 ? void 0 : _a.find((item) => item.id === '_create');
114
+ const action = relatedObject.actions?.find((item) => item.id === '_create');
122
115
  if (action) {
123
116
  let relatedObjectProperty;
124
117
  let validationCriteria;
125
118
  if (action.parameters) {
126
119
  relatedObjectProperty = action.parameters.find((param) => param.id === property.relatedPropertyId);
127
- validationCriteria = (_b = relatedObjectProperty === null || relatedObjectProperty === void 0 ? void 0 : relatedObjectProperty.validation) === null || _b === void 0 ? void 0 : _b.criteria;
120
+ validationCriteria = relatedObjectProperty?.validation?.criteria;
128
121
  }
129
122
  else if (action.inputProperties) {
130
123
  relatedObjectProperty = action.inputProperties.find((inputProp) => inputProp.key === property.relatedPropertyId);
131
- validationCriteria = (_c = relatedObjectProperty === null || relatedObjectProperty === void 0 ? void 0 : relatedObjectProperty.validate) === null || _c === void 0 ? void 0 : _c.criteria;
124
+ validationCriteria = relatedObjectProperty?.validate?.criteria;
132
125
  }
133
126
  else {
134
- relatedObjectProperty = ((_d = relatedObject.properties) !== null && _d !== void 0 ? _d : []).find((prop) => prop.id === property.relatedPropertyId);
135
- validationCriteria = (_e = relatedObjectProperty === null || relatedObjectProperty === void 0 ? void 0 : relatedObjectProperty.validation) === null || _e === void 0 ? void 0 : _e.criteria;
127
+ relatedObjectProperty = (relatedObject.properties ?? []).find((prop) => prop.id === property.relatedPropertyId);
128
+ validationCriteria = relatedObjectProperty?.validation?.criteria;
136
129
  }
137
130
  if (relatedObjectProperty) {
138
131
  if (validationCriteria) {
@@ -156,24 +149,24 @@ const RepeatableField = (props) => {
156
149
  }
157
150
  };
158
151
  useEffect(() => {
159
- (() => __awaiter(void 0, void 0, void 0, function* () {
152
+ (async () => {
160
153
  try {
161
- const users = yield apiServices.get(getPrefixedUrl(`/users`));
154
+ const users = await apiServices.get(getPrefixedUrl(`/users`));
162
155
  setUsers(users);
163
156
  }
164
157
  catch (error) {
165
158
  console.error(error);
166
159
  }
167
- }))();
160
+ })();
168
161
  }, [apiServices]);
169
162
  useEffect(() => {
170
163
  fetchRelatedInstances();
171
164
  }, [fetchRelatedInstances, reloadOnErrorTrigger, instance]);
172
165
  useEffect(() => {
173
- if (relatedObject === null || relatedObject === void 0 ? void 0 : relatedObject.rootObjectId) {
166
+ if (relatedObject?.rootObjectId) {
174
167
  const callback = () => fetchRelatedInstances();
175
- instanceChanges === null || instanceChanges === void 0 ? void 0 : instanceChanges.subscribe(relatedObject === null || relatedObject === void 0 ? void 0 : relatedObject.rootObjectId, callback);
176
- return () => instanceChanges === null || instanceChanges === void 0 ? void 0 : instanceChanges.unsubscribe(relatedObject === null || relatedObject === void 0 ? void 0 : relatedObject.rootObjectId, callback);
168
+ instanceChanges?.subscribe(relatedObject?.rootObjectId, callback);
169
+ return () => instanceChanges?.unsubscribe(relatedObject?.rootObjectId, callback);
177
170
  }
178
171
  }, [instanceChanges, relatedObject]);
179
172
  const deleteRow = (id) => {
@@ -207,8 +200,7 @@ const RepeatableField = (props) => {
207
200
  },
208
201
  'min-width': '44px',
209
202
  }, variant: "text", onClick: () => setReloadOnErrorTrigger((prevState) => !prevState) }, "Retry")));
210
- const save = (actionType, input, instanceId, setSubmitting) => __awaiter(void 0, void 0, void 0, function* () {
211
- var _d, _e, _f, _g, _h, _j;
203
+ const save = async (actionType, input, instanceId, setSubmitting) => {
212
204
  setSubmitting && setSubmitting(true);
213
205
  // date-time fields are stored in the database in ISO format so convert all
214
206
  // LocalDateTime objects to ISO format.
@@ -220,13 +212,13 @@ const RepeatableField = (props) => {
220
212
  let isSuccessful = false;
221
213
  let error;
222
214
  if (actionType === 'create') {
223
- const updatedInput = Object.assign(Object.assign({}, input), { [property === null || property === void 0 ? void 0 : property.relatedPropertyId]: { id: instance === null || instance === void 0 ? void 0 : instance.id } });
215
+ const updatedInput = { ...input, [property?.relatedPropertyId]: { id: instance?.id } };
224
216
  try {
225
- const instance = yield apiServices.post(getPrefixedUrl(`/objects/${property.objectId}/instances/actions`), {
217
+ const instance = await apiServices.post(getPrefixedUrl(`/objects/${property.objectId}/instances/actions`), {
226
218
  actionId: DEFAULT_CREATE_ACTION,
227
219
  input: updatedInput,
228
220
  });
229
- const hasAccess = (property === null || property === void 0 ? void 0 : property.relatedPropertyId) && property.relatedPropertyId in instance;
221
+ const hasAccess = property?.relatedPropertyId && property.relatedPropertyId in instance;
230
222
  hasAccess && setRelatedInstances([...relatedInstances, instance]);
231
223
  setSubmitting && setSubmitting(false);
232
224
  // clear out dialog
@@ -242,23 +234,25 @@ const RepeatableField = (props) => {
242
234
  isError: true,
243
235
  });
244
236
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
245
- error = (_e = (_d = err.response) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.error;
237
+ error = err.response?.data?.error;
246
238
  setSubmitting && setSubmitting(false);
247
239
  }
248
240
  }
249
241
  else {
250
- const relatedObjectId = relatedObject === null || relatedObject === void 0 ? void 0 : relatedObject.id;
242
+ const relatedObjectId = relatedObject?.id;
251
243
  try {
252
- yield apiServices.post(getPrefixedUrl(`/objects/${relatedObjectId}/instances/${instanceId}/actions`), {
244
+ await apiServices.post(getPrefixedUrl(`/objects/${relatedObjectId}/instances/${instanceId}/actions`), {
253
245
  actionId: `_${actionType}`,
254
- input: pick(input, (_g = (_f = relatedObject === null || relatedObject === void 0 ? void 0 : relatedObject.properties) === null || _f === void 0 ? void 0 : _f.filter((property) => !property.formula && property.type !== 'collection').map((property) => property.id)) !== null && _g !== void 0 ? _g : []),
246
+ input: pick(input, relatedObject?.properties
247
+ ?.filter((property) => !property.formula && property.type !== 'collection')
248
+ .map((property) => property.id) ?? []),
255
249
  });
256
250
  if (actionType === 'delete') {
257
251
  setRelatedInstances((prevInstances) => prevInstances.filter((instance) => instance.id !== instanceId));
258
252
  setSubmitting && setSubmitting(false);
259
253
  }
260
254
  else {
261
- setRelatedInstances((prevInstances) => prevInstances.map((i) => (i.id === (instance === null || instance === void 0 ? void 0 : instance.id) ? instance : i)));
255
+ setRelatedInstances((prevInstances) => prevInstances.map((i) => (i.id === instance?.id ? instance : i)));
262
256
  setSubmitting && setSubmitting(false);
263
257
  }
264
258
  // clear out dialog
@@ -274,27 +268,30 @@ const RepeatableField = (props) => {
274
268
  isError: true,
275
269
  });
276
270
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
277
- error = (_j = (_h = err.response) === null || _h === void 0 ? void 0 : _h.data) === null || _j === void 0 ? void 0 : _j.error;
271
+ error = err.response?.data?.error;
278
272
  }
279
273
  }
280
274
  return { isSuccessful, error };
281
- });
275
+ };
282
276
  const retrieveViewLayout = () => {
283
- var _a, _b, _c, _d;
284
277
  let properties = [];
285
- if ((_a = tableViewLayout === null || tableViewLayout === void 0 ? void 0 : tableViewLayout.properties) === null || _a === void 0 ? void 0 : _a.length) {
278
+ if (tableViewLayout?.properties?.length) {
286
279
  for (const prop of tableViewLayout.properties) {
287
280
  const propertyId = prop.id.split('.')[0];
288
- const property = (_b = relatedObject === null || relatedObject === void 0 ? void 0 : relatedObject.properties) === null || _b === void 0 ? void 0 : _b.find((p) => p.id === propertyId);
281
+ const property = relatedObject?.properties?.find((p) => p.id === propertyId);
289
282
  if (property) {
290
283
  if ((property.type === 'object' && property.id !== property.relatedPropertyId) ||
291
284
  property.type === 'address' ||
292
285
  property.type === 'user') {
293
- properties.push(Object.assign(Object.assign({}, property), { id: ['user', 'object'].includes(property.type) && !prop.id.endsWith('.name')
286
+ properties.push({
287
+ ...property,
288
+ id: ['user', 'object'].includes(property.type) && !prop.id.endsWith('.name')
294
289
  ? `${prop.id}.name`
295
- : prop.id, name: property.type === 'address'
290
+ : prop.id,
291
+ name: property.type === 'address'
296
292
  ? `${property.name} - ${startCase(prop.id.split('.')[1])}`
297
- : property.name }));
293
+ : property.name,
294
+ });
298
295
  }
299
296
  else {
300
297
  properties.push(property);
@@ -304,7 +301,12 @@ const RepeatableField = (props) => {
304
301
  }
305
302
  else {
306
303
  properties =
307
- (_d = (_c = relatedObject === null || relatedObject === void 0 ? void 0 : relatedObject.properties) === null || _c === void 0 ? void 0 : _c.filter((prop) => !['address', 'image', 'collection'].includes(prop.type)).map((prop) => (Object.assign(Object.assign({}, prop), { id: prop.type === 'object' || prop.type === 'user' ? `${prop.id}.name` : prop.id })))) !== null && _d !== void 0 ? _d : [];
304
+ relatedObject?.properties
305
+ ?.filter((prop) => !['address', 'image', 'collection'].includes(prop.type))
306
+ .map((prop) => ({
307
+ ...prop,
308
+ id: prop.type === 'object' || prop.type === 'user' ? `${prop.id}.name` : prop.id,
309
+ })) ?? [];
308
310
  }
309
311
  return properties;
310
312
  };
@@ -342,7 +344,7 @@ const RepeatableField = (props) => {
342
344
  React.createElement(Skeleton, null),
343
345
  React.createElement(Skeleton, null))) : (React.createElement(React.Fragment, null,
344
346
  React.createElement(Box, { sx: { padding: '10px 0' } },
345
- !(relatedInstances === null || relatedInstances === void 0 ? void 0 : relatedInstances.length) ? (!error ? (React.createElement(Typography, { sx: { color: 'rgb(114 124 132)', fontSize: '14px' } }, "No items added")) : (React.createElement(ErrorComponent, null))) : (React.createElement(TableContainer, { sx: {
347
+ !relatedInstances?.length ? (!error ? (React.createElement(Typography, { sx: { color: 'rgb(114 124 132)', fontSize: '14px' } }, "No items added")) : (React.createElement(ErrorComponent, null))) : (React.createElement(TableContainer, { sx: {
346
348
  borderRadius: '6px',
347
349
  border: '1px solid #919EAB3D',
348
350
  boxShadow: 'none',
@@ -350,12 +352,11 @@ const RepeatableField = (props) => {
350
352
  } },
351
353
  React.createElement(Table, { stickyHeader: true, sx: { minWidth: 650 } },
352
354
  React.createElement(TableHead, { sx: { backgroundColor: '#F4F6F8' } },
353
- React.createElement(TableRow, null, columns === null || columns === void 0 ? void 0 :
354
- columns.map((prop) => React.createElement(TableCell, { sx: styles.tableCell }, prop.name)),
355
- React.createElement(TableCell, { sx: Object.assign(Object.assign({}, styles.tableCell), { width: '80px' }) }))),
356
- React.createElement(TableBody, null, relatedInstances === null || relatedInstances === void 0 ? void 0 : relatedInstances.map((relatedInstance, index) => (React.createElement(TableRow, { key: relatedInstance.id }, columns === null || columns === void 0 ? void 0 :
357
- columns.map((prop) => {
358
- var _a;
355
+ React.createElement(TableRow, null,
356
+ columns?.map((prop) => React.createElement(TableCell, { sx: styles.tableCell }, prop.name)),
357
+ React.createElement(TableCell, { sx: { ...styles.tableCell, width: '80px' } }))),
358
+ React.createElement(TableBody, null, relatedInstances?.map((relatedInstance, index) => (React.createElement(TableRow, { key: relatedInstance.id },
359
+ columns?.map((prop) => {
359
360
  return (React.createElement(TableCell, { sx: { color: '#212B36', fontSize: '16px' } },
360
361
  React.createElement(Typography, { key: prop.id, sx: prop.id === 'name'
361
362
  ? {
@@ -369,7 +370,7 @@ const RepeatableField = (props) => {
369
370
  : undefined },
370
371
  getValue(relatedInstance, prop.id, prop.type),
371
372
  prop.type === 'user' &&
372
- ((_a = users === null || users === void 0 ? void 0 : users.find((user) => get(relatedInstance, `${prop.id.split('.')[0]}.id`) === user.id)) === null || _a === void 0 ? void 0 : _a.status) === 'Inactive' && React.createElement("span", null, ' (Inactive)'))));
373
+ users?.find((user) => get(relatedInstance, `${prop.id.split('.')[0]}.id`) === user.id)?.status === 'Inactive' && React.createElement("span", null, ' (Inactive)'))));
373
374
  }),
374
375
  canUpdateProperty && (React.createElement(TableCell, { sx: { width: '80px' } },
375
376
  React.createElement(IconButton, { "aria-label": `edit-collection-instance-${index}`, onClick: () => editRow(relatedInstance.id) },
@@ -379,9 +380,9 @@ const RepeatableField = (props) => {
379
380
  React.createElement(Tooltip, { title: "Delete" },
380
381
  React.createElement(TrashCan, { sx: { ':hover': { color: '#A12723' } } })))))))))))),
381
382
  hasCreateAction && (React.createElement(Button, { variant: "contained", sx: styles.addButton, onClick: addRow }, "Add"))),
382
- relatedObject && openDialog && (React.createElement(ActionDialog, { object: relatedObject, open: openDialog, apiServices: apiServices, onClose: () => setOpenDialog(false), instanceInput: dialogType === 'update' ? (_a = relatedInstances.find((i) => i.id === selectedRow)) !== null && _a !== void 0 ? _a : {} : {}, handleSubmit: save,
383
+ relatedObject && openDialog && (React.createElement(ActionDialog, { object: relatedObject, open: openDialog, apiServices: apiServices, onClose: () => setOpenDialog(false), instanceInput: dialogType === 'update' ? relatedInstances.find((i) => i.id === selectedRow) ?? {} : {}, handleSubmit: save,
383
384
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
384
- objectInputCommonProps: { apiServices }, action: (_b = relatedObject === null || relatedObject === void 0 ? void 0 : relatedObject.actions) === null || _b === void 0 ? void 0 : _b.find((a) => a.id ===
385
+ objectInputCommonProps: { apiServices }, action: relatedObject?.actions?.find((a) => a.id ===
385
386
  (dialogType === 'create' ? '_create' : dialogType === 'update' ? '_update' : '_delete')), instanceId: selectedRow, relatedProperty: property, queryAddresses: queryAddresses, user: user })),
386
387
  React.createElement(Snackbar, { open: snackbarError.showAlert, handleClose: () => setSnackbarError({ isError: snackbarError.isError, showAlert: false }), message: snackbarError.message, error: snackbarError.isError })));
387
388
  };
@@ -12,11 +12,14 @@ const apiBaseUrl = process.env.REACT_APP_API_ROOT || `${window.location.origin}/
12
12
  export class RepeatableFieldComponent extends ReactComponent {
13
13
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
14
  constructor(component, options, data) {
15
- var _a;
16
- super(Object.assign(Object.assign({}, component), { canUpdateProperty: !component.readOnly, hideLabel: true }), options, data);
15
+ super({
16
+ ...component,
17
+ canUpdateProperty: !component.readOnly,
18
+ hideLabel: true,
19
+ }, options, data);
17
20
  this.errorDetails = {};
18
21
  this.criteria = component.validate.criteria;
19
- this.updatedCriteria = (_a = cloneDeep(component.validate.criteria)) !== null && _a !== void 0 ? _a : {};
22
+ this.updatedCriteria = cloneDeep(component.validate.criteria) ?? {};
20
23
  }
21
24
  init() {
22
25
  if (this.criteria) {
@@ -33,9 +36,8 @@ export class RepeatableFieldComponent extends ReactComponent {
33
36
  compKey = inputProp;
34
37
  }
35
38
  this.on(`changed-${compKey}`, () => {
36
- var _a;
37
39
  const data = dot.dot(this.root._data);
38
- this.updatedCriteria = (_a = cloneDeep(this.criteria)) !== null && _a !== void 0 ? _a : {};
40
+ this.updatedCriteria = cloneDeep(this.criteria) ?? {};
39
41
  for (const inputProp of inputProps) {
40
42
  updateCriteriaInputs(this.updatedCriteria, inputProp, data[inputProp], true);
41
43
  }
@@ -49,7 +51,7 @@ export class RepeatableFieldComponent extends ReactComponent {
49
51
  const inputId = `${this.component.id}-input`;
50
52
  return ReactDOM.render(React.createElement("div", null, !this.component.hidden ? (React.createElement(ApiBaseUrlProvider, { url: apiBaseUrl },
51
53
  React.createElement(NotificationProvider, null,
52
- React.createElement(FormComponentWrapper, Object.assign({}, this.component, { inputId: inputId, viewOnly: !this.component.canUpdateProperty }), this.component.property.manyToManyPropertyId ? (React.createElement(DropdownRepeatableField, { id: inputId, property: this.component.property, instance: this.component.instance, apiServices: this.component.apiServices, criteria: this.updatedCriteria, readOnly: !this.component.canUpdateProperty, initialMiddleObjectInstances: this.component.initialMiddleObjectInstances, middleObject: this.component.middleObject, getMiddleObjectInstances: this.component.getMiddleObjectInstances, fieldHeight: this.component.fieldHeight, viewLayout: this.component.viewLayout })) : (React.createElement(RepeatableField, Object.assign({}, this.component))))))) : null), element);
54
+ React.createElement(FormComponentWrapper, { ...this.component, inputId: inputId, viewOnly: !this.component.canUpdateProperty }, this.component.property.manyToManyPropertyId ? (React.createElement(DropdownRepeatableField, { id: inputId, property: this.component.property, instance: this.component.instance, apiServices: this.component.apiServices, criteria: this.updatedCriteria, readOnly: !this.component.canUpdateProperty, initialMiddleObjectInstances: this.component.initialMiddleObjectInstances, middleObject: this.component.middleObject, getMiddleObjectInstances: this.component.getMiddleObjectInstances, fieldHeight: this.component.fieldHeight, viewLayout: this.component.viewLayout })) : (React.createElement(RepeatableField, { ...this.component })))))) : null), element);
53
55
  }
54
56
  detachReact(element) {
55
57
  ReactDOM.unmountComponentAtNode(element);
@@ -6,7 +6,9 @@ export declare class UserComponent extends ReactComponent {
6
6
  [x: string]: any;
7
7
  static schema: any;
8
8
  errorDetails: any;
9
- component: BaseFormComponentProps;
9
+ component: BaseFormComponentProps & {
10
+ initialValue?: string;
11
+ };
10
12
  componentRoot?: Root;
11
13
  criteria: Record<string, unknown> | undefined;
12
14
  updatedCriteria: Record<string, unknown>;
@@ -1,4 +1,3 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
1
  import { ReactComponent } from '@formio/react';
3
2
  import { cloneDeep, isEmpty } from 'lodash';
4
3
  import React from 'react';
@@ -8,21 +7,25 @@ import { isPropertyVisible, transformToWhere } from '../../utils';
8
7
  import { UserProperty } from './UserProperty';
9
8
  export class UserComponent extends ReactComponent {
10
9
  constructor(component, options, data) {
11
- var _a;
12
- super(Object.assign(Object.assign({}, component), { canUpdateProperty: !component.readOnly, hideLabel: true }), options, data);
10
+ super({
11
+ ...component,
12
+ canUpdateProperty: !component.readOnly,
13
+ hideLabel: true,
14
+ }, options, data);
13
15
  this.handleChangeUserProperty = (value) => {
16
+ delete this.errorDetails['api-error'];
14
17
  // set the value on the form instance at this.root.data
15
18
  const updatedValue = value ? { name: value.label, id: value.value } : '';
16
19
  this.setValue(updatedValue);
17
20
  // update the value in the component instance
18
- this.updateValue(updatedValue !== null && updatedValue !== void 0 ? updatedValue : {}, { modified: true });
21
+ this.updateValue(updatedValue ?? {}, { modified: true });
19
22
  this.handleValidation();
20
23
  this.attach(this.element);
21
24
  this.component.autoSave && this.component.autoSave(value);
22
25
  };
23
26
  this.errorDetails = {};
24
27
  this.criteria = component.validate.criteria;
25
- this.updatedCriteria = (_a = cloneDeep(component.validate.criteria)) !== null && _a !== void 0 ? _a : {};
28
+ this.updatedCriteria = cloneDeep(component.validate.criteria) ?? {};
26
29
  this.handleChangeUserProperty = this.handleChangeUserProperty.bind(this);
27
30
  }
28
31
  init() {
@@ -45,6 +48,42 @@ export class UserComponent extends ReactComponent {
45
48
  }
46
49
  }
47
50
  });
51
+ if (this.component.initialValue && /^{{.*}}$/.test(this.component.initialValue)) {
52
+ const regex = /^{{input\.(?<relatedObjectProperty>[a-zA-Z][a-zA-Z0-9_]*)\.(?<nestedProperty>[a-zA-Z][a-zA-Z0-9_]*)}}$/;
53
+ const groups = regex.exec(this.component.initialValue)?.groups;
54
+ if (groups?.relatedObjectProperty && groups?.nestedProperty) {
55
+ this.on(`changed-${groups.relatedObjectProperty}`, (value) => {
56
+ if (value) {
57
+ this.setValue(value?.[groups.nestedProperty]);
58
+ this.updateValue(value?.[groups.nestedProperty], { modified: true });
59
+ this.attach(this.element);
60
+ }
61
+ });
62
+ }
63
+ }
64
+ this.on(`api-error`, (details) => {
65
+ const error = details.find((detail) => detail.code === 'errorMessage' && detail.path.replace('/', '') === this.component.key);
66
+ if (error) {
67
+ if (!this.root.customErrors.find((err) => err.formattedKeyOrPath === this.component.key && err.message === error.message)) {
68
+ this.root.customErrors = [
69
+ ...this.root.customErrors,
70
+ {
71
+ ...error,
72
+ code: 'api-error',
73
+ component: this.component,
74
+ formattedKeyOrPath: this.component.key,
75
+ },
76
+ ];
77
+ }
78
+ this.errorDetails['api-error'] = error?.message;
79
+ }
80
+ else {
81
+ this.root.customErrors = this.root.customErrors.filter((item) => item.formattedKeyOrPath !== this.component.key);
82
+ delete this.errorDetails['api-error'];
83
+ }
84
+ this.attach(this.element);
85
+ this.attachReact(this.element);
86
+ });
48
87
  }
49
88
  clearErrors() {
50
89
  this.errorDetails = {};
@@ -68,10 +107,9 @@ export class UserComponent extends ReactComponent {
68
107
  * Synchronizes out-of-the-box formio errors with this field's errorDetails object
69
108
  */
70
109
  manageFormErrors() {
71
- var _a;
72
- const outOfTheBoxError = (_a = this.root.errors.find((error) => {
110
+ const outOfTheBoxError = this.root.errors.find((error) => {
73
111
  return error.component.key === this.component.key;
74
- })) === null || _a === void 0 ? void 0 : _a.message;
112
+ })?.message;
75
113
  // add OoB formio error to errorDetails object to show under field
76
114
  if (outOfTheBoxError) {
77
115
  this.errorDetails['rootError'] = outOfTheBoxError;
@@ -85,15 +123,20 @@ export class UserComponent extends ReactComponent {
85
123
  this.element && this.attach(this.element);
86
124
  }
87
125
  attachReact(element) {
88
- var _a;
89
- const updatedComponent = Object.assign(Object.assign({}, this.component), { instance: Object.assign(Object.assign({}, this.component.instance), { [this.component.key]: isEmpty(this.dataValue) ? null : this.dataValue }) });
126
+ const updatedComponent = {
127
+ ...this.component,
128
+ instance: {
129
+ ...this.component.instance,
130
+ [this.component.key]: isEmpty(this.dataValue) ? null : this.dataValue,
131
+ },
132
+ };
90
133
  if (!this.componentRoot) {
91
134
  this.componentRoot = createRoot(element, { onRecoverableError: console.error });
92
135
  }
93
136
  // FormIO uses id for an enclosing div, so we need to give the input field a different id.
94
137
  const inputId = `${this.component.id}-input`;
95
138
  return this.componentRoot.render(React.createElement("div", null,
96
- React.createElement(FormComponentWrapper, Object.assign({}, updatedComponent, { inputId: inputId, errorMessage: this.errorMessages() }),
97
- React.createElement(UserProperty, Object.assign({}, updatedComponent, { id: inputId, value: (_a = this.dataValue) !== null && _a !== void 0 ? _a : '', handleChangeUserProperty: this.handleChangeUserProperty, error: this.hasErrors(), filter: this.criteria ? { where: transformToWhere(this.updatedCriteria) } : undefined })))));
139
+ React.createElement(FormComponentWrapper, { ...updatedComponent, inputId: inputId, errorMessage: this.errorMessages() },
140
+ React.createElement(UserProperty, { ...updatedComponent, id: inputId, value: this.dataValue ?? '', handleChangeUserProperty: this.handleChangeUserProperty, error: this.hasErrors(), filter: this.criteria ? { where: transformToWhere(this.updatedCriteria) } : undefined }))));
98
141
  }
99
142
  }
@@ -10,8 +10,8 @@ export const UserProperty = (props) => {
10
10
  const [users, setUsers] = useState();
11
11
  const [userValue, setUserValue] = useState();
12
12
  useEffect(() => {
13
- if (value === '$_CURRENT' && (user === null || user === void 0 ? void 0 : user.id)) {
14
- const loggedInUser = users === null || users === void 0 ? void 0 : users.find((u) => u.id === user.id);
13
+ if (value === '$_CURRENT' && user?.id) {
14
+ const loggedInUser = users?.find((u) => u.id === user.id);
15
15
  if (loggedInUser) {
16
16
  setUserValue({ label: loggedInUser.name, value: loggedInUser.id });
17
17
  handleChangeUserProperty({ label: loggedInUser.name, value: loggedInUser.id });
@@ -31,7 +31,7 @@ export const UserProperty = (props) => {
31
31
  setLoadingOptions(true);
32
32
  apiServices.get(getPrefixedUrl(`/users`), (error, userList) => {
33
33
  setUsers(userList);
34
- setOptions((userList !== null && userList !== void 0 ? userList : []).map((user) => ({ label: user.name, value: user.id })));
34
+ setOptions((userList ?? []).map((user) => ({ label: user.name, value: user.id })));
35
35
  setLoadingOptions(false);
36
36
  });
37
37
  }
@@ -58,33 +58,33 @@ export const UserProperty = (props) => {
58
58
  },
59
59
  } }, children));
60
60
  }, sx: {
61
- '& button.MuiButtonBase-root': Object.assign({}, (!loadingOptions && value
62
- ? {
63
- visibility: 'visible',
64
- }
65
- : {})),
61
+ '& button.MuiButtonBase-root': {
62
+ ...(!loadingOptions && value
63
+ ? {
64
+ visibility: 'visible',
65
+ }
66
+ : {}),
67
+ },
66
68
  }, noOptionsText: 'No options available', renderOption: (props, option) => {
67
- var _a;
68
- return (React.createElement("li", Object.assign({}, props, { key: option.id }),
69
+ return (React.createElement("li", { ...props, key: option.id },
69
70
  React.createElement(Typography, { sx: { marginLeft: '8px', fontSize: '14px' } },
70
71
  option.label,
71
72
  " ",
72
73
  '',
73
- ((_a = users === null || users === void 0 ? void 0 : users.find((user) => option.value === user.id)) === null || _a === void 0 ? void 0 : _a.status) === 'Inactive' ? (React.createElement("span", null, "(Inactive)")) : (''))));
74
+ users?.find((user) => option.value === user.id)?.status === 'Inactive' ? (React.createElement("span", null, "(Inactive)")) : (''))));
74
75
  }, onOpen: () => {
75
76
  setOpenOptions(true);
76
- }, onClose: () => setOpenOptions(false), value: userValue !== null && userValue !== void 0 ? userValue : '', options: options, getOptionLabel: (option) => {
77
- var _a, _b, _c, _d;
77
+ }, onClose: () => setOpenOptions(false), value: userValue ?? '', options: options, getOptionLabel: (option) => {
78
78
  if (typeof option === 'string') {
79
- return (_b = (_a = options.find((o) => o.value === option)) === null || _a === void 0 ? void 0 : _a.label) !== null && _b !== void 0 ? _b : '';
79
+ return options.find((o) => o.value === option)?.label ?? '';
80
80
  }
81
81
  else {
82
82
  {
83
- if (((_c = users === null || users === void 0 ? void 0 : users.find((user) => option.value === user.id)) === null || _c === void 0 ? void 0 : _c.status) === 'Inactive') {
83
+ if (users?.find((user) => option.value === user.id)?.status === 'Inactive') {
84
84
  return option.label + ' (Inactive)';
85
85
  }
86
86
  else {
87
- return (_d = option.label) !== null && _d !== void 0 ? _d : '';
87
+ return option.label ?? '';
88
88
  }
89
89
  }
90
90
  }
@@ -96,20 +96,22 @@ export const UserProperty = (props) => {
96
96
  if (typeof value === 'string') {
97
97
  return option.value === value;
98
98
  }
99
- return option.value === (value === null || value === void 0 ? void 0 : value.value);
99
+ return option.value === value?.value;
100
100
  }, onChange: (event, value) => {
101
101
  handleChangeUserProperty(value);
102
- }, selectOnFocus: false, renderInput: (params) => (React.createElement(TextField, Object.assign({}, params, { placeholder: 'Select', sx: Object.assign({}, (!loadingOptions && value
103
- ? {
104
- '.MuiOutlinedInput-root': {
105
- background: 'white',
106
- border: 'auto',
107
- },
108
- '& fieldset': { borderColor: 'auto' },
109
- '&:hover .MuiOutlinedInput-notchedOutline': {
110
- border: 'auto',
111
- },
112
- caretColor: 'white',
113
- }
114
- : {})), size: fieldHeight !== null && fieldHeight !== void 0 ? fieldHeight : 'medium' }))), error: error }))));
102
+ }, selectOnFocus: false, renderInput: (params) => (React.createElement(TextField, { ...params, placeholder: 'Select', sx: {
103
+ ...(!loadingOptions && value
104
+ ? {
105
+ '.MuiOutlinedInput-root': {
106
+ background: 'white',
107
+ border: 'auto',
108
+ },
109
+ '& fieldset': { borderColor: 'auto' },
110
+ '&:hover .MuiOutlinedInput-notchedOutline': {
111
+ border: 'auto',
112
+ },
113
+ caretColor: 'white',
114
+ }
115
+ : {}),
116
+ }, size: fieldHeight ?? 'medium' })), error: error }))));
115
117
  };