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

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 +105 -82
  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
@@ -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 { useApp, useAuthenticationContext, } from '@evoke-platform/context';
11
2
  import { Components, Form as FormIO } from '@formio/react';
12
3
  import { flatten } from 'flat';
@@ -25,13 +16,12 @@ const usePrevious = (value) => {
25
16
  return ref.current;
26
17
  };
27
18
  export function Form(props) {
28
- var _a;
29
19
  const { clearable, closeModal, onSave, submitButtonLabel, instance, object, objectInputCommonProps, actionId, actionType, associatedObject, onAutoSave, apiServices, navigateTo, document, queryAddresses, user, isReadOnly, fieldHeight, richTextEditor, } = props;
30
20
  const [formKey, setFormKey] = useState();
31
21
  const [componentProps, setComponentProps] = useState([]);
32
22
  const [snackbarError, setSnackbarError] = useState();
33
23
  const prevFormKey = usePrevious(formKey);
34
- const userAccount = user !== null && user !== void 0 ? user : (_a = useAuthenticationContext()) === null || _a === void 0 ? void 0 : _a.account;
24
+ const userAccount = user ?? useAuthenticationContext()?.account;
35
25
  const { defaultPages, findDefaultPageSlugFor } = useApp();
36
26
  const rebuildFormComponents = () => {
37
27
  const viewDetailsComponents = {
@@ -53,7 +43,30 @@ export function Form(props) {
53
43
  ViewOnlyImage: ImageComponent,
54
44
  ViewOnlyTime: ViewOnlyComponent,
55
45
  };
56
- Components.setComponents(Object.assign(Object.assign(Object.assign({}, Components.components), { Boolean: FormFieldComponent, Columns: Components.components.columns, DateTime: FormFieldComponent, Date: FormFieldComponent, Select: FormFieldComponent, MultiSelect: FormFieldComponent, Object: ObjectComponent, User: UserComponent, TextField: FormFieldComponent, Decimal: FormFieldComponent, Document: DocumentComponent, Integer: FormFieldComponent, Buttons: ButtonComponent, Content: Components.components.content, RichText: richTextEditor, Section: Components.components.tabs, ManyToManyRepeatableField: RepeatableFieldComponent, RepeatableField: RepeatableFieldComponent, Image: ImageComponent, Time: FormFieldComponent }), (isReadOnly && viewDetailsComponents)));
46
+ Components.setComponents({
47
+ ...Components.components,
48
+ Boolean: FormFieldComponent,
49
+ Columns: Components.components.columns,
50
+ DateTime: FormFieldComponent,
51
+ Date: FormFieldComponent,
52
+ Select: FormFieldComponent,
53
+ MultiSelect: FormFieldComponent,
54
+ Object: ObjectComponent,
55
+ User: UserComponent,
56
+ TextField: FormFieldComponent,
57
+ Decimal: FormFieldComponent,
58
+ Document: DocumentComponent,
59
+ Integer: FormFieldComponent,
60
+ Buttons: ButtonComponent,
61
+ Content: Components.components.content,
62
+ RichText: richTextEditor,
63
+ Section: Components.components.tabs,
64
+ ManyToManyRepeatableField: RepeatableFieldComponent,
65
+ RepeatableField: RepeatableFieldComponent,
66
+ Image: ImageComponent,
67
+ Time: FormFieldComponent,
68
+ ...(isReadOnly && viewDetailsComponents),
69
+ });
57
70
  buildComponents();
58
71
  };
59
72
  useEffect(() => {
@@ -68,55 +81,59 @@ export function Form(props) {
68
81
  buildComponents();
69
82
  }
70
83
  }, [formKey]);
71
- const buildComponents = () => __awaiter(this, void 0, void 0, function* () {
72
- var _b, _c, _d;
73
- const action = (_b = object === null || object === void 0 ? void 0 : object.actions) === null || _b === void 0 ? void 0 : _b.find((action) => action.id === actionId);
84
+ const buildComponents = async () => {
85
+ const action = object?.actions?.find((action) => action.id === actionId);
74
86
  let input;
75
- const parameters = (associatedObject === null || associatedObject === void 0 ? void 0 : associatedObject.propertyId) && (action === null || action === void 0 ? void 0 : action.parameters)
76
- ? action.parameters.filter((param) => param.id !== (associatedObject === null || associatedObject === void 0 ? void 0 : associatedObject.propertyId))
77
- : action === null || action === void 0 ? void 0 : action.parameters;
87
+ const parameters = associatedObject?.propertyId && action?.parameters
88
+ ? action.parameters.filter((param) => param.id !== associatedObject?.propertyId)
89
+ : action?.parameters;
78
90
  if (parameters && object) {
79
- input = ((_c = action === null || action === void 0 ? void 0 : action.form) === null || _c === void 0 ? void 0 : _c.entries)
91
+ input = action?.form?.entries
80
92
  ? convertFormToComponents(action.form.entries, parameters, object)
81
- : parameters.filter((param) => { var _a; return (_a = object.properties) === null || _a === void 0 ? void 0 : _a.some((prop) => prop.id === param.id); });
93
+ : parameters.filter((param) => object.properties?.some((prop) => prop.id === param.id));
82
94
  }
83
95
  else {
84
- input = (_d = action === null || action === void 0 ? void 0 : action.inputProperties) !== null && _d !== void 0 ? _d : ((action === null || action === void 0 ? void 0 : action.type) === 'delete' ? [] : undefined);
96
+ input = action?.inputProperties ?? (action?.type === 'delete' ? [] : undefined);
85
97
  }
86
- let visibleObjectProperties = object === null || object === void 0 ? void 0 : object.properties;
98
+ let visibleObjectProperties = object?.properties;
87
99
  if (associatedObject) {
88
100
  // Eliminates the associated object's field from the form
89
- visibleObjectProperties = visibleObjectProperties === null || visibleObjectProperties === void 0 ? void 0 : visibleObjectProperties.filter((property) => property.id !== associatedObject.propertyId);
101
+ visibleObjectProperties = visibleObjectProperties?.filter((property) => property.id !== associatedObject.propertyId);
90
102
  }
91
103
  let foundDefaultPages = defaultPages;
92
- const relatedObjectProperties = visibleObjectProperties === null || visibleObjectProperties === void 0 ? void 0 : visibleObjectProperties.filter((property) => property.type === 'object');
104
+ const relatedObjectProperties = visibleObjectProperties?.filter((property) => property.type === 'object');
93
105
  if (relatedObjectProperties) {
94
- foundDefaultPages = yield relatedObjectProperties.reduce((acc, property) => __awaiter(this, void 0, void 0, function* () {
95
- const result = yield acc;
106
+ foundDefaultPages = await relatedObjectProperties.reduce(async (acc, property) => {
107
+ const result = await acc;
96
108
  if (property.objectId && defaultPages && defaultPages[property.objectId]) {
97
- const slug = yield findDefaultPageSlugFor(property.objectId);
109
+ const slug = await findDefaultPageSlugFor(property.objectId);
98
110
  if (slug) {
99
- return Object.assign(Object.assign({}, result), { [property.objectId]: slug });
111
+ return { ...result, [property.objectId]: slug };
100
112
  }
101
113
  }
102
114
  return result;
103
- }), Promise.resolve({}));
115
+ }, Promise.resolve({}));
104
116
  }
105
- const allDefaultPages = Object.assign(Object.assign({}, defaultPages), foundDefaultPages);
117
+ const allDefaultPages = { ...defaultPages, ...foundDefaultPages };
106
118
  if (input && visibleObjectProperties) {
107
- if (input.length || (action === null || action === void 0 ? void 0 : action.type) !== 'delete') {
119
+ if (input.length || action?.type !== 'delete') {
108
120
  // formIO builder-configured input properties exist
109
- const newComponentProps = yield addObjectPropertiesToComponentProps(visibleObjectProperties, input, instance, Object.assign(Object.assign({}, objectInputCommonProps), { defaultPages: allDefaultPages, navigateTo,
110
- apiServices, user: userAccount }), undefined, isReadOnly, allDefaultPages, navigateTo, queryAddresses, apiServices, !!closeModal, fieldHeight);
121
+ const newComponentProps = await addObjectPropertiesToComponentProps(visibleObjectProperties, input, instance, {
122
+ ...objectInputCommonProps,
123
+ defaultPages: allDefaultPages,
124
+ navigateTo,
125
+ apiServices,
126
+ user: userAccount,
127
+ }, undefined, isReadOnly, allDefaultPages, navigateTo, queryAddresses, apiServices, !!closeModal, fieldHeight);
111
128
  const components = isReadOnly ? newComponentProps : [...newComponentProps, BottomButtons];
112
129
  setComponentProps(components);
113
130
  }
114
131
  else {
115
132
  // this condition is used for the delete action's modal form
116
133
  setComponentProps([
117
- ...(yield addObjectPropertiesToComponentProps(visibleObjectProperties, [
134
+ ...(await addObjectPropertiesToComponentProps(visibleObjectProperties, [
118
135
  {
119
- html: `<p>${(action === null || action === void 0 ? void 0 : action.type) === 'delete' ? 'This action cannot be undone.' : 'Are you sure?'}</p>`,
136
+ html: `<p>${action?.type === 'delete' ? 'This action cannot be undone.' : 'Are you sure?'}</p>`,
120
137
  label: 'Content',
121
138
  customClass: '',
122
139
  refreshOnChange: false,
@@ -182,33 +199,41 @@ export function Form(props) {
182
199
  addons: [],
183
200
  id: 'eahbwo',
184
201
  },
185
- ], instance, Object.assign(Object.assign({}, objectInputCommonProps), { defaultPages: allDefaultPages, navigateTo,
186
- apiServices, user: userAccount }), undefined, undefined, undefined, undefined, undefined, undefined, !!closeModal, fieldHeight)),
202
+ ], instance, {
203
+ ...objectInputCommonProps,
204
+ defaultPages: allDefaultPages,
205
+ navigateTo,
206
+ apiServices,
207
+ user: userAccount,
208
+ }, undefined, undefined, undefined, undefined, undefined, undefined, !!closeModal, fieldHeight)),
187
209
  BottomButtons,
188
210
  ]);
189
211
  }
190
212
  }
191
- else if (object === null || object === void 0 ? void 0 : object.properties) {
213
+ else if (object?.properties) {
192
214
  // If form.io form is not configured and no inputProperties are
193
215
  // set, use object properties to build form.
194
- const propertiesInForm = object.properties.filter((prop) => prop.id !== (associatedObject === null || associatedObject === void 0 ? void 0 : associatedObject.propertyId) && ((action === null || action === void 0 ? void 0 : action.type) !== 'create' || prop.type !== 'document'));
216
+ const propertiesInForm = object.properties.filter((prop) => prop.id !== associatedObject?.propertyId && (action?.type !== 'create' || prop.type !== 'document'));
195
217
  setComponentProps([
196
- ...buildComponentPropsFromObjectProperties(propertiesInForm, object.id, instance, Object.assign(Object.assign({}, objectInputCommonProps), { defaultPages: allDefaultPages, navigateTo,
218
+ ...buildComponentPropsFromObjectProperties(propertiesInForm, object.id, instance, {
219
+ ...objectInputCommonProps,
220
+ defaultPages: allDefaultPages,
221
+ navigateTo,
197
222
  apiServices,
198
- user }), !!action, undefined, isReadOnly, queryAddresses, !!closeModal, fieldHeight),
223
+ user,
224
+ }, !!action, undefined, isReadOnly, queryAddresses, !!closeModal, fieldHeight),
199
225
  !isReadOnly && BottomButtons,
200
226
  ]);
201
227
  }
202
228
  else if (document) {
203
- const documentProperties = toPairs(flatten(document !== null && document !== void 0 ? document : {}));
229
+ const documentProperties = toPairs(flatten(document ?? {}));
204
230
  setComponentProps([
205
231
  ...buildComponentPropsFromDocumentProperties(documentProperties, isReadOnly, undefined, fieldHeight),
206
232
  !isReadOnly && BottomButtons,
207
233
  ]);
208
234
  }
209
- });
210
- const uploadDocuments = (files, metadata) => __awaiter(this, void 0, void 0, function* () {
211
- var _e;
235
+ };
236
+ const uploadDocuments = async (files, metadata) => {
212
237
  const allDocuments = [];
213
238
  const formData = new FormData();
214
239
  for (const [index, file] of files.entries()) {
@@ -224,29 +249,32 @@ export function Form(props) {
224
249
  formData.append(key, value);
225
250
  }
226
251
  }
227
- const docs = yield (apiServices === null || apiServices === void 0 ? void 0 : apiServices.post(getPrefixedUrl(`/objects/${object === null || object === void 0 ? void 0 : object.id}/instances/${instance === null || instance === void 0 ? void 0 : instance.id}/documents`), formData));
228
- return allDocuments.concat((_e = docs === null || docs === void 0 ? void 0 : docs.map((doc) => ({ id: doc.id, name: doc.name }))) !== null && _e !== void 0 ? _e : []);
229
- });
230
- const saveDocuments = (submittedFields, action) => __awaiter(this, void 0, void 0, function* () {
231
- var _f, _g, _h, _j;
232
- const documentProperties = (action === null || action === void 0 ? void 0 : action.parameters)
252
+ const docs = await apiServices?.post(getPrefixedUrl(`/objects/${object?.id}/instances/${instance?.id}/documents`), formData);
253
+ return allDocuments.concat(docs?.map((doc) => ({ id: doc.id, name: doc.name })) ?? []);
254
+ };
255
+ const saveDocuments = async (submittedFields, action) => {
256
+ const documentProperties = action?.parameters
233
257
  ? action.parameters.filter((param) => param.type === 'document')
234
- : (_f = object === null || object === void 0 ? void 0 : object.properties) === null || _f === void 0 ? void 0 : _f.filter((prop) => prop.type === 'document');
258
+ : object?.properties?.filter((prop) => prop.type === 'document');
235
259
  let allEntries = null;
236
- for (const docProperty of documentProperties !== null && documentProperties !== void 0 ? documentProperties : []) {
260
+ for (const docProperty of documentProperties ?? []) {
237
261
  const value = submittedFields[docProperty.id];
238
262
  // skip if the document list did not change
239
- if (value === undefined || !instance || isEqual(instance === null || instance === void 0 ? void 0 : instance[docProperty.id], value)) {
263
+ if (value === undefined || !instance || isEqual(instance?.[docProperty.id], value)) {
240
264
  continue;
241
265
  }
242
266
  let savedDocuments = null;
243
267
  if (value && value.some((doc) => doc instanceof File)) {
244
268
  if (!allEntries) {
245
- allEntries = (_j = getFlattenEntries((_h = (_g = action === null || action === void 0 ? void 0 : action.form) === null || _g === void 0 ? void 0 : _g.entries) !== null && _h !== void 0 ? _h : [])) !== null && _j !== void 0 ? _j : [];
269
+ allEntries = getFlattenEntries(action?.form?.entries ?? []) ?? [];
246
270
  }
247
271
  const docEntry = allEntries.find((entry) => entry.parameterId === docProperty.id);
248
272
  try {
249
- savedDocuments = yield uploadDocuments(value, Object.assign({ type: '', view_permission: '' }, docEntry === null || docEntry === void 0 ? void 0 : docEntry.documentMetadata));
273
+ savedDocuments = await uploadDocuments(value, {
274
+ type: '',
275
+ view_permission: '',
276
+ ...docEntry?.documentMetadata,
277
+ });
250
278
  }
251
279
  catch (error) {
252
280
  setSnackbarError({ message: `An error occurred while uploading associated documents` });
@@ -260,32 +288,30 @@ export function Form(props) {
260
288
  submittedFields[docProperty.id] = savedDocuments;
261
289
  }
262
290
  return true;
263
- });
264
- const deleteDocuments = (submittedFields, requestSuccess, action) => __awaiter(this, void 0, void 0, function* () {
265
- var _k, _l, _m, _o;
266
- const documentProperties = (action === null || action === void 0 ? void 0 : action.parameters)
291
+ };
292
+ const deleteDocuments = async (submittedFields, requestSuccess, action) => {
293
+ const documentProperties = action?.parameters
267
294
  ? action.parameters.filter((param) => param.type === 'document')
268
- : (_k = object === null || object === void 0 ? void 0 : object.properties) === null || _k === void 0 ? void 0 : _k.filter((prop) => prop.type === 'document');
269
- for (const docProperty of documentProperties !== null && documentProperties !== void 0 ? documentProperties : []) {
295
+ : object?.properties?.filter((prop) => prop.type === 'document');
296
+ for (const docProperty of documentProperties ?? []) {
270
297
  const savedValue = submittedFields[docProperty.id];
271
- const originalValue = instance === null || instance === void 0 ? void 0 : instance[docProperty.id];
298
+ const originalValue = instance?.[docProperty.id];
272
299
  const documentsToRemove = requestSuccess
273
- ? (_l = originalValue === null || originalValue === void 0 ? void 0 : originalValue.filter((file) => !(savedValue === null || savedValue === void 0 ? void 0 : savedValue.some((f) => f.id === file.id)))) !== null && _l !== void 0 ? _l : []
274
- : (_m = savedValue === null || savedValue === void 0 ? void 0 : savedValue.filter((file) => !(originalValue === null || originalValue === void 0 ? void 0 : originalValue.some((f) => f.id === file.id)))) !== null && _m !== void 0 ? _m : [];
300
+ ? originalValue?.filter((file) => !savedValue?.some((f) => f.id === file.id)) ?? []
301
+ : savedValue?.filter((file) => !originalValue?.some((f) => f.id === file.id)) ?? [];
275
302
  for (const doc of documentsToRemove) {
276
303
  try {
277
- yield (apiServices === null || apiServices === void 0 ? void 0 : apiServices.delete(getPrefixedUrl(`/objects/${object === null || object === void 0 ? void 0 : object.id}/instances/${instance === null || instance === void 0 ? void 0 : instance.id}/documents/${doc.id}`)));
304
+ await apiServices?.delete(getPrefixedUrl(`/objects/${object?.id}/instances/${instance?.id}/documents/${doc.id}`));
278
305
  }
279
306
  catch (error) {
280
- if (((_o = error.response) === null || _o === void 0 ? void 0 : _o.status) !== 404) {
307
+ if (error.response?.status !== 404) {
281
308
  setSnackbarError({ message: `An error occurred while removing document '${doc.name}'` });
282
309
  }
283
310
  }
284
311
  }
285
312
  }
286
- });
287
- const saveHandler = (submission, type, setError, setSubmitting) => __awaiter(this, void 0, void 0, function* () {
288
- var _p;
313
+ };
314
+ const saveHandler = async (submission, type, setError, setSubmitting) => {
289
315
  const submittedFields = {};
290
316
  for (const field in submission.data) {
291
317
  const value = submission.data[field];
@@ -299,32 +325,32 @@ export function Form(props) {
299
325
  //OPTIMIZATION TODO: See if type can be inferred from the event target
300
326
  if (type === 'submit') {
301
327
  if (onSave) {
302
- const action = (_p = object === null || object === void 0 ? void 0 : object.actions) === null || _p === void 0 ? void 0 : _p.find((action) => action.id === actionId);
303
- const documentsUploaded = yield saveDocuments(submittedFields, action);
328
+ const action = object?.actions?.find((action) => action.id === actionId);
329
+ const documentsUploaded = await saveDocuments(submittedFields, action);
304
330
  if (documentsUploaded) {
305
331
  try {
306
- const { isSuccessful, error } = yield onSave(submittedFields, setSubmitting);
332
+ const { isSuccessful, error } = await onSave(submittedFields, setSubmitting);
307
333
  setError(error);
308
334
  // Delete the documents that were removed if save was successful,
309
335
  // otherwise delete the documents that were uploaded.
310
- yield deleteDocuments(submittedFields, isSuccessful, action);
336
+ await deleteDocuments(submittedFields, isSuccessful, action);
311
337
  !error && !closeModal && setFormKey(Date.now());
312
338
  }
313
339
  catch (err) {
314
340
  // If the save fails, delete the documents that were just uploaded
315
- yield deleteDocuments(submittedFields, false, action);
341
+ await deleteDocuments(submittedFields, false, action);
316
342
  }
317
343
  }
318
344
  }
319
345
  }
320
346
  else {
321
347
  if (onAutoSave) {
322
- const documentsUploaded = yield saveDocuments(submittedFields);
348
+ const documentsUploaded = await saveDocuments(submittedFields);
323
349
  if (!documentsUploaded) {
324
350
  return;
325
351
  }
326
352
  try {
327
- const { isSuccessful, error } = yield onAutoSave(submittedFields);
353
+ const { isSuccessful, error } = await onAutoSave(submittedFields);
328
354
  // Delete the documents that were removed if save was successful,
329
355
  // otherwise delete the documents that were uploaded.
330
356
  deleteDocuments(submittedFields, isSuccessful);
@@ -336,7 +362,7 @@ export function Form(props) {
336
362
  }
337
363
  }
338
364
  }
339
- });
365
+ };
340
366
  const BottomButtons = {
341
367
  type: 'Buttons',
342
368
  key: 'cancel-submit',
@@ -367,7 +393,7 @@ export function Form(props) {
367
393
  key: 'save-draft',
368
394
  variant: 'outlined',
369
395
  isModal: !!closeModal,
370
- onClick: (data, setError, setSubmitting) => __awaiter(this, void 0, void 0, function* () { return yield saveHandler(data, 'draft', setError, setSubmitting); }),
396
+ onClick: async (data, setError, setSubmitting) => await saveHandler(data, 'draft', setError, setSubmitting),
371
397
  style: { lineHeight: '2.75', margin: '5px', padding: '0 10px' },
372
398
  }
373
399
  : undefined,
@@ -408,6 +434,6 @@ export function Form(props) {
408
434
  React.createElement(Box, { display: 'flex', width: '100%', justifyContent: 'space-between' },
409
435
  React.createElement(Skeleton, { width: '48%', sx: { borderRadius: '8px', height: '40px' } }),
410
436
  React.createElement(Skeleton, { width: '48%', sx: { borderRadius: '8px', height: '40px' } })))),
411
- React.createElement(Snackbar, { open: !!(snackbarError === null || snackbarError === void 0 ? void 0 : snackbarError.message), handleClose: () => setSnackbarError(undefined), message: snackbarError === null || snackbarError === void 0 ? void 0 : snackbarError.message, error: true })));
437
+ React.createElement(Snackbar, { open: !!snackbarError?.message, handleClose: () => setSnackbarError(undefined), message: snackbarError?.message, error: true })));
412
438
  }
413
439
  export default Form;
@@ -16,17 +16,26 @@ const descriptionStyles = {
16
16
  const PrefixSuffix = (props) => {
17
17
  const { prefix, suffix, height } = props;
18
18
  const text = prefix || suffix;
19
- const prefixSuffixStyles = Object.assign(Object.assign(Object.assign({ display: 'inline-flex', alignItems: 'center', background: '#f5f5f5', padding: '5px', border: '1px solid #ccc' }, (suffix && {
20
- borderTopRightRadius: '5px',
21
- borderBottomRightRadius: '5px',
22
- marginLeft: '-5px',
23
- paddingLeft: '10px',
24
- })), (prefix && {
25
- borderTopLeftRadius: '5px',
26
- borderBottomLeftRadius: '5px',
27
- marginRight: '-5px',
28
- paddingRight: '10px',
29
- })), { height: height });
19
+ const prefixSuffixStyles = {
20
+ display: 'inline-flex',
21
+ alignItems: 'center',
22
+ background: '#f5f5f5',
23
+ padding: '5px',
24
+ border: '1px solid #ccc',
25
+ ...(suffix && {
26
+ borderTopRightRadius: '5px',
27
+ borderBottomRightRadius: '5px',
28
+ marginLeft: '-5px',
29
+ paddingLeft: '10px',
30
+ }),
31
+ ...(prefix && {
32
+ borderTopLeftRadius: '5px',
33
+ borderBottomLeftRadius: '5px',
34
+ marginRight: '-5px',
35
+ paddingRight: '10px',
36
+ }),
37
+ height: height,
38
+ };
30
39
  if (!prefix && !suffix)
31
40
  return null;
32
41
  return (React.createElement(Box, { sx: prefixSuffixStyles },
@@ -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
  /* eslint-disable @typescript-eslint/no-explicit-any */
11
2
  import { ReactComponent } from '@formio/react';
12
3
  import { groupBy, isEmpty } from 'lodash';
@@ -21,12 +12,11 @@ export class ButtonComponent extends ReactComponent {
21
12
  constructor(component, options, data) {
22
13
  super(component, options, data);
23
14
  this.getButton = (buttonAction) => {
24
- var _a;
25
- return (_a = this.component.components) === null || _a === void 0 ? void 0 : _a.find((button) => button && button.action == buttonAction);
15
+ return this.component.components?.find((button) => button && button.action == buttonAction);
26
16
  };
27
17
  this.handleCancel = (event) => {
28
18
  const cancelButton = this.getButton('cancel');
29
- cancelButton === null || cancelButton === void 0 ? void 0 : cancelButton.onClick(event);
19
+ cancelButton?.onClick(event);
30
20
  };
31
21
  this.handleSaveDraft = (setSubmitting) => {
32
22
  setSubmitting(true);
@@ -79,17 +69,16 @@ export class ButtonComponent extends ReactComponent {
79
69
  setTimeout(() => {
80
70
  const element = document.getElementById(`error-list-${this.root.id}`);
81
71
  submitButton.isModal
82
- ? element === null || element === void 0 ? void 0 : element.scrollIntoView({ block: 'nearest' })
72
+ ? element?.scrollIntoView({ block: 'nearest' })
83
73
  : this.scrollIntoViewWithOffset(element, 170);
84
74
  }, 0);
85
75
  setSubmitting(false);
86
76
  }
87
77
  };
88
78
  this.scrollIntoViewWithOffset = (el, offset) => {
89
- var _a, _b, _c;
90
79
  window.scrollTo({
91
80
  behavior: 'smooth',
92
- top: ((_a = el === null || el === void 0 ? void 0 : el.getBoundingClientRect()) === null || _a === void 0 ? void 0 : _a.top) - ((_c = (_b = document === null || document === void 0 ? void 0 : document.body) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect()) === null || _c === void 0 ? void 0 : _c.top) - offset,
81
+ top: el?.getBoundingClientRect()?.top - document?.body?.getBoundingClientRect()?.top - offset,
93
82
  });
94
83
  };
95
84
  this.setButtonKey = (value) => {
@@ -103,15 +92,15 @@ export class ButtonComponent extends ReactComponent {
103
92
  this.buttonKey = nanoid();
104
93
  }
105
94
  setError(error) {
106
- if ((error === null || error === void 0 ? void 0 : error.statusCode) === 422) {
95
+ if (error?.statusCode === 422) {
107
96
  for (const [key, details] of Object.entries(groupBy(error.details, 'path'))) {
108
97
  this.emit(`error-${key.replace('/', '')}`, details);
109
98
  }
110
99
  setTimeout(() => {
111
100
  const submitButton = this.getButton('submit');
112
101
  const element = document.getElementById(`error-list-${this.root.id}`);
113
- (submitButton === null || submitButton === void 0 ? void 0 : submitButton.isModal)
114
- ? element === null || element === void 0 ? void 0 : element.scrollIntoView({ block: 'nearest' })
102
+ submitButton?.isModal
103
+ ? element?.scrollIntoView({ block: 'nearest' })
115
104
  : this.scrollIntoViewWithOffset(element, 170);
116
105
  }, 100);
117
106
  }
@@ -131,7 +120,7 @@ export class ButtonComponent extends ReactComponent {
131
120
  const Button = (props) => {
132
121
  const { button, handleSubmit, handleCancel, handleSaveDraft, setButtonKey } = props;
133
122
  const [submitting, setSubmitting] = useState(false);
134
- return (React.createElement(LoadingButton, { sx: button.style, variant: button.variant, onClick: (event) => __awaiter(void 0, void 0, void 0, function* () {
123
+ return (React.createElement(LoadingButton, { sx: button.style, variant: button.variant, onClick: async (event) => {
135
124
  switch (button.action) {
136
125
  case 'submit':
137
126
  handleSubmit(setSubmitting);
@@ -146,5 +135,5 @@ const Button = (props) => {
146
135
  default:
147
136
  button.onClick();
148
137
  }
149
- }), loading: submitting }, button.label));
138
+ }, loading: submitting }, button.label));
150
139
  };
@@ -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 { isNil } from 'lodash';
11
2
  import React, { useEffect, useState } from 'react';
12
3
  import { useDropzone } from 'react-dropzone';
@@ -16,7 +7,6 @@ import { Box, Grid } from '../../../../layout';
16
7
  import { getPrefixedUrl } from '../../utils';
17
8
  import { DocumentList } from './DocumentList';
18
9
  export const Document = (props) => {
19
- var _a;
20
10
  const { id, handleChange, property, instance, canUpdateProperty, apiServices, error, objectId, value, validate } = props;
21
11
  const [documents, setDocuments] = useState();
22
12
  const [hasUpdatePermission, setHasUpdatePermission] = useState();
@@ -25,8 +15,8 @@ export const Document = (props) => {
25
15
  setDocuments(value);
26
16
  }, [value]);
27
17
  useEffect(() => {
28
- const currentValue = instance === null || instance === void 0 ? void 0 : instance[property.id];
29
- if (currentValue === null || currentValue === void 0 ? void 0 : currentValue.length) {
18
+ const currentValue = instance?.[property.id];
19
+ if (currentValue?.length) {
30
20
  setDocuments(currentValue);
31
21
  }
32
22
  }, [property]);
@@ -40,19 +30,19 @@ export const Document = (props) => {
40
30
  .then((accessCheck) => setHasUpdatePermission(accessCheck.result));
41
31
  }
42
32
  };
43
- const handleUpload = (files) => __awaiter(void 0, void 0, void 0, function* () {
44
- const newDocuments = [...(documents !== null && documents !== void 0 ? documents : []), ...(files !== null && files !== void 0 ? files : [])];
33
+ const handleUpload = async (files) => {
34
+ const newDocuments = [...(documents ?? []), ...(files ?? [])];
45
35
  setDocuments(newDocuments);
46
36
  handleChange(property.id, newDocuments);
47
- });
48
- const uploadDisabled = !!(validate === null || validate === void 0 ? void 0 : validate.maxDocuments) && ((_a = documents === null || documents === void 0 ? void 0 : documents.length) !== null && _a !== void 0 ? _a : 0) >= validate.maxDocuments;
37
+ };
38
+ const uploadDisabled = !!validate?.maxDocuments && (documents?.length ?? 0) >= validate.maxDocuments;
49
39
  const { getRootProps, getInputProps, open } = useDropzone({
50
40
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
51
41
  onDrop: (files) => handleUpload(files),
52
42
  disabled: uploadDisabled,
53
43
  });
54
44
  return (React.createElement(React.Fragment, null,
55
- canUpdateProperty && hasUpdatePermission && (React.createElement(Box, Object.assign({ sx: {
45
+ canUpdateProperty && hasUpdatePermission && (React.createElement(Box, { sx: {
56
46
  margin: '5px 0',
57
47
  height: '115px',
58
48
  borderRadius: '8px',
@@ -62,8 +52,8 @@ export const Document = (props) => {
62
52
  border: `1px dashed ${error ? 'red' : uploadDisabled ? '#DFE3E8' : '#858585'}`,
63
53
  position: 'relative',
64
54
  cursor: uploadDisabled ? 'cursor' : 'pointer',
65
- } }, getRootProps(), { onClick: open }),
66
- React.createElement("input", Object.assign({}, getInputProps({ id }), { disabled: uploadDisabled })),
55
+ }, ...getRootProps(), onClick: open },
56
+ React.createElement("input", { ...getInputProps({ id }), disabled: uploadDisabled }),
67
57
  React.createElement(Grid, { container: true, sx: { width: '100%' } },
68
58
  React.createElement(Grid, { item: true, xs: 12, sx: { display: 'flex', justifyContent: 'center', paddingBottom: '7px' } },
69
59
  React.createElement(UploadCloud, { sx: { color: uploadDisabled ? '#919EAB' : '#919EAB', width: '50px', height: '30px' } })),
@@ -76,5 +66,5 @@ export const Document = (props) => {
76
66
  "to upload"))))),
77
67
  canUpdateProperty && isNil(hasUpdatePermission) && (React.createElement(Skeleton, { variant: "rectangular", height: "115px", sx: { margin: '5px 0', borderRadius: '8px' } })),
78
68
  React.createElement(DocumentList, { property: property, instance: instance, objectId: objectId, handleChange: handleChange, value: value, apiServices: apiServices, setSnackbarError: (type, message) => setSnackbarError({ message, type }), canUpdateProperty: canUpdateProperty && !!hasUpdatePermission }),
79
- React.createElement(Snackbar, { open: !!(snackbarError === null || snackbarError === void 0 ? void 0 : snackbarError.message), handleClose: () => setSnackbarError(null), message: snackbarError === null || snackbarError === void 0 ? void 0 : snackbarError.message, error: (snackbarError === null || snackbarError === void 0 ? void 0 : snackbarError.type) === 'error' })));
69
+ React.createElement(Snackbar, { open: !!snackbarError?.message, handleClose: () => setSnackbarError(null), message: snackbarError?.message, error: snackbarError?.type === 'error' })));
80
70
  };