@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 { camelCase, get, isArray, isEmpty, isNil, isObject, isUndefined, pick, startCase, transform, uniq, } from 'lodash';
11
2
  import { DateTime } from 'luxon';
12
3
  import { nanoid } from 'nanoid';
@@ -26,7 +17,7 @@ export function determineComponentType(properties, parameter) {
26
17
  const property = properties.find((property) => property.id === parameter.id);
27
18
  if (!property)
28
19
  return undefined;
29
- return (property === null || property === void 0 ? void 0 : property.manyToManyPropertyId) ? 'ManyToManyRepeatableField' : 'RepeatableField';
20
+ return property?.manyToManyPropertyId ? 'ManyToManyRepeatableField' : 'RepeatableField';
30
21
  }
31
22
  case 'document':
32
23
  return 'Document';
@@ -73,12 +64,12 @@ export function determineParameterType(componentType) {
73
64
  export function getFlattenEntries(entries) {
74
65
  return entries.reduce((acc, entry) => {
75
66
  if (entry.type === 'sections') {
76
- const subEntries = entry.sections.flatMap((s) => { var _a; return (_a = s.entries) !== null && _a !== void 0 ? _a : []; });
77
- return acc.concat(getFlattenEntries(subEntries !== null && subEntries !== void 0 ? subEntries : []));
67
+ const subEntries = entry.sections.flatMap((s) => s.entries ?? []);
68
+ return acc.concat(getFlattenEntries(subEntries ?? []));
78
69
  }
79
70
  else if (entry.type === 'columns') {
80
- const subEntries = entry.columns.flatMap((c) => { var _a; return (_a = c.entries) !== null && _a !== void 0 ? _a : []; });
81
- return acc.concat(getFlattenEntries(subEntries !== null && subEntries !== void 0 ? subEntries : []));
71
+ const subEntries = entry.columns.flatMap((c) => c.entries ?? []);
72
+ return acc.concat(getFlattenEntries(subEntries ?? []));
82
73
  }
83
74
  else if (entry.type === 'content') {
84
75
  return acc;
@@ -91,24 +82,20 @@ export function getFlattenEntries(entries) {
91
82
  export function convertFormToComponents(entries, parameters, object) {
92
83
  return entries
93
84
  .map((entry) => {
94
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17;
95
85
  if (entry.type === 'sections') {
96
86
  return {
97
87
  type: 'Section',
98
88
  key: nanoid(),
99
89
  verticalLayout: true,
100
90
  label: 'Section',
101
- components: entry.sections.map((section) => {
102
- var _a;
103
- return ({
104
- key: nanoid(),
105
- label: section.label,
106
- components: ((_a = section.entries) === null || _a === void 0 ? void 0 : _a.length)
107
- ? convertFormToComponents(section.entries, parameters, object)
108
- : [],
109
- });
110
- }),
111
- conditional: typeof entry.visibility !== 'string' && ((_b = (_a = entry.visibility) === null || _a === void 0 ? void 0 : _a.conditions) === null || _b === void 0 ? void 0 : _b.length)
91
+ components: entry.sections.map((section) => ({
92
+ key: nanoid(),
93
+ label: section.label,
94
+ components: section.entries?.length
95
+ ? convertFormToComponents(section.entries, parameters, object)
96
+ : [],
97
+ })),
98
+ conditional: typeof entry.visibility !== 'string' && entry.visibility?.conditions?.length
112
99
  ? {
113
100
  show: entry.visibility.conditions[0].operator === 'eq',
114
101
  when: entry.visibility.conditions[0].property,
@@ -124,13 +111,15 @@ export function convertFormToComponents(entries, parameters, object) {
124
111
  type: 'Columns',
125
112
  key: nanoid(),
126
113
  label: 'Columns',
127
- columns: entry.columns.map((column) => {
128
- var _a;
129
- return (Object.assign(Object.assign({}, column), { size: 'md', currentWidth: column.width, components: ((_a = column.entries) === null || _a === void 0 ? void 0 : _a.length)
130
- ? convertFormToComponents(column.entries, parameters, object)
131
- : [] }));
132
- }),
133
- conditional: typeof entry.visibility !== 'string' && ((_d = (_c = entry.visibility) === null || _c === void 0 ? void 0 : _c.conditions) === null || _d === void 0 ? void 0 : _d.length)
114
+ columns: entry.columns.map((column) => ({
115
+ ...column,
116
+ size: 'md',
117
+ currentWidth: column.width,
118
+ components: column.entries?.length
119
+ ? convertFormToComponents(column.entries, parameters, object)
120
+ : [],
121
+ })),
122
+ conditional: typeof entry.visibility !== 'string' && entry.visibility?.conditions?.length
134
123
  ? {
135
124
  show: entry.visibility.conditions[0].operator === 'eq',
136
125
  when: entry.visibility.conditions[0].property,
@@ -146,7 +135,7 @@ export function convertFormToComponents(entries, parameters, object) {
146
135
  type: 'Content',
147
136
  key: nanoid(),
148
137
  html: entry.html,
149
- conditional: typeof entry.visibility !== 'string' && ((_f = (_e = entry.visibility) === null || _e === void 0 ? void 0 : _e.conditions) === null || _f === void 0 ? void 0 : _f.length)
138
+ conditional: typeof entry.visibility !== 'string' && entry.visibility?.conditions?.length
150
139
  ? {
151
140
  show: entry.visibility.conditions[0].operator === 'eq',
152
141
  when: entry.visibility.conditions[0].property,
@@ -163,190 +152,190 @@ export function convertFormToComponents(entries, parameters, object) {
163
152
  if (!parameter) {
164
153
  return;
165
154
  }
166
- let property = (_h = (_g = object.properties) === null || _g === void 0 ? void 0 : _g.find((p) => p.id === entry.parameterId)) !== null && _h !== void 0 ? _h : {
155
+ let property = object.properties?.find((p) => p.id === entry.parameterId) ?? {
167
156
  id: entry.parameterId,
168
157
  };
169
- if ((_j = property.id) === null || _j === void 0 ? void 0 : _j.includes('.')) {
170
- const topLevelProperty = (_k = object.properties) === null || _k === void 0 ? void 0 : _k.find((p) => { var _a; return p.id === ((_a = property.id) === null || _a === void 0 ? void 0 : _a.split('.')[0]) && (p.type === 'address' || p.type === 'user'); });
158
+ if (property.id?.includes('.')) {
159
+ const topLevelProperty = object.properties?.find((p) => p.id === property.id?.split('.')[0] && (p.type === 'address' || p.type === 'user'));
171
160
  property = {
172
161
  id: property.id,
173
- name: (topLevelProperty === null || topLevelProperty === void 0 ? void 0 : topLevelProperty.name)
162
+ name: topLevelProperty?.name
174
163
  ? `${topLevelProperty.name} ${startCase(property.id.split('.')[1])}`
175
164
  : startCase(property.id.split('.')[1]),
176
165
  };
177
166
  }
178
- const type = determineComponentType((_l = object.properties) !== null && _l !== void 0 ? _l : [], parameter);
167
+ const type = determineComponentType(object.properties ?? [], parameter);
179
168
  if (!type) {
180
169
  return;
181
170
  }
182
- return Object.assign(Object.assign({}, pick(displayOptions, 'label', 'description', 'tooltip', 'prefix', 'suffix', 'readOnly', 'mode')), { initialValue: type === 'Select'
183
- ? (_m = entry.enumWithLabels) === null || _m === void 0 ? void 0 : _m.find((c) => c.value === (displayOptions === null || displayOptions === void 0 ? void 0 : displayOptions.defaultValue))
184
- : type === 'MultiSelect' && isArray(displayOptions === null || displayOptions === void 0 ? void 0 : displayOptions.defaultValue)
185
- ? (_o = entry.enumWithLabels) === null || _o === void 0 ? void 0 : _o.filter((c) => (displayOptions === null || displayOptions === void 0 ? void 0 : displayOptions.defaultValue).includes(c.value))
186
- : type !== 'Object'
187
- ? displayOptions === null || displayOptions === void 0 ? void 0 : displayOptions.defaultValue
188
- : undefined, isMultiLineText: parameter.type === 'string' && (displayOptions === null || displayOptions === void 0 ? void 0 : displayOptions.rowCount) ? true : false, rows: displayOptions === null || displayOptions === void 0 ? void 0 : displayOptions.rowCount, key: parameter.id, type, multiple: ['array', 'document'].includes(parameter.type), data: {
171
+ return {
172
+ ...pick(displayOptions, 'label', 'description', 'tooltip', 'prefix', 'suffix', 'readOnly', 'mode'),
173
+ initialValue: type === 'Object'
174
+ ? typeof displayOptions?.defaultValue === 'string'
175
+ ? displayOptions.defaultValue
176
+ : undefined
177
+ : displayOptions?.defaultValue,
178
+ isMultiLineText: parameter.type === 'string' && displayOptions?.rowCount ? true : false,
179
+ rows: displayOptions?.rowCount,
180
+ key: parameter.id,
181
+ type,
182
+ multiple: ['array', 'document'].includes(parameter.type),
183
+ data: {
189
184
  values: entry.enumWithLabels,
190
- }, property: property, defaultToCurrentTime: (displayOptions === null || displayOptions === void 0 ? void 0 : displayOptions.defaultValue) === 'currentTime' && parameter.type === 'time' ? true : false, defaultToCurrentDate: (displayOptions === null || displayOptions === void 0 ? void 0 : displayOptions.defaultValue) === 'currentDate' && parameter.type === 'date' ? true : false, defaultValueCriteria: parameter.type === 'object' && (displayOptions === null || displayOptions === void 0 ? void 0 : displayOptions.defaultValue)
185
+ },
186
+ property: property,
187
+ defaultToCurrentTime: displayOptions?.defaultValue === 'currentTime' && parameter.type === 'time' ? true : false,
188
+ defaultToCurrentDate: displayOptions?.defaultValue === 'currentDate' && parameter.type === 'date' ? true : false,
189
+ defaultValueCriteria: parameter.type === 'object' &&
190
+ displayOptions?.defaultValue &&
191
+ typeof displayOptions.defaultValue !== 'string'
191
192
  ? displayOptions.defaultValue.criteria
192
- : undefined, sortBy: parameter.type === 'object' && (displayOptions === null || displayOptions === void 0 ? void 0 : displayOptions.defaultValue)
193
- ? (_p = displayOptions.defaultValue) === null || _p === void 0 ? void 0 : _p.sortBy
194
- : undefined, orderBy: parameter.type === 'object' &&
195
- ((_q = displayOptions === null || displayOptions === void 0 ? void 0 : displayOptions.defaultValue) === null || _q === void 0 ? void 0 : _q.orderBy)
196
- ? (_r = displayOptions === null || displayOptions === void 0 ? void 0 : displayOptions.defaultValue) === null || _r === void 0 ? void 0 : _r.orderBy
197
- : undefined, inputMask: parameter.type === 'string' ? (_s = parameter.validation) === null || _s === void 0 ? void 0 : _s.mask : undefined, inputMaskPlacholderChar: displayOptions === null || displayOptions === void 0 ? void 0 : displayOptions.placeholderChar, placeholder: displayOptions === null || displayOptions === void 0 ? void 0 : displayOptions.placeholder, tableView: false, displayOption: parameter.type === 'object' ? displayOptions === null || displayOptions === void 0 ? void 0 : displayOptions.relatedObjectDisplay : undefined, labelPosition: 'top', dataSrc: ((_t = property.enum) === null || _t === void 0 ? void 0 : _t.length) ? 'values' : undefined, showCharCount: displayOptions === null || displayOptions === void 0 ? void 0 : displayOptions.charCount, objectId: object.id, validate: {
198
- required: displayOptions === null || displayOptions === void 0 ? void 0 : displayOptions.required,
199
- criteria: ['collection', 'object'].includes((_u = parameter.type) !== null && _u !== void 0 ? _u : '')
200
- ? (_v = parameter.validation) === null || _v === void 0 ? void 0 : _v.criteria
193
+ : undefined,
194
+ sortBy: parameter.type === 'object' &&
195
+ displayOptions?.defaultValue &&
196
+ typeof displayOptions.defaultValue !== 'string'
197
+ ? displayOptions.defaultValue?.sortBy
198
+ : undefined,
199
+ orderBy: parameter.type === 'object' &&
200
+ displayOptions?.defaultValue &&
201
+ typeof displayOptions.defaultValue !== 'string'
202
+ ? displayOptions.defaultValue.orderBy
203
+ : undefined,
204
+ inputMask: parameter.type === 'string' ? parameter.validation?.mask : undefined,
205
+ inputMaskPlacholderChar: displayOptions?.placeholderChar,
206
+ placeholder: displayOptions?.placeholder,
207
+ tableView: false,
208
+ displayOption: parameter.type === 'object' ? displayOptions?.relatedObjectDisplay : undefined,
209
+ labelPosition: 'top',
210
+ dataSrc: property.enum?.length ? 'values' : undefined,
211
+ showCharCount: displayOptions?.charCount,
212
+ objectId: object.id,
213
+ validate: {
214
+ required: displayOptions?.required,
215
+ criteria: ['collection', 'object'].includes(parameter.type ?? '')
216
+ ? parameter.validation?.criteria
201
217
  : undefined,
202
218
  regexes: parameter.type === 'string'
203
- ? (_x = (_w = parameter.validation) === null || _w === void 0 ? void 0 : _w.rules) === null || _x === void 0 ? void 0 : _x.map((rule) => {
204
- var _a;
205
- return (Object.assign(Object.assign({}, rule), { errorMessage: (_a = rule.errorMessage) !== null && _a !== void 0 ? _a : 'Property is not in a valid format' }));
206
- })
219
+ ? parameter.validation?.rules?.map((rule) => ({
220
+ ...rule,
221
+ errorMessage: rule.errorMessage ?? 'Property is not in a valid format',
222
+ }))
207
223
  : [],
208
- operator: (_z = (_y = parameter.validation) === null || _y === void 0 ? void 0 : _y.operator) !== null && _z !== void 0 ? _z : 'any',
224
+ operator: parameter.validation?.operator ?? 'any',
209
225
  minLength: parameter.type === 'string'
210
- ? (_0 = parameter.validation) === null || _0 === void 0 ? void 0 : _0.minLength
226
+ ? parameter.validation?.minLength
211
227
  : undefined,
212
228
  maxLength: parameter.type === 'string'
213
- ? (_1 = parameter.validation) === null || _1 === void 0 ? void 0 : _1.maxLength
229
+ ? parameter.validation?.maxLength
214
230
  : undefined,
215
- minDate: parameter.type === 'date' ? (_2 = parameter.validation) === null || _2 === void 0 ? void 0 : _2.from : undefined,
216
- maxDate: parameter.type === 'date' ? (_3 = parameter.validation) === null || _3 === void 0 ? void 0 : _3.to : undefined,
217
- minTime: parameter.type === 'time' ? (_4 = parameter.validation) === null || _4 === void 0 ? void 0 : _4.from : undefined,
218
- maxTime: parameter.type === 'time' ? (_5 = parameter.validation) === null || _5 === void 0 ? void 0 : _5.to : undefined,
219
- min: ['integer', 'number'].includes((_6 = parameter.type) !== null && _6 !== void 0 ? _6 : '')
220
- ? (_7 = parameter.validation) === null || _7 === void 0 ? void 0 : _7.minimum
231
+ minDate: parameter.type === 'date' ? parameter.validation?.from : undefined,
232
+ maxDate: parameter.type === 'date' ? parameter.validation?.to : undefined,
233
+ minTime: parameter.type === 'time' ? parameter.validation?.from : undefined,
234
+ maxTime: parameter.type === 'time' ? parameter.validation?.to : undefined,
235
+ min: ['integer', 'number'].includes(parameter.type ?? '')
236
+ ? parameter.validation?.minimum
221
237
  : undefined,
222
- max: ['integer', 'number'].includes((_8 = parameter.type) !== null && _8 !== void 0 ? _8 : '')
223
- ? (_9 = parameter.validation) === null || _9 === void 0 ? void 0 : _9.maximum
238
+ max: ['integer', 'number'].includes(parameter.type ?? '')
239
+ ? parameter.validation?.maximum
224
240
  : undefined,
225
241
  minDocuments: parameter.type === 'document'
226
- ? (_10 = parameter.validation) === null || _10 === void 0 ? void 0 : _10.minDocuments
242
+ ? parameter.validation?.minDocuments
227
243
  : undefined,
228
244
  maxDocuments: parameter.type === 'document'
229
- ? (_11 = parameter.validation) === null || _11 === void 0 ? void 0 : _11.maxDocuments
245
+ ? parameter.validation?.maxDocuments
230
246
  : undefined,
231
- customMessage: ['integer', 'number', 'date', 'time', 'document'].includes((_12 = parameter.type) !== null && _12 !== void 0 ? _12 : '')
232
- ? (_13 = parameter.validation) === null || _13 === void 0 ? void 0 : _13.errorMessage
247
+ customMessage: ['integer', 'number', 'date', 'time', 'document'].includes(parameter.type ?? '')
248
+ ? parameter.validation
249
+ ?.errorMessage
233
250
  : '',
234
- }, id: nanoid(7), isAddressLine1: ((_14 = property.id) === null || _14 === void 0 ? void 0 : _14.split('.')[1]) === 'line1' ? true : false, addressPropertyId: ((_15 = property.id) === null || _15 === void 0 ? void 0 : _15.split('.')[1]) === 'line1' ? (_16 = property.id) === null || _16 === void 0 ? void 0 : _16.split('.')[0] : undefined, input: true, widget: (parameter.type === 'string' && parameter.enum) || parameter.type === 'array'
251
+ },
252
+ id: nanoid(7),
253
+ isAddressLine1: property.id?.split('.')[1] === 'line1' ? true : false,
254
+ addressPropertyId: property.id?.split('.')[1] === 'line1' ? property.id?.split('.')[0] : undefined,
255
+ input: true,
256
+ widget: (parameter.type === 'string' && parameter.enum) || parameter.type === 'array'
235
257
  ? 'choicejs'
236
- : undefined, conditional: (displayOptions === null || displayOptions === void 0 ? void 0 : displayOptions.visibility) &&
237
- typeof (displayOptions === null || displayOptions === void 0 ? void 0 : displayOptions.visibility) !== 'string' &&
238
- ((_17 = displayOptions.visibility.conditions) === null || _17 === void 0 ? void 0 : _17.length)
258
+ : undefined,
259
+ conditional: displayOptions?.visibility &&
260
+ typeof displayOptions?.visibility !== 'string' &&
261
+ displayOptions.visibility.conditions?.length
239
262
  ? {
240
- show: (displayOptions === null || displayOptions === void 0 ? void 0 : displayOptions.visibility.conditions[0].operator) === 'eq',
241
- when: displayOptions === null || displayOptions === void 0 ? void 0 : displayOptions.visibility.conditions[0].property,
242
- eq: displayOptions === null || displayOptions === void 0 ? void 0 : displayOptions.visibility.conditions[0].value,
263
+ show: displayOptions?.visibility.conditions[0].operator === 'eq',
264
+ when: displayOptions?.visibility.conditions[0].property,
265
+ eq: displayOptions?.visibility.conditions[0].value,
243
266
  }
244
267
  : {
245
- json: displayOptions === null || displayOptions === void 0 ? void 0 : displayOptions.visibility,
246
- }, viewLayout: displayOptions === null || displayOptions === void 0 ? void 0 : displayOptions.viewLayout });
268
+ json: displayOptions?.visibility,
269
+ },
270
+ viewLayout: displayOptions?.viewLayout,
271
+ };
247
272
  }
248
273
  })
249
274
  .filter((item) => item);
250
275
  }
251
276
  export function convertComponentsToForm(components) {
252
277
  return components.map((component) => {
253
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
254
278
  if (component.type === 'Section') {
255
- return Object.assign({ type: 'sections', label: component.label, sections: (_a = component.components) === null || _a === void 0 ? void 0 : _a.map((section) => {
256
- var _a;
257
- return ({
258
- key: nanoid(),
259
- label: section.label,
260
- entries: ((_a = section.components) === null || _a === void 0 ? void 0 : _a.length) ? convertComponentsToForm(section.components) : [],
261
- });
262
- }) }, (((_b = component.conditional) === null || _b === void 0 ? void 0 : _b.json) ||
263
- (((_c = component.conditional) === null || _c === void 0 ? void 0 : _c.when) && !isUndefined((_d = component.conditional) === null || _d === void 0 ? void 0 : _d.show) && ((_e = component.conditional) === null || _e === void 0 ? void 0 : _e.eq))
264
- ? {
265
- visibility: component.conditional.json
266
- ? component.conditional.json
267
- : {
268
- operator: 'all',
269
- conditions: [
270
- {
271
- property: component.conditional.when,
272
- operator: component.conditional.show ? 'eq' : 'ne',
273
- value: component.conditional.eq,
274
- },
275
- ],
276
- },
277
- }
278
- : {}));
279
+ return {
280
+ type: 'sections',
281
+ label: component.label,
282
+ sections: component.components?.map((section) => ({
283
+ key: nanoid(),
284
+ label: section.label,
285
+ entries: section.components?.length ? convertComponentsToForm(section.components) : [],
286
+ })),
287
+ ...(component.conditional?.json ||
288
+ (component.conditional?.when && !isUndefined(component.conditional?.show) && component.conditional?.eq)
289
+ ? {
290
+ visibility: component.conditional.json
291
+ ? component.conditional.json
292
+ : {
293
+ operator: 'all',
294
+ conditions: [
295
+ {
296
+ property: component.conditional.when,
297
+ operator: component.conditional.show ? 'eq' : 'ne',
298
+ value: component.conditional.eq,
299
+ },
300
+ ],
301
+ },
302
+ }
303
+ : {}),
304
+ };
279
305
  }
280
306
  else if (component.type === 'Columns') {
281
- return Object.assign({ type: 'columns', label: component.label, columns: (_f = component.columns) === null || _f === void 0 ? void 0 : _f.map((column) => {
282
- var _a;
283
- return ({
284
- width: column.width,
285
- entries: ((_a = column.components) === null || _a === void 0 ? void 0 : _a.length) ? convertComponentsToForm(column.components) : [],
286
- });
287
- }) }, (((_g = component.conditional) === null || _g === void 0 ? void 0 : _g.json) ||
288
- (((_h = component.conditional) === null || _h === void 0 ? void 0 : _h.when) && !isUndefined((_j = component.conditional) === null || _j === void 0 ? void 0 : _j.show) && ((_k = component.conditional) === null || _k === void 0 ? void 0 : _k.eq))
289
- ? {
290
- visibility: component.conditional.json
291
- ? component.conditional.json
292
- : {
293
- operator: 'all',
294
- conditions: [
295
- {
296
- property: component.conditional.when,
297
- operator: component.conditional.show ? 'eq' : 'ne',
298
- value: component.conditional.eq,
299
- },
300
- ],
301
- },
302
- }
303
- : {}));
304
- }
305
- else if (component.type === 'Content') {
306
- return Object.assign({ type: 'content', html: (_l = component.html) !== null && _l !== void 0 ? _l : '' }, (((_m = component.conditional) === null || _m === void 0 ? void 0 : _m.json) ||
307
- (((_o = component.conditional) === null || _o === void 0 ? void 0 : _o.when) && !isUndefined((_p = component.conditional) === null || _p === void 0 ? void 0 : _p.show) && ((_q = component.conditional) === null || _q === void 0 ? void 0 : _q.eq))
308
- ? {
309
- visibility: component.conditional.json
310
- ? component.conditional.json
311
- : {
312
- operator: 'all',
313
- conditions: [
314
- {
315
- property: component.conditional.when,
316
- operator: component.conditional.show ? 'eq' : 'ne',
317
- value: component.conditional.eq,
318
- },
319
- ],
320
- },
321
- }
322
- : {}));
323
- }
324
- else {
325
307
  return {
326
- type: 'input',
327
- parameterId: component.key,
328
- display: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (component.label ? { label: component.label } : {})), (component.description ? { description: component.description } : {})), (component.tooltip ? { tooltip: component.tooltip } : {})), (component.placeholder ? { placeholder: component.placeholder } : {})), (component.prefix ? { prefix: component.prefix } : {})), (component.suffix ? { suffix: component.suffix } : {})), (component.readOnly ? { readOnly: component.readOnly } : {})), (component.mode ? { mode: component.mode } : {})), (((_r = component.validate) === null || _r === void 0 ? void 0 : _r.required) ? { required: (_s = component.validate) === null || _s === void 0 ? void 0 : _s.required } : {})), (component.displayOption ? { relatedObjectDisplay: component.displayOption } : {})), (component.defaultToCurrentDate ||
329
- component.defaultToCurrentTime ||
330
- component.initialValue ||
331
- component.defaultValueCriteria
308
+ type: 'columns',
309
+ label: component.label,
310
+ columns: component.columns?.map((column) => ({
311
+ width: column.width,
312
+ entries: column.components?.length ? convertComponentsToForm(column.components) : [],
313
+ })),
314
+ ...(component.conditional?.json ||
315
+ (component.conditional?.when && !isUndefined(component.conditional?.show) && component.conditional?.eq)
332
316
  ? {
333
- defaultValue: component.defaultToCurrentDate
334
- ? 'currentDate'
335
- : component.defaultToCurrentTime
336
- ? 'currentTime'
337
- : component.defaultValueCriteria
338
- ? Object.assign(Object.assign({ criteria: component.defaultValueCriteria }, (component.sortBy ? { sortBy: component.sortBy } : {})), (component.orderBy ? { sortBy: component.orderBy } : {})) : isArray(component.initialValue)
339
- ? component.initialValue.map((c) => c.value)
340
- : ((_t = component.initialValue) === null || _t === void 0 ? void 0 : _t.value)
341
- ? (_u = component.initialValue) === null || _u === void 0 ? void 0 : _u.value
342
- : component.initialValue,
317
+ visibility: component.conditional.json
318
+ ? component.conditional.json
319
+ : {
320
+ operator: 'all',
321
+ conditions: [
322
+ {
323
+ property: component.conditional.when,
324
+ operator: component.conditional.show ? 'eq' : 'ne',
325
+ value: component.conditional.eq,
326
+ },
327
+ ],
328
+ },
343
329
  }
344
- : {})), (component.rows ? { rowCount: component.rows } : {})), (component.inputMaskPlaceholderChar
345
- ? { placeholderChar: component.inputMaskPlaceholderChar }
346
- : {})), (component.showCharCount ? { charCount: true } : {})), (((_v = component.conditional) === null || _v === void 0 ? void 0 : _v.json) ||
347
- (((_w = component.conditional) === null || _w === void 0 ? void 0 : _w.when) &&
348
- !isUndefined((_x = component.conditional) === null || _x === void 0 ? void 0 : _x.show) &&
349
- ((_y = component.conditional) === null || _y === void 0 ? void 0 : _y.eq))
330
+ : {}),
331
+ };
332
+ }
333
+ else if (component.type === 'Content') {
334
+ return {
335
+ type: 'content',
336
+ html: component.html ?? '',
337
+ ...(component.conditional?.json ||
338
+ (component.conditional?.when && !isUndefined(component.conditional?.show) && component.conditional?.eq)
350
339
  ? {
351
340
  visibility: component.conditional.json
352
341
  ? component.conditional.json
@@ -361,8 +350,72 @@ export function convertComponentsToForm(components) {
361
350
  ],
362
351
  },
363
352
  }
364
- : {})),
365
- enumWithLabels: (_z = component.data) === null || _z === void 0 ? void 0 : _z.values,
353
+ : {}),
354
+ };
355
+ }
356
+ else {
357
+ return {
358
+ type: 'input',
359
+ parameterId: component.key,
360
+ display: {
361
+ ...(component.label ? { label: component.label } : {}),
362
+ ...(component.description ? { description: component.description } : {}),
363
+ ...(component.tooltip ? { tooltip: component.tooltip } : {}),
364
+ ...(component.placeholder ? { placeholder: component.placeholder } : {}),
365
+ ...(component.prefix ? { prefix: component.prefix } : {}),
366
+ ...(component.suffix ? { suffix: component.suffix } : {}),
367
+ ...(component.readOnly ? { readOnly: component.readOnly } : {}),
368
+ ...(component.mode ? { mode: component.mode } : {}),
369
+ ...(component.validate?.required ? { required: component.validate?.required } : {}),
370
+ ...(component.displayOption ? { relatedObjectDisplay: component.displayOption } : {}),
371
+ ...(component.defaultToCurrentDate ||
372
+ component.defaultToCurrentTime ||
373
+ component.initialValue ||
374
+ component.defaultValueCriteria
375
+ ? {
376
+ defaultValue: component.defaultToCurrentDate
377
+ ? 'currentDate'
378
+ : component.defaultToCurrentTime
379
+ ? 'currentTime'
380
+ : component.defaultValueCriteria
381
+ ? {
382
+ criteria: component.defaultValueCriteria,
383
+ ...(component.sortBy ? { sortBy: component.sortBy } : {}),
384
+ ...(component.orderBy ? { sortBy: component.orderBy } : {}),
385
+ }
386
+ : isArray(component.initialValue)
387
+ ? component.initialValue.map((c) => c.value)
388
+ : component.initialValue?.value
389
+ ? component.initialValue?.value
390
+ : component.initialValue,
391
+ }
392
+ : {}),
393
+ ...(component.rows ? { rowCount: component.rows } : {}),
394
+ ...(component.inputMaskPlaceholderChar
395
+ ? { placeholderChar: component.inputMaskPlaceholderChar }
396
+ : {}),
397
+ ...(component.showCharCount ? { charCount: true } : {}),
398
+ ...(component.conditional?.json ||
399
+ (component.conditional?.when &&
400
+ !isUndefined(component.conditional?.show) &&
401
+ component.conditional?.eq)
402
+ ? {
403
+ visibility: component.conditional.json
404
+ ? component.conditional.json
405
+ : {
406
+ operator: 'all',
407
+ conditions: [
408
+ {
409
+ property: component.conditional.when,
410
+ operator: component.conditional.show ? 'eq' : 'ne',
411
+ value: component.conditional.eq,
412
+ },
413
+ ],
414
+ },
415
+ }
416
+ : {}),
417
+ },
418
+ enumWithLabels: component.data?.values,
366
419
  };
367
420
  }
368
421
  });
@@ -370,7 +423,7 @@ export function convertComponentsToForm(components) {
370
423
  // The following functions are used to support the many-to-many relationship collection property.
371
424
  export function getMiddleObjectFilter(property, instance) {
372
425
  const filterProperty = `${property.relatedPropertyId}.id`;
373
- const filter = { where: { [filterProperty]: instance === null || instance === void 0 ? void 0 : instance.id } };
426
+ const filter = { where: { [filterProperty]: instance?.id } };
374
427
  return filter;
375
428
  }
376
429
  export function getMiddleObject(instance, property, endObjectId, endObjectName) {
@@ -389,7 +442,7 @@ export function getMiddleObject(instance, property, endObjectId, endObjectName)
389
442
  }
390
443
  }
391
444
  export function getMiddleInstance(instanceId, property, middleObjectInstances) {
392
- return middleObjectInstances.find((o) => { var _a; return property.manyToManyPropertyId && ((_a = o[property.manyToManyPropertyId]) === null || _a === void 0 ? void 0 : _a.id) === instanceId; });
445
+ return middleObjectInstances.find((o) => property.manyToManyPropertyId && o[property.manyToManyPropertyId]?.id === instanceId);
393
446
  }
394
447
  // The following function is used to prefix the URL with the appropriate path.
395
448
  export function getPrefixedUrl(url) {
@@ -408,245 +461,327 @@ export function getPrefixedUrl(url) {
408
461
  return `/accessManagement${url}`;
409
462
  if (workflowMatchers.some((endpoint) => url.startsWith(endpoint)))
410
463
  return `/workflow${url}`;
464
+ console.error('Invalid URL');
411
465
  return url;
412
466
  }
413
467
  // The following function adds the object properties to the form components.
414
468
  // This function is used when there is no form configured in the form builder.
415
- export function addObjectPropertiesToComponentProps(properties,
469
+ export async function addObjectPropertiesToComponentProps(properties,
416
470
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
417
471
  formComponents, instance, objectPropertyInputProps, autoSave, readOnly, defaultPages, navigateTo, queryAddresses, apiServices, isModal, fieldHeight) {
418
- var _a;
419
- return __awaiter(this, void 0, void 0, function* () {
420
- return [
421
- ...(yield Promise.all((_a = formComponents === null || formComponents === void 0 ? void 0 : formComponents.filter((component) => !isUndefined(component) && !isNil(component))) === null || _a === void 0 ? void 0 : _a.map((component) => __awaiter(this, void 0, void 0, function* () {
422
- var _b, _c, _d, _e, _f, _g;
423
- const property = properties
424
- .flatMap((property) => {
425
- if (property.type === 'address') {
426
- return [
427
- {
428
- id: `${property.id}.line1`,
429
- name: `${property.name} Line 1`,
430
- type: 'string',
431
- },
432
- {
433
- id: `${property.id}.line2`,
434
- name: `${property.name} Line 2`,
435
- type: 'string',
436
- },
437
- {
438
- id: `${property.id}.city`,
439
- name: `${property.name} City`,
440
- type: 'string',
441
- },
442
- {
443
- id: `${property.id}.county`,
444
- name: `${property.name} County`,
445
- type: 'string',
446
- },
447
- {
448
- id: `${property.id}.state`,
449
- name: `${property.name} State`,
450
- type: 'string',
451
- },
452
- {
453
- id: `${property.id}.zipCode`,
454
- name: `${property.name} Zip Code`,
455
- type: 'string',
456
- },
457
- ];
458
- }
459
- return property;
460
- })
461
- .find((property) => property.id === component.key);
462
- const id = (_b = property === null || property === void 0 ? void 0 : property.id) !== null && _b !== void 0 ? _b : component.key;
463
- if (component.type === 'Content') {
464
- return component;
472
+ return [
473
+ ...(await Promise.all(formComponents
474
+ ?.filter((component) => !isUndefined(component) && !isNil(component))
475
+ ?.map(async (component) => {
476
+ const property = properties
477
+ .flatMap((property) => {
478
+ if (property.type === 'address') {
479
+ return [
480
+ {
481
+ id: `${property.id}.line1`,
482
+ name: `${property.name} Line 1`,
483
+ type: 'string',
484
+ },
485
+ {
486
+ id: `${property.id}.line2`,
487
+ name: `${property.name} Line 2`,
488
+ type: 'string',
489
+ },
490
+ {
491
+ id: `${property.id}.city`,
492
+ name: `${property.name} City`,
493
+ type: 'string',
494
+ },
495
+ {
496
+ id: `${property.id}.county`,
497
+ name: `${property.name} County`,
498
+ type: 'string',
499
+ },
500
+ {
501
+ id: `${property.id}.state`,
502
+ name: `${property.name} State`,
503
+ type: 'string',
504
+ },
505
+ {
506
+ id: `${property.id}.zipCode`,
507
+ name: `${property.name} Zip Code`,
508
+ type: 'string',
509
+ },
510
+ ];
465
511
  }
466
- if (component.type === 'Date') {
467
- if (component.initialValue) {
468
- component.initialValue = DateTime.fromISO(component.initialValue).toISODate();
469
- }
470
- // This will overwrite the default value
471
- if (component.defaultToCurrentDate) {
472
- component.initialValue = DateTime.now().toISODate();
473
- }
512
+ return property;
513
+ })
514
+ .find((property) => property.id === component.key);
515
+ const id = property?.id ?? component.key;
516
+ if (component.type === 'Content') {
517
+ return component;
518
+ }
519
+ else if (component.type === 'Date') {
520
+ if (component.initialValue && !/^{{.*}}/.test(component.initialValue)) {
521
+ component.initialValue =
522
+ component.initialValue === 'currentDate'
523
+ ? DateTime.now().toISODate()
524
+ : DateTime.fromISO(component.initialValue).toISODate();
474
525
  }
475
- if (component.type === 'DateTime') {
476
- if (component.initialValue) {
477
- component.initialValue = DateTime.fromISO(component.initialValue).toISO();
478
- }
479
- // This will overwrite the default value
480
- if (component.defaultToCurrentDate) {
481
- component.initialValue = DateTime.now().toISO();
482
- }
526
+ // @Deprecrated
527
+ // This will overwrite the default value
528
+ if (component.defaultToCurrentDate) {
529
+ component.initialValue = DateTime.now().toISODate();
483
530
  }
484
- if (component.type === 'Time') {
485
- if (component.initialValue) {
486
- component.initialValue = DateTime.fromISO(component.initialValue).toISOTime({
487
- includeOffset: false,
488
- suppressMilliseconds: true,
489
- });
490
- }
491
- // This will overwrite the default value
492
- if (component.defaultToCurrentTime) {
493
- component.initialValue = DateTime.now().toISOTime({
494
- includeOffset: false,
495
- suppressMilliseconds: true,
496
- });
497
- }
531
+ }
532
+ else if (component.type === 'DateTime') {
533
+ if (component.initialValue && !/^{{.*}}/.test(component.initialValue)) {
534
+ component.initialValue =
535
+ component.initialValue === 'currentDateTime'
536
+ ? DateTime.now().toISO()
537
+ : DateTime.fromISO(component.initialValue).toISO();
498
538
  }
499
- // if a conditional date is in a format other than yyyy-mm-dd, convert it to that format
500
- if (component.conditional &&
501
- ((_c = formComponents.find((formComponent) => formComponent.key === component.conditional.when)) === null || _c === void 0 ? void 0 : _c.type) === 'Date') {
502
- component.conditional.eq = new Date(component.conditional.eq).toISOString().split('T')[0];
539
+ // @Deprecrated
540
+ // This will overwrite the default value
541
+ if (component.defaultToCurrentDate) {
542
+ component.initialValue = DateTime.now().toISO();
503
543
  }
504
- const [propertyId, nestedPropertyId] = id.split('.');
505
- let instanceValue;
506
- if (nestedPropertyId) {
507
- instanceValue = (instance === null || instance === void 0 ? void 0 : instance[propertyId])
508
- ? instance[propertyId][nestedPropertyId]
509
- : undefined;
544
+ }
545
+ else if (component.type === 'Time') {
546
+ if (component.initialValue && !/^{{.*}}/.test(component.initialValue)) {
547
+ component.initialValue =
548
+ component.initialValue === 'currentTime'
549
+ ? DateTime.now().toISOTime({
550
+ includeOffset: false,
551
+ suppressMilliseconds: true,
552
+ })
553
+ : DateTime.fromISO(component.initialValue).toISOTime({
554
+ includeOffset: false,
555
+ suppressMilliseconds: true,
556
+ });
510
557
  }
511
- else {
512
- instanceValue = instance && id ? instance[id] : undefined;
558
+ // @Deprecrated
559
+ // This will overwrite the default value
560
+ if (component.defaultToCurrentTime) {
561
+ component.initialValue = DateTime.now().toISOTime({
562
+ includeOffset: false,
563
+ suppressMilliseconds: true,
564
+ });
513
565
  }
514
- // only add fieldComponents if the property exists on the sanitized object
515
- if (property) {
516
- if (property.manyToManyPropertyId &&
517
- apiServices &&
518
- !component.middleObject &&
519
- !component.initialMiddleObjectInstances) {
520
- const getMiddleObjectInstances = () => __awaiter(this, void 0, void 0, function* () {
521
- const filter = instance ? getMiddleObjectFilter(property, instance) : {};
522
- try {
523
- return yield apiServices.get(getPrefixedUrl(`/objects/${property.objectId}/instances`), { params: { filter: JSON.stringify(filter) } });
524
- }
525
- catch (err) {
526
- console.log(err);
527
- return [];
528
- }
529
- });
530
- const middleObject = yield apiServices.get(getPrefixedUrl(`/objects/${property.objectId}/effective?sanitizedVersion=true`), {
531
- params: { filter: { fields: ['properties', 'actions', 'rootObjectId'] } },
532
- });
533
- const initialMiddleObjectInstances = yield getMiddleObjectInstances();
534
- return Object.assign(Object.assign(Object.assign({}, component), (component.type === 'Object' && objectPropertyInputProps)), { defaultValue: getDefaultValue(isNil(instanceValue) ? component.initialValue : instanceValue, (_d = component === null || component === void 0 ? void 0 : component.data) === null || _d === void 0 ? void 0 : _d.values), property, type: `${readOnly ? 'ViewOnly' : ''}${component.type}`, readOnly: component.readOnly || readOnly || (property === null || property === void 0 ? void 0 : property.formula), multiple: ['array', 'document'].includes(property.type), instance: instance, fromFormBuilder: true, apiServices: objectPropertyInputProps === null || objectPropertyInputProps === void 0 ? void 0 : objectPropertyInputProps.apiServices, user: objectPropertyInputProps === null || objectPropertyInputProps === void 0 ? void 0 : objectPropertyInputProps.user, autoSave,
535
- fieldHeight, customDefaultValue: component.type === 'Select'
536
- ? () => getDefaultValue(isNil(instanceValue) ? component.initialValue : instanceValue)
537
- : undefined, queryAddresses: component.isAddressLine1 || ['collection', 'object'].includes(property === null || property === void 0 ? void 0 : property.type)
538
- ? queryAddresses
539
- : undefined, initialMiddleObjectInstances,
540
- middleObject,
541
- getMiddleObjectInstances,
542
- isModal });
543
- }
544
- return Object.assign(Object.assign(Object.assign({}, component), (component.type === 'Object' && objectPropertyInputProps)), { type: `${readOnly ? 'ViewOnly' : ''}${component.type}`, defaultValue: getDefaultValue(isNil(instanceValue) ? component.initialValue : instanceValue, (_e = component === null || component === void 0 ? void 0 : component.data) === null || _e === void 0 ? void 0 : _e.values), property, readOnly: component.readOnly || readOnly || (property === null || property === void 0 ? void 0 : property.formula), multiple: ['array', 'document'].includes(property.type), instance: instance, fromFormBuilder: true, apiServices: objectPropertyInputProps === null || objectPropertyInputProps === void 0 ? void 0 : objectPropertyInputProps.apiServices, user: objectPropertyInputProps === null || objectPropertyInputProps === void 0 ? void 0 : objectPropertyInputProps.user, fieldHeight,
545
- autoSave, customDefaultValue: component.type === 'Select'
566
+ }
567
+ // if a conditional date is in a format other than yyyy-mm-dd, convert it to that format
568
+ if (component.conditional &&
569
+ formComponents.find((formComponent) => formComponent.key === component.conditional.when)
570
+ ?.type === 'Date') {
571
+ component.conditional.eq = new Date(component.conditional.eq).toISOString().split('T')[0];
572
+ }
573
+ const [propertyId, nestedPropertyId] = id.split('.');
574
+ let instanceValue;
575
+ if (nestedPropertyId) {
576
+ instanceValue = instance?.[propertyId]
577
+ ? instance[propertyId][nestedPropertyId]
578
+ : undefined;
579
+ }
580
+ else {
581
+ instanceValue = instance && id ? instance[id] : undefined;
582
+ }
583
+ // only add fieldComponents if the property exists on the sanitized object
584
+ if (property) {
585
+ if (property.manyToManyPropertyId &&
586
+ apiServices &&
587
+ !component.middleObject &&
588
+ !component.initialMiddleObjectInstances) {
589
+ const getMiddleObjectInstances = async () => {
590
+ const filter = instance ? getMiddleObjectFilter(property, instance) : {};
591
+ try {
592
+ return await apiServices.get(getPrefixedUrl(`/objects/${property.objectId}/instances`), { params: { filter: JSON.stringify(filter) } });
593
+ }
594
+ catch (err) {
595
+ console.log(err);
596
+ return [];
597
+ }
598
+ };
599
+ const middleObject = await apiServices.get(getPrefixedUrl(`/objects/${property.objectId}/effective?sanitizedVersion=true`), {
600
+ params: { filter: { fields: ['properties', 'actions', 'rootObjectId'] } },
601
+ });
602
+ const initialMiddleObjectInstances = await getMiddleObjectInstances();
603
+ const defaultValue = getDefaultValue(isNil(instanceValue) ? component.initialValue : instanceValue, component?.data?.values);
604
+ return {
605
+ ...component,
606
+ ...(component.type === 'Object' && objectPropertyInputProps),
607
+ defaultValue,
608
+ property,
609
+ type: `${readOnly ? 'ViewOnly' : ''}${component.type}`,
610
+ readOnly: component.readOnly || readOnly || property?.formula,
611
+ multiple: ['array', 'document'].includes(property.type),
612
+ instance: instance,
613
+ fromFormBuilder: true,
614
+ apiServices: objectPropertyInputProps?.apiServices,
615
+ user: objectPropertyInputProps?.user,
616
+ autoSave,
617
+ fieldHeight,
618
+ customDefaultValue: component.type === 'Select'
546
619
  ? () => getDefaultValue(isNil(instanceValue) ? component.initialValue : instanceValue)
547
- : undefined, queryAddresses: component.isAddressLine1 || ['collection', 'object'].includes(property === null || property === void 0 ? void 0 : property.type)
620
+ : undefined,
621
+ queryAddresses: component.isAddressLine1 || ['collection', 'object'].includes(property?.type)
548
622
  ? queryAddresses
549
- : undefined, isOptionEqualToValue: component.type === 'Select' || component.type === 'MultiSelect'
550
- ? (option, value) => {
551
- if (typeof value === 'object' && 'value' in value) {
552
- return option.value === value.value;
553
- }
554
- return option.value === value;
555
- }
556
- : undefined, getOptionLabel: component.type === 'Select' || component.type === 'MultiSelect'
557
- ? (option) => {
558
- var _a, _b, _c;
559
- if (option) {
560
- return (_c = (_b = (_a = component.data) === null || _a === void 0 ? void 0 : _a.values) === null || _b === void 0 ? void 0 : _b.find((op) => op.value ===
561
- (typeof option === 'string' ? option : option.value))) === null || _c === void 0 ? void 0 : _c.label;
562
- }
563
- }
564
- : undefined, isModal });
565
- }
566
- if (component.columns) {
567
- for (const column of component.columns) {
568
- column.components = yield addObjectPropertiesToComponentProps(properties, column.components, instance, objectPropertyInputProps, autoSave, readOnly, undefined, undefined, queryAddresses, apiServices, isModal, fieldHeight);
569
- }
570
- return component;
623
+ : undefined,
624
+ initialMiddleObjectInstances,
625
+ middleObject,
626
+ getMiddleObjectInstances,
627
+ isModal,
628
+ };
571
629
  }
572
- if (component.components) {
573
- for (const item of component.components) {
574
- const nestedFieldProperty = properties.find((property) => property.id === item.key);
575
- if (item.type) {
576
- item.defaultValue = getDefaultValue(!instance || isNil(get(instance, item.key))
577
- ? item.initialValue
578
- : get(instance, item.key), (_f = item === null || item === void 0 ? void 0 : item.data) === null || _f === void 0 ? void 0 : _f.values);
579
- item.customDefaultValue =
580
- item.type === 'Select'
581
- ? () => getDefaultValue(!instance || isNil(instance[item === null || item === void 0 ? void 0 : item.key])
582
- ? item.initialValue
583
- : instance[item.key], undefined)
584
- : undefined;
585
- if (item.type.includes('RepeatableField') && !!instance) {
586
- item.instance = instance;
630
+ const defaultValue = getDefaultValue(isNil(instanceValue) ? component.initialValue : instanceValue, component?.data?.values);
631
+ return {
632
+ ...component,
633
+ ...(component.type === 'Object' && objectPropertyInputProps),
634
+ type: `${readOnly ? 'ViewOnly' : ''}${component.type}`,
635
+ defaultValue,
636
+ property,
637
+ readOnly: component.readOnly || readOnly || property?.formula,
638
+ multiple: ['array', 'document'].includes(property.type),
639
+ instance: instance,
640
+ fromFormBuilder: true,
641
+ apiServices: objectPropertyInputProps?.apiServices,
642
+ user: objectPropertyInputProps?.user,
643
+ fieldHeight,
644
+ autoSave,
645
+ customDefaultValue: component.type === 'Select'
646
+ ? () => getDefaultValue(isNil(instanceValue) ? component.initialValue : instanceValue)
647
+ : undefined,
648
+ queryAddresses: component.isAddressLine1 || ['collection', 'object'].includes(property?.type)
649
+ ? queryAddresses
650
+ : undefined,
651
+ isOptionEqualToValue: component.type === 'Select' || component.type === 'MultiSelect'
652
+ ? (option, value) => {
653
+ if (typeof value === 'object' && 'value' in value) {
654
+ return option.value === value.value;
587
655
  }
656
+ return option.value === value;
588
657
  }
589
- if (nestedFieldProperty) {
590
- item.type = `${readOnly ? 'ViewOnly' : ''}${item.type}`;
591
- item.property = nestedFieldProperty;
592
- }
593
- item.instance = instance;
594
- item.readOnly = item.readOnly || readOnly;
595
- item.autoSave = autoSave;
596
- item.apiServices = objectPropertyInputProps === null || objectPropertyInputProps === void 0 ? void 0 : objectPropertyInputProps.apiServices;
597
- item.user = objectPropertyInputProps === null || objectPropertyInputProps === void 0 ? void 0 : objectPropertyInputProps.user;
598
- item.defaultPages = defaultPages;
599
- item.navigateTo = navigateTo;
600
- item.isModal = isModal;
601
- item.fieldHeight = fieldHeight;
602
- if (item.addressPropertyId) {
603
- item.queryAddresses = queryAddresses;
658
+ : undefined,
659
+ getOptionLabel: component.type === 'Select' || component.type === 'MultiSelect'
660
+ ? (option) => {
661
+ if (option) {
662
+ return component.data?.values?.find((op) => op.value ===
663
+ (typeof option === 'string' ? option : option.value))?.label;
664
+ }
604
665
  }
605
- if (((_g = item.property) === null || _g === void 0 ? void 0 : _g.manyToManyPropertyId) &&
606
- apiServices &&
607
- !item.middleObject &&
608
- !item.initialMiddleObjectInstances) {
609
- const getMiddleObjectInstances = () => __awaiter(this, void 0, void 0, function* () {
610
- const filter = instance ? getMiddleObjectFilter(item.property, instance) : {};
611
- return yield apiServices.get(getPrefixedUrl(`/objects/${item.property.objectId}/instances`), { params: { filter: JSON.stringify(filter) } });
612
- });
613
- const middleObject = yield apiServices.get(getPrefixedUrl(`/objects/${item.property.objectId}/effective?sanitizedVersion=true`), {
614
- params: { filter: { fields: ['properties', 'actions', 'rootObjectId'] } },
615
- });
616
- const initialMiddleObjectInstances = yield getMiddleObjectInstances();
617
- item.initialMiddleObjectInstances = initialMiddleObjectInstances;
618
- item.middleObject = middleObject;
619
- item.getMiddleObjectInstances = getMiddleObjectInstances;
666
+ : undefined,
667
+ isModal,
668
+ };
669
+ }
670
+ if (component.columns) {
671
+ for (const column of component.columns) {
672
+ column.components = await addObjectPropertiesToComponentProps(properties, column.components, instance, objectPropertyInputProps, autoSave, readOnly, undefined, undefined, queryAddresses, apiServices, isModal, fieldHeight);
673
+ }
674
+ return component;
675
+ }
676
+ if (component.components) {
677
+ for (const item of component.components) {
678
+ const nestedFieldProperty = properties.find((property) => property.id === item.key);
679
+ if (item.type) {
680
+ item.defaultValue = getDefaultValue(!instance || isNil(get(instance, item.key))
681
+ ? item.initialValue
682
+ : get(instance, item.key), item?.data?.values);
683
+ item.customDefaultValue =
684
+ item.type === 'Select'
685
+ ? () => getDefaultValue(!instance || isNil(instance[item?.key])
686
+ ? item.initialValue
687
+ : instance[item.key], undefined)
688
+ : undefined;
689
+ if (item.type.includes('RepeatableField') && !!instance) {
690
+ item.instance = instance;
620
691
  }
621
692
  }
622
- return Object.assign(Object.assign(Object.assign({ components: yield addObjectPropertiesToComponentProps(properties, component.components, instance, objectPropertyInputProps, autoSave, readOnly, defaultPages, navigateTo, queryAddresses, apiServices, isModal, fieldHeight) }, component), (component.type === 'Object' && objectPropertyInputProps)), { type: `${readOnly ? 'ViewOnly' : ''}${component.type}`, properties: properties, property, instance: instance, fromFormBuilder: true, apiServices: apiServices, user: objectPropertyInputProps === null || objectPropertyInputProps === void 0 ? void 0 : objectPropertyInputProps.user, autoSave, queryAddresses: component.isAddressLine1 ? queryAddresses : undefined, isModal,
623
- fieldHeight });
693
+ if (nestedFieldProperty) {
694
+ item.type = `${readOnly ? 'ViewOnly' : ''}${item.type}`;
695
+ item.property = nestedFieldProperty;
696
+ }
697
+ item.instance = instance;
698
+ item.readOnly = item.readOnly || readOnly;
699
+ item.autoSave = autoSave;
700
+ item.apiServices = objectPropertyInputProps?.apiServices;
701
+ item.user = objectPropertyInputProps?.user;
702
+ item.defaultPages = defaultPages;
703
+ item.navigateTo = navigateTo;
704
+ item.isModal = isModal;
705
+ item.fieldHeight = fieldHeight;
706
+ if (item.addressPropertyId) {
707
+ item.queryAddresses = queryAddresses;
708
+ }
709
+ if (item.property?.manyToManyPropertyId &&
710
+ apiServices &&
711
+ !item.middleObject &&
712
+ !item.initialMiddleObjectInstances) {
713
+ const getMiddleObjectInstances = async () => {
714
+ const filter = instance ? getMiddleObjectFilter(item.property, instance) : {};
715
+ return await apiServices.get(getPrefixedUrl(`/objects/${item.property.objectId}/instances`), { params: { filter: JSON.stringify(filter) } });
716
+ };
717
+ const middleObject = await apiServices.get(getPrefixedUrl(`/objects/${item.property.objectId}/effective?sanitizedVersion=true`), {
718
+ params: { filter: { fields: ['properties', 'actions', 'rootObjectId'] } },
719
+ });
720
+ const initialMiddleObjectInstances = await getMiddleObjectInstances();
721
+ item.initialMiddleObjectInstances = initialMiddleObjectInstances;
722
+ item.middleObject = middleObject;
723
+ item.getMiddleObjectInstances = getMiddleObjectInstances;
724
+ }
624
725
  }
625
- })))).filter((component) => !!component),
626
- ];
627
- });
726
+ return {
727
+ components: await addObjectPropertiesToComponentProps(properties, component.components, instance, objectPropertyInputProps, autoSave, readOnly, defaultPages, navigateTo, queryAddresses, apiServices, isModal, fieldHeight),
728
+ ...component,
729
+ ...(component.type === 'Object' && objectPropertyInputProps),
730
+ type: `${readOnly ? 'ViewOnly' : ''}${component.type}`,
731
+ properties: properties,
732
+ property,
733
+ instance: instance,
734
+ fromFormBuilder: true,
735
+ apiServices: apiServices,
736
+ user: objectPropertyInputProps?.user,
737
+ autoSave,
738
+ queryAddresses: component.isAddressLine1 ? queryAddresses : undefined,
739
+ isModal,
740
+ fieldHeight,
741
+ };
742
+ }
743
+ }))).filter((component) => !!component),
744
+ ];
628
745
  }
629
746
  export function getDefaultValue(initialValue, selectOptions) {
630
- var _a;
631
747
  if (!isEmpty(initialValue) || (initialValue !== undefined && typeof initialValue === 'number')) {
632
748
  if (Array.isArray(initialValue)) {
633
- return initialValue.map((option) => {
749
+ return initialValue
750
+ .map((option) => {
634
751
  if (option && typeof option === 'object' && 'value' in option) {
635
752
  return option.value;
636
753
  }
637
754
  else {
638
755
  return option;
639
756
  }
640
- });
757
+ })
758
+ .filter((option) => !/^{{.*}}$/.test(option));
641
759
  }
642
- else if (initialValue && typeof initialValue === 'object' && 'value' in initialValue) {
643
- return initialValue['value'];
760
+ else if (initialValue && isObject(initialValue) && 'value' in initialValue) {
761
+ return initialValue.value;
644
762
  }
645
763
  else {
646
- if (selectOptions === null || selectOptions === void 0 ? void 0 : selectOptions.length) {
647
- return (_a = selectOptions === null || selectOptions === void 0 ? void 0 : selectOptions.find((option) => option.value === initialValue)) === null || _a === void 0 ? void 0 : _a.label;
764
+ if (selectOptions?.length) {
765
+ return selectOptions?.find((option) => option.value === initialValue)?.label;
766
+ }
767
+ if (initialValue === 'currentDate') {
768
+ return DateTime.now().toISODate();
769
+ }
770
+ else if (initialValue === 'currentDateTime') {
771
+ return DateTime.now().toISO();
772
+ }
773
+ else if (initialValue === 'currentTime') {
774
+ return DateTime.now().toISOTime({
775
+ includeOffset: false,
776
+ suppressMilliseconds: true,
777
+ });
778
+ }
779
+ else if (/^{{.*}}$/.test(initialValue)) {
780
+ return undefined;
781
+ }
782
+ else {
783
+ return initialValue;
648
784
  }
649
- return initialValue;
650
785
  }
651
786
  }
652
787
  return undefined;
@@ -690,7 +825,6 @@ export const buildComponentPropsFromObjectProperties = (properties, objectId, in
690
825
  };
691
826
  properties = properties.filter((property) => property.type !== 'collection');
692
827
  return properties.flatMap((property) => {
693
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
694
828
  if (property.type === 'address') {
695
829
  const type = readOnly ? 'ViewOnlyTextField' : 'TextField';
696
830
  return [
@@ -699,10 +833,10 @@ export const buildComponentPropsFromObjectProperties = (properties, objectId, in
699
833
  key: `${property.id}.line1`,
700
834
  label: `${property.name} Line 1`,
701
835
  inputMask: property.mask,
702
- readOnly: !hasActionPermissions || readOnly || !!(property === null || property === void 0 ? void 0 : property.formula),
836
+ readOnly: !hasActionPermissions || readOnly || !!property?.formula,
703
837
  instance: instance,
704
- defaultValue: instance ? (_a = instance[property.id]) === null || _a === void 0 ? void 0 : _a[`line1`] : undefined,
705
- user: objectPropertyInputProps === null || objectPropertyInputProps === void 0 ? void 0 : objectPropertyInputProps.user,
838
+ defaultValue: instance ? instance[property.id]?.[`line1`] : undefined,
839
+ user: objectPropertyInputProps?.user,
706
840
  property: {
707
841
  id: `${property.id}.line1`,
708
842
  name: `${property.name} Line 1`,
@@ -723,10 +857,10 @@ export const buildComponentPropsFromObjectProperties = (properties, objectId, in
723
857
  key: `${property.id}.line2`,
724
858
  label: `${property.name} Line 2`,
725
859
  inputMask: property.mask,
726
- readOnly: !hasActionPermissions || readOnly || !!(property === null || property === void 0 ? void 0 : property.formula),
860
+ readOnly: !hasActionPermissions || readOnly || !!property?.formula,
727
861
  instance: instance,
728
- defaultValue: instance ? (_b = instance[property.id]) === null || _b === void 0 ? void 0 : _b[`line2`] : undefined,
729
- user: objectPropertyInputProps === null || objectPropertyInputProps === void 0 ? void 0 : objectPropertyInputProps.user,
862
+ defaultValue: instance ? instance[property.id]?.[`line2`] : undefined,
863
+ user: objectPropertyInputProps?.user,
730
864
  property: {
731
865
  id: `${property.id}.line2`,
732
866
  name: `${property.name} Line 2`,
@@ -741,10 +875,10 @@ export const buildComponentPropsFromObjectProperties = (properties, objectId, in
741
875
  key: `${property.id}.city`,
742
876
  label: `${property.name} City`,
743
877
  inputMask: property.mask,
744
- readOnly: !hasActionPermissions || readOnly || !!(property === null || property === void 0 ? void 0 : property.formula),
878
+ readOnly: !hasActionPermissions || readOnly || !!property?.formula,
745
879
  instance: instance,
746
- defaultValue: instance ? (_c = instance[property.id]) === null || _c === void 0 ? void 0 : _c[`city`] : undefined,
747
- user: objectPropertyInputProps === null || objectPropertyInputProps === void 0 ? void 0 : objectPropertyInputProps.user,
880
+ defaultValue: instance ? instance[property.id]?.[`city`] : undefined,
881
+ user: objectPropertyInputProps?.user,
748
882
  property: {
749
883
  id: `${property.id}.city`,
750
884
  name: `${property.name} City`,
@@ -762,10 +896,10 @@ export const buildComponentPropsFromObjectProperties = (properties, objectId, in
762
896
  key: `${property.id}.county`,
763
897
  label: `${property.name} County`,
764
898
  inputMask: property.mask,
765
- readOnly: !hasActionPermissions || readOnly || !!(property === null || property === void 0 ? void 0 : property.formula),
899
+ readOnly: !hasActionPermissions || readOnly || !!property?.formula,
766
900
  instance: instance,
767
- defaultValue: instance ? (_d = instance[property.id]) === null || _d === void 0 ? void 0 : _d[`county`] : undefined,
768
- user: objectPropertyInputProps === null || objectPropertyInputProps === void 0 ? void 0 : objectPropertyInputProps.user,
901
+ defaultValue: instance ? instance[property.id]?.[`county`] : undefined,
902
+ user: objectPropertyInputProps?.user,
769
903
  property: {
770
904
  id: `${property.id}.county`,
771
905
  name: `${property.name} County`,
@@ -779,10 +913,10 @@ export const buildComponentPropsFromObjectProperties = (properties, objectId, in
779
913
  key: `${property.id}.state`,
780
914
  label: `${property.name} State`,
781
915
  inputMask: property.mask,
782
- readOnly: !hasActionPermissions || readOnly || !!(property === null || property === void 0 ? void 0 : property.formula),
916
+ readOnly: !hasActionPermissions || readOnly || !!property?.formula,
783
917
  instance: instance,
784
- defaultValue: instance ? (_e = instance[property.id]) === null || _e === void 0 ? void 0 : _e[`state`] : undefined,
785
- user: objectPropertyInputProps === null || objectPropertyInputProps === void 0 ? void 0 : objectPropertyInputProps.user,
918
+ defaultValue: instance ? instance[property.id]?.[`state`] : undefined,
919
+ user: objectPropertyInputProps?.user,
786
920
  property: {
787
921
  id: `${property.id}.state`,
788
922
  name: `${property.name} State`,
@@ -800,10 +934,10 @@ export const buildComponentPropsFromObjectProperties = (properties, objectId, in
800
934
  key: `${property.id}.zipCode`,
801
935
  label: `${property.name} Zip Code`,
802
936
  inputMask: property.mask,
803
- readOnly: !hasActionPermissions || readOnly || !!(property === null || property === void 0 ? void 0 : property.formula),
937
+ readOnly: !hasActionPermissions || readOnly || !!property?.formula,
804
938
  instance: instance,
805
- defaultValue: instance ? (_f = instance[property.id]) === null || _f === void 0 ? void 0 : _f[`zipCode`] : undefined,
806
- user: objectPropertyInputProps === null || objectPropertyInputProps === void 0 ? void 0 : objectPropertyInputProps.user,
939
+ defaultValue: instance ? instance[property.id]?.[`zipCode`] : undefined,
940
+ user: objectPropertyInputProps?.user,
807
941
  property: {
808
942
  id: `${property.id}.zipCode`,
809
943
  name: `${property.name} Zip Code`,
@@ -818,8 +952,8 @@ export const buildComponentPropsFromObjectProperties = (properties, objectId, in
818
952
  },
819
953
  ];
820
954
  }
821
- let minDate = (_h = (_g = property.validation) === null || _g === void 0 ? void 0 : _g.from) !== null && _h !== void 0 ? _h : '';
822
- let maxDate = (_k = (_j = property.validation) === null || _j === void 0 ? void 0 : _j.to) !== null && _k !== void 0 ? _k : '';
955
+ let minDate = property.validation?.from ?? '';
956
+ let maxDate = property.validation?.to ?? '';
823
957
  if (minDate && /^{{.*}}$/.test(minDate)) {
824
958
  const fragments = minDate.split(/\s/);
825
959
  if (fragments.length === 1) {
@@ -852,43 +986,70 @@ export const buildComponentPropsFromObjectProperties = (properties, objectId, in
852
986
  .join(' ');
853
987
  }
854
988
  }
855
- return Object.assign(Object.assign({ type: `${readOnly ? 'ViewOnly' : ''}${matchType(property.type)}`, key: property.id, label: property.name, inputMask: property.mask, multiple: ['array', 'document'].includes(property.type), readOnly: !hasActionPermissions || readOnly || !!(property === null || property === void 0 ? void 0 : property.formula), instance: instance, validate: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ required: property.required }, (property.type === 'date' &&
856
- property.validation && {
857
- minDate,
858
- maxDate,
859
- customMessage: property.validation.errorMessage,
860
- })), (property.type === 'date-time' &&
861
- property.validation && {
862
- minTime: property.validation.from,
863
- maxTime: property.validation.to,
864
- customMessage: (property === null || property === void 0 ? void 0 : property.validation).errorMessage,
865
- })), (property.type === 'time' &&
866
- property.validation && {
867
- minTime: property.validation.from,
868
- maxTime: property.validation.to,
869
- customMessage: (property === null || property === void 0 ? void 0 : property.validation).errorMessage,
870
- })), ((property.type === 'integer' || property.type === 'number') &&
871
- property.validation && {
872
- min: property.validation.minimum,
873
- max: property.validation.maximum,
874
- customMessage: property.validation.errorMessage,
875
- })), (property.type === 'string' &&
876
- property.validation &&
877
- Object.hasOwnProperty.call(property.validation, 'rules') && {
878
- operator: property.validation.operator,
879
- regexes: (_l = property.validation.rules) === null || _l === void 0 ? void 0 : _l.map((rule) => {
880
- var _a;
881
- return (Object.assign(Object.assign({}, rule), { errorMessage: ((_a = rule.errorMessage) === null || _a === void 0 ? void 0 : _a.length)
989
+ return {
990
+ type: `${readOnly ? 'ViewOnly' : ''}${matchType(property.type)}`,
991
+ key: property.id,
992
+ label: property.name,
993
+ inputMask: property.mask,
994
+ multiple: ['array', 'document'].includes(property.type),
995
+ readOnly: !hasActionPermissions || readOnly || !!property?.formula,
996
+ instance: instance,
997
+ validate: {
998
+ required: property.required,
999
+ ...(property.type === 'date' &&
1000
+ property.validation && {
1001
+ minDate,
1002
+ maxDate,
1003
+ customMessage: property.validation.errorMessage,
1004
+ }),
1005
+ ...(property.type === 'date-time' &&
1006
+ property.validation && {
1007
+ minTime: property.validation.from,
1008
+ maxTime: property.validation.to,
1009
+ customMessage: (property?.validation).errorMessage,
1010
+ }),
1011
+ ...(property.type === 'time' &&
1012
+ property.validation && {
1013
+ minTime: property.validation.from,
1014
+ maxTime: property.validation.to,
1015
+ customMessage: (property?.validation).errorMessage,
1016
+ }),
1017
+ ...((property.type === 'integer' || property.type === 'number') &&
1018
+ property.validation && {
1019
+ min: property.validation.minimum,
1020
+ max: property.validation.maximum,
1021
+ customMessage: property.validation.errorMessage,
1022
+ }),
1023
+ ...(property.type === 'string' &&
1024
+ property.validation &&
1025
+ Object.hasOwnProperty.call(property.validation, 'rules') && {
1026
+ operator: property.validation.operator,
1027
+ regexes: property.validation.rules?.map((rule) => ({
1028
+ ...rule,
1029
+ errorMessage: rule.errorMessage?.length
882
1030
  ? rule.errorMessage
883
- : 'Property is not in a valid format' }));
1031
+ : 'Property is not in a valid format',
1032
+ })),
884
1033
  }),
885
- })), (property.type === 'document' &&
886
- property.validation && {
887
- minDocuments: property.validation.minDocuments,
888
- maxDocuments: property.validation.maxDocuments,
889
- customMessage: property.validation.errorMessage,
890
- })), property.validation), objectId }, (property.type === 'object' && objectPropertyInputProps)), { defaultValue: instance ? instance[property.id] : undefined, user: objectPropertyInputProps === null || objectPropertyInputProps === void 0 ? void 0 : objectPropertyInputProps.user, apiServices: objectPropertyInputProps === null || objectPropertyInputProps === void 0 ? void 0 : objectPropertyInputProps.apiServices, property: property, fieldHeight,
891
- autoSave, queryAddresses: ['collection', 'object'].includes(property === null || property === void 0 ? void 0 : property.type) ? queryAddresses : undefined, isModal });
1034
+ ...(property.type === 'document' &&
1035
+ property.validation && {
1036
+ minDocuments: property.validation.minDocuments,
1037
+ maxDocuments: property.validation.maxDocuments,
1038
+ customMessage: property.validation.errorMessage,
1039
+ }),
1040
+ ...property.validation,
1041
+ },
1042
+ objectId,
1043
+ ...(property.type === 'object' && objectPropertyInputProps),
1044
+ defaultValue: instance ? instance[property.id] : undefined,
1045
+ user: objectPropertyInputProps?.user,
1046
+ apiServices: objectPropertyInputProps?.apiServices,
1047
+ property: property,
1048
+ fieldHeight,
1049
+ autoSave,
1050
+ queryAddresses: ['collection', 'object'].includes(property?.type) ? queryAddresses : undefined,
1051
+ isModal,
1052
+ };
892
1053
  });
893
1054
  };
894
1055
  // The following function is used to build the form components from the document properties.
@@ -934,7 +1095,6 @@ export function transformToWhere(mongoQuery) {
934
1095
  });
935
1096
  }
936
1097
  export function updateCriteriaInputs(criteria, field, fieldValue, isInputField) {
937
- var _a;
938
1098
  for (const [key, value] of Object.entries(criteria)) {
939
1099
  if (isArray(value)) {
940
1100
  for (const index in value) {
@@ -944,8 +1104,10 @@ export function updateCriteriaInputs(criteria, field, fieldValue, isInputField)
944
1104
  else {
945
1105
  value[index] =
946
1106
  typeof value[index] === 'string'
947
- ? ((_a = value[index]) === null || _a === void 0 ? void 0 : _a.replaceAll(!isInputField ? `{{{${field}}}}` : `{{{input.${field}}}}`, fieldValue !== null && fieldValue !== void 0 ? fieldValue : '').trim()) || undefined
948
- : value !== null && value !== void 0 ? value : undefined;
1107
+ ? value[index]
1108
+ ?.replaceAll(!isInputField ? `{{{${field}}}}` : `{{{input.${field}}}}`, fieldValue ?? '')
1109
+ .trim() || undefined
1110
+ : value ?? undefined;
949
1111
  }
950
1112
  }
951
1113
  }
@@ -955,8 +1117,10 @@ export function updateCriteriaInputs(criteria, field, fieldValue, isInputField)
955
1117
  else {
956
1118
  criteria[key] =
957
1119
  typeof value === 'string'
958
- ? (value === null || value === void 0 ? void 0 : value.replaceAll(!isInputField ? `{{{${field}}}}` : `{{{input.${field}}}}`, fieldValue !== null && fieldValue !== void 0 ? fieldValue : '').trim()) || undefined
959
- : value !== null && value !== void 0 ? value : undefined;
1120
+ ? value
1121
+ ?.replaceAll(!isInputField ? `{{{${field}}}}` : `{{{input.${field}}}}`, fieldValue ?? '')
1122
+ .trim() || undefined
1123
+ : value ?? undefined;
960
1124
  }
961
1125
  }
962
1126
  }
@@ -987,7 +1151,7 @@ export function getAllCriteriaInputs(criteria) {
987
1151
  return uniq(result.map((item) => item.replace('{{{input.', '').replace('}}}', '')));
988
1152
  }
989
1153
  export function isPropertyVisible(conditional, formData) {
990
- const isConditional = !!(conditional === null || conditional === void 0 ? void 0 : conditional.when);
1154
+ const isConditional = !!conditional?.when;
991
1155
  if (!isConditional) {
992
1156
  return true;
993
1157
  }
@@ -1004,9 +1168,10 @@ export function normalizeDateTime(dateTime) {
1004
1168
  return new Date(dateTime.toString()).toISOString();
1005
1169
  }
1006
1170
  export function normalizeDates(instances, object) {
1007
- var _a, _b;
1008
1171
  const dateProps = ['date', 'date-time', 'time'];
1009
- const properties = (_b = (_a = object === null || object === void 0 ? void 0 : object.properties) === null || _a === void 0 ? void 0 : _a.filter((property) => dateProps.includes(property.type)).reduce((agg, property) => Object.assign(agg, { [property.id]: property.type }), {})) !== null && _b !== void 0 ? _b : {};
1172
+ const properties = object?.properties
1173
+ ?.filter((property) => dateProps.includes(property.type))
1174
+ .reduce((agg, property) => Object.assign(agg, { [property.id]: property.type }), {}) ?? {};
1010
1175
  const propKeys = Object.keys(properties);
1011
1176
  instances.forEach((instance) => {
1012
1177
  Object.keys(instance).forEach((key) => {