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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (202) hide show
  1. package/dist/published/components/core/Accordion/Accordion.js +1 -1
  2. package/dist/published/components/core/Accordion/AccordionActions/AccordionActions.js +1 -1
  3. package/dist/published/components/core/Accordion/AccordionDetails/AccordionDetails.js +1 -1
  4. package/dist/published/components/core/Accordion/AccordionSummary/AccordionSummary.js +1 -1
  5. package/dist/published/components/core/Alert/Alert.js +8 -9
  6. package/dist/published/components/core/AlertTitle/AlertTitle.js +1 -1
  7. package/dist/published/components/core/AppBar/AppBar.js +1 -1
  8. package/dist/published/components/core/Autocomplete/Autocomplete.js +33 -15
  9. package/dist/published/components/core/Autocomplete/Autocomplete.test.js +1 -1
  10. package/dist/published/components/core/Avatar/Avatar.js +7 -4
  11. package/dist/published/components/core/Backdrop/Backdrop.js +1 -1
  12. package/dist/published/components/core/Badge/Badge.js +1 -1
  13. package/dist/published/components/core/Breadcrumbs/Breadcrumbs.js +1 -1
  14. package/dist/published/components/core/Button/Button.js +1 -1
  15. package/dist/published/components/core/ButtonGroup/ButtonGroup.js +1 -1
  16. package/dist/published/components/core/Card/Card.js +1 -1
  17. package/dist/published/components/core/Checkbox/Checkbox.js +1 -1
  18. package/dist/published/components/core/Chip/Chip.js +1 -1
  19. package/dist/published/components/core/CircularProgress/CircularProgress.js +1 -1
  20. package/dist/published/components/core/Collapse/Collapse.js +1 -1
  21. package/dist/published/components/core/DatePicker/DatePicker.js +4 -16
  22. package/dist/published/components/core/DateTimePicker/DateTimePicker.js +3 -15
  23. package/dist/published/components/core/Dialog/Dialog.js +1 -1
  24. package/dist/published/components/core/Dialog/DialogActions/DialogActions.js +2 -13
  25. package/dist/published/components/core/Dialog/DialogContent/DialogContent.js +1 -1
  26. package/dist/published/components/core/Dialog/DialogContentText/DialogContentText.js +1 -1
  27. package/dist/published/components/core/Dialog/DialogTitle/DialogTitle.js +1 -1
  28. package/dist/published/components/core/Divider/Divider.js +1 -1
  29. package/dist/published/components/core/Drawer/Drawer.js +1 -1
  30. package/dist/published/components/core/FieldError/FieldError.js +1 -2
  31. package/dist/published/components/core/FormElements/FormControl/FormControl.js +1 -1
  32. package/dist/published/components/core/FormElements/FormControlLabel/FormControlLabel.js +1 -1
  33. package/dist/published/components/core/FormElements/FormGroup/FormGroup.js +1 -1
  34. package/dist/published/components/core/FormElements/FormHelperText/FormHelperText.js +1 -1
  35. package/dist/published/components/core/FormElements/FormLabel/FormLabel.js +1 -1
  36. package/dist/published/components/core/IconButton/IconButton.js +1 -1
  37. package/dist/published/components/core/LinearProgress/LinearProgress.js +1 -1
  38. package/dist/published/components/core/Link/Link.js +1 -1
  39. package/dist/published/components/core/List/List.js +1 -1
  40. package/dist/published/components/core/List/ListItem.js +1 -1
  41. package/dist/published/components/core/List/ListItemText/ListItemText.js +1 -1
  42. package/dist/published/components/core/LoadingButton/LoadingButton.js +1 -1
  43. package/dist/published/components/core/LocalizationProvider/LocalizationProvider.js +3 -14
  44. package/dist/published/components/core/Menu/Menu.js +1 -1
  45. package/dist/published/components/core/Menu/MenuItem/MenuItem.js +1 -1
  46. package/dist/published/components/core/Paper/Paper.js +1 -1
  47. package/dist/published/components/core/Popover/Popover.js +1 -1
  48. package/dist/published/components/core/Popper/Popper.js +1 -1
  49. package/dist/published/components/core/RadioGroup/Radio.js +1 -1
  50. package/dist/published/components/core/RadioGroup/RadioGroup.js +1 -1
  51. package/dist/published/components/core/Select/Select.js +11 -4
  52. package/dist/published/components/core/Skeleton/Skeleton.js +1 -1
  53. package/dist/published/components/core/Snackbar/Snackbar.js +2 -2
  54. package/dist/published/components/core/StaticDatePicker/StaticDatePicker.js +3 -15
  55. package/dist/published/components/core/Stepper/Step/Step.js +1 -1
  56. package/dist/published/components/core/Stepper/StepButton/StepButton.js +1 -1
  57. package/dist/published/components/core/Stepper/StepConnector/StepConnector.js +1 -1
  58. package/dist/published/components/core/Stepper/StepContent/StepContent.js +1 -1
  59. package/dist/published/components/core/Stepper/StepIcon/StepIcon.js +1 -1
  60. package/dist/published/components/core/Stepper/StepLabel/StepLabel.js +1 -1
  61. package/dist/published/components/core/Stepper/Stepper.js +1 -1
  62. package/dist/published/components/core/Switch/Switch.js +1 -1
  63. package/dist/published/components/core/Table/Table.js +1 -1
  64. package/dist/published/components/core/Tabs/Tab/Tab.js +1 -1
  65. package/dist/published/components/core/Tabs/Tabs.js +1 -1
  66. package/dist/published/components/core/TextField/TextField.js +12 -6
  67. package/dist/published/components/core/ToggleButton/ToggleButton.js +1 -1
  68. package/dist/published/components/core/ToggleButtonGroup/ToggleButtonGroup.js +1 -1
  69. package/dist/published/components/core/Tooltip/Tooltip.js +15 -2
  70. package/dist/published/components/core/Typography/index.js +1 -1
  71. package/dist/published/components/custom/BuilderGrid/BuilderGrid.js +33 -29
  72. package/dist/published/components/custom/BuilderGrid/BuilderGridToolbar.js +1 -2
  73. package/dist/published/components/custom/BuilderGrid/EmptyContent.js +4 -5
  74. package/dist/published/components/custom/BuilderGrid/EmptyContentIllustration.js +6 -1
  75. package/dist/published/components/custom/BuilderGrid/ToolbarActions.js +3 -1
  76. package/dist/published/components/custom/CriteriaBuilder/CriteriaBuilder.js +46 -27
  77. package/dist/published/components/custom/CriteriaBuilder/CriteriaBuilder.test.js +12 -21
  78. package/dist/published/components/custom/CriteriaBuilder/ValueEditor.js +27 -34
  79. package/dist/published/components/custom/DataGrid/DataGrid.js +38 -33
  80. package/dist/published/components/custom/DataGrid/DateTimeCustomOperator.js +3 -5
  81. package/dist/published/components/custom/DataGrid/Toolbar.js +3 -4
  82. package/dist/published/components/custom/ErrorComponent/ErrorComponent.js +11 -1
  83. package/dist/published/components/custom/Form/Common/Form.js +106 -80
  84. package/dist/published/components/custom/Form/Common/FormComponentWrapper.js +20 -11
  85. package/dist/published/components/custom/Form/FormComponents/ButtonComponent.js +9 -20
  86. package/dist/published/components/custom/Form/FormComponents/DocumentComponent/Document.js +10 -20
  87. package/dist/published/components/custom/Form/FormComponents/DocumentComponent/DocumentComponent.js +24 -28
  88. package/dist/published/components/custom/Form/FormComponents/DocumentComponent/DocumentList.js +49 -64
  89. package/dist/published/components/custom/Form/FormComponents/FormFieldComponent.d.ts +1 -0
  90. package/dist/published/components/custom/Form/FormComponents/FormFieldComponent.js +109 -34
  91. package/dist/published/components/custom/Form/FormComponents/ImageComponent/Image.d.ts +2 -0
  92. package/dist/published/components/custom/Form/FormComponents/ImageComponent/Image.js +13 -25
  93. package/dist/published/components/custom/Form/FormComponents/ImageComponent/ImageComponent.d.ts +3 -1
  94. package/dist/published/components/custom/Form/FormComponents/ImageComponent/ImageComponent.js +30 -9
  95. package/dist/published/components/custom/Form/FormComponents/ObjectComponent/InstanceLookup.js +26 -31
  96. package/dist/published/components/custom/Form/FormComponents/ObjectComponent/ObjectComponent.d.ts +5 -4
  97. package/dist/published/components/custom/Form/FormComponents/ObjectComponent/ObjectComponent.js +70 -22
  98. package/dist/published/components/custom/Form/FormComponents/ObjectComponent/ObjectPropertyInput.js +93 -75
  99. package/dist/published/components/custom/Form/FormComponents/ObjectComponent/RelatedObjectInstance.d.ts +2 -2
  100. package/dist/published/components/custom/Form/FormComponents/ObjectComponent/RelatedObjectInstance.js +17 -26
  101. package/dist/published/components/custom/Form/FormComponents/RepeatableFieldComponent/ActionDialog.js +20 -24
  102. package/dist/published/components/custom/Form/FormComponents/RepeatableFieldComponent/ManyToMany/DropdownRepeatableField.js +22 -33
  103. package/dist/published/components/custom/Form/FormComponents/RepeatableFieldComponent/ManyToMany/DropdownRepeatableFieldInput.js +12 -9
  104. package/dist/published/components/custom/Form/FormComponents/RepeatableFieldComponent/RepeatableField.js +61 -60
  105. package/dist/published/components/custom/Form/FormComponents/RepeatableFieldComponent/RepeatableFieldComponent.js +8 -6
  106. package/dist/published/components/custom/Form/FormComponents/UserComponent/UserComponent.d.ts +3 -1
  107. package/dist/published/components/custom/Form/FormComponents/UserComponent/UserComponent.js +55 -12
  108. package/dist/published/components/custom/Form/FormComponents/UserComponent/UserProperty.js +32 -30
  109. package/dist/published/components/custom/Form/FormComponents/ViewOnlyComponent.js +12 -9
  110. package/dist/published/components/custom/Form/types.d.ts +5 -5
  111. package/dist/published/components/custom/Form/utils.js +611 -446
  112. package/dist/published/components/custom/FormField/AddressFieldComponent/AddressFieldComponent.test.js +41 -54
  113. package/dist/published/components/custom/FormField/AddressFieldComponent/addressFieldComponent.js +7 -8
  114. package/dist/published/components/custom/FormField/BooleanSelect/BooleanSelect.js +1 -1
  115. package/dist/published/components/custom/FormField/BooleanSelect/BooleanSelect.test.js +5 -14
  116. package/dist/published/components/custom/FormField/DatePickerSelect/DatePickerSelect.js +2 -2
  117. package/dist/published/components/custom/FormField/DatePickerSelect/DatePickerSelect.test.js +12 -21
  118. package/dist/published/components/custom/FormField/DateTimePickerSelect/DateTimePickerSelect.js +2 -2
  119. package/dist/published/components/custom/FormField/DateTimePickerSelect/DateTimePickerSelect.test.js +12 -21
  120. package/dist/published/components/custom/FormField/FileUpload/FileUpload.js +10 -11
  121. package/dist/published/components/custom/FormField/FormField.js +10 -10
  122. package/dist/published/components/custom/FormField/InputFieldComponent/InputFieldComponent.js +22 -30
  123. package/dist/published/components/custom/FormField/InputFieldComponent/InputFieldComponent.test.js +8 -17
  124. package/dist/published/components/custom/FormField/Select/Select.js +5 -6
  125. package/dist/published/components/custom/FormField/Select/Select.test.js +18 -27
  126. package/dist/published/components/custom/FormField/TimePickerSelect/TimePickerSelect.js +4 -4
  127. package/dist/published/components/custom/HistoryLog/DisplayedProperty.js +12 -13
  128. package/dist/published/components/custom/HistoryLog/HistoryData.js +49 -45
  129. package/dist/published/components/custom/HistoryLog/HistoryLoading.js +5 -5
  130. package/dist/published/components/custom/HistoryLog/index.js +5 -6
  131. package/dist/published/components/custom/Menubar/Menubar.js +2 -2
  132. package/dist/published/components/custom/MultiSelect/MultiSelect.js +38 -50
  133. package/dist/published/components/custom/MultiSelect/SortableItem.js +1 -1
  134. package/dist/published/components/custom/RepeatableField/RepeatableField.js +14 -16
  135. package/dist/published/components/custom/UserAvatar/UserAvatar.js +12 -5
  136. package/dist/published/components/custom/util.js +1 -1
  137. package/dist/published/components/layout/Box/Box.js +1 -1
  138. package/dist/published/components/layout/Container/Container.js +1 -1
  139. package/dist/published/components/layout/Grid/Grid.js +1 -1
  140. package/dist/published/components/layout/Stack/Stack.js +1 -1
  141. package/dist/published/icons/custom/FileWithExtension.js +8 -4
  142. package/dist/published/icons/custom/Inherited.js +8 -6
  143. package/dist/published/icons/custom/Overrides.js +9 -7
  144. package/dist/published/icons/custom/TrashCan.js +10 -8
  145. package/dist/published/icons/custom/UploadCloud.js +9 -7
  146. package/dist/published/stories/Accordion.stories.js +2 -2
  147. package/dist/published/stories/Alert.stories.js +1 -1
  148. package/dist/published/stories/AlertTitle.stories.js +1 -1
  149. package/dist/published/stories/Autocomplete.stories.js +2 -2
  150. package/dist/published/stories/Avatar.stories.js +1 -1
  151. package/dist/published/stories/Backdrop.stories.js +1 -1
  152. package/dist/published/stories/Badge.stories.js +1 -1
  153. package/dist/published/stories/Box.stories.js +2 -2
  154. package/dist/published/stories/Breadcrumbs.stories.js +1 -1
  155. package/dist/published/stories/Button.stories.js +1 -1
  156. package/dist/published/stories/ButtonGroup.stories.js +1 -1
  157. package/dist/published/stories/Card.stories.js +1 -1
  158. package/dist/published/stories/Checkbox.stories.js +1 -1
  159. package/dist/published/stories/Chip.stories.js +1 -1
  160. package/dist/published/stories/CircularProgress.stories.js +1 -1
  161. package/dist/published/stories/Collapse.stories.js +1 -1
  162. package/dist/published/stories/Container.stories.js +1 -1
  163. package/dist/published/stories/CriteriaBuilder.stories.js +7 -3
  164. package/dist/published/stories/DataGrid.stories.js +3 -3
  165. package/dist/published/stories/DatePicker.stories.js +3 -14
  166. package/dist/published/stories/Dialog.stories.js +1 -1
  167. package/dist/published/stories/Divider.stories.js +1 -1
  168. package/dist/published/stories/Drawer.stories.js +2 -2
  169. package/dist/published/stories/FormControl.stories.js +1 -1
  170. package/dist/published/stories/FormControlLabel.stories.js +1 -1
  171. package/dist/published/stories/FormField.stories.js +3 -12
  172. package/dist/published/stories/FormGroup.stories.js +1 -1
  173. package/dist/published/stories/FormHelperText.stories.js +1 -1
  174. package/dist/published/stories/FormLabel.stories.js +1 -1
  175. package/dist/published/stories/Grid.stories.js +1 -1
  176. package/dist/published/stories/HistoryLog.stories.js +1 -1
  177. package/dist/published/stories/IconButton.stories.js +4 -4
  178. package/dist/published/stories/LinearProgress.stories.js +1 -1
  179. package/dist/published/stories/Link.stories.js +1 -1
  180. package/dist/published/stories/List.stories.js +2 -2
  181. package/dist/published/stories/Menu.stories.js +2 -2
  182. package/dist/published/stories/MenuBar.stories.js +1 -1
  183. package/dist/published/stories/MultiSelect.stories.js +3 -3
  184. package/dist/published/stories/Palette.stories.js +11 -11
  185. package/dist/published/stories/Paper.stories.js +1 -1
  186. package/dist/published/stories/RadioGroup.stories.js +1 -1
  187. package/dist/published/stories/RepeatableField.stories.js +6 -7
  188. package/dist/published/stories/RichTextViewer.stories.js +1 -1
  189. package/dist/published/stories/Skeleton.stories.js +1 -1
  190. package/dist/published/stories/Snackbar.stories.js +1 -1
  191. package/dist/published/stories/Stack.stories.js +1 -1
  192. package/dist/published/stories/StaticDatePicker.stories.js +3 -14
  193. package/dist/published/stories/Stepper.stories.js +3 -3
  194. package/dist/published/stories/Switch.stories.js +1 -1
  195. package/dist/published/stories/Table.stories.js +2 -2
  196. package/dist/published/stories/Tabs.stories.js +6 -17
  197. package/dist/published/stories/TextField.stories.js +1 -1
  198. package/dist/published/stories/TimePicker.stories.js +3 -14
  199. package/dist/published/stories/TimePickerSelect.stories.js +3 -14
  200. package/dist/published/stories/ToggleButton.stories.js +4 -4
  201. package/dist/published/theme/UIThemeProvider.js +1 -2
  202. package/package.json +1 -1
@@ -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 '@testing-library/jest-dom/extend-expect';
11
2
  import { render, screen } from '@testing-library/react';
12
3
  import { userEvent } from '@testing-library/user-event';
@@ -19,66 +10,62 @@ const addressProperty = {
19
10
  name: 'Line 1',
20
11
  type: 'text',
21
12
  };
22
- test('displays matching addresses', () => __awaiter(void 0, void 0, void 0, function* () {
13
+ test('displays matching addresses', async () => {
23
14
  const user = userEvent.setup();
24
- const queryAddresses = (search) => __awaiter(void 0, void 0, void 0, function* () {
25
- return [
26
- {
27
- address: {
28
- line1: '1234 Main Street',
29
- city: 'Columbia',
30
- county: 'Howard',
31
- state: 'Maryland',
32
- zipCode: '21046',
33
- },
15
+ const queryAddresses = async (search) => [
16
+ {
17
+ address: {
18
+ line1: '1234 Main Street',
19
+ city: 'Columbia',
20
+ county: 'Howard',
21
+ state: 'Maryland',
22
+ zipCode: '21046',
34
23
  },
35
- {
36
- address: {
37
- line1: '12345 Main Avenue',
38
- city: 'Columbia',
39
- county: 'Howard',
40
- state: 'Maryland',
41
- zipCode: '21046',
42
- },
24
+ },
25
+ {
26
+ address: {
27
+ line1: '12345 Main Avenue',
28
+ city: 'Columbia',
29
+ county: 'Howard',
30
+ state: 'Maryland',
31
+ zipCode: '21046',
43
32
  },
44
- ];
45
- });
33
+ },
34
+ ];
46
35
  render(React.createElement(AddressFieldComponent, { id: "addressSearch", property: addressProperty, onChange: () => { }, queryAddresses: queryAddresses }));
47
36
  const addressField = screen.getByRole('searchbox');
48
- yield user.type(addressField, '1234 Main');
49
- yield screen.findByRole('menuitem', { name: /1234 Main Street/ });
50
- yield screen.findByRole('menuitem', { name: /12345 Main Avenue/ });
51
- }));
52
- test('returns manually typed address', () => __awaiter(void 0, void 0, void 0, function* () {
37
+ await user.type(addressField, '1234 Main');
38
+ await screen.findByRole('menuitem', { name: /1234 Main Street/ });
39
+ await screen.findByRole('menuitem', { name: /12345 Main Avenue/ });
40
+ });
41
+ test('returns manually typed address', async () => {
53
42
  const user = userEvent.setup();
54
43
  const onChangeMock = jest.fn((name, value, property, unused) => { });
55
44
  render(React.createElement(AddressFieldComponent, { id: "addressSearch", property: addressProperty, onChange: onChangeMock }));
56
45
  const addressField = screen.getByRole('searchbox');
57
- yield user.type(addressField, '1234 Main St');
46
+ await user.type(addressField, '1234 Main St');
58
47
  expect(onChangeMock).toBeCalledTimes(12);
59
48
  expect(onChangeMock).lastCalledWith('addressLine1', '1234 Main St', addressProperty, undefined);
60
- }));
61
- test('returns selected search result', () => __awaiter(void 0, void 0, void 0, function* () {
49
+ });
50
+ test('returns selected search result', async () => {
62
51
  const user = userEvent.setup();
63
52
  const onChangeMock = jest.fn((name, value, property, unused) => { });
64
- const queryAddresses = (search) => __awaiter(void 0, void 0, void 0, function* () {
65
- return [
66
- {
67
- address: {
68
- line1: '1234 Main Street',
69
- city: 'Columbia',
70
- county: 'Howard',
71
- state: 'Maryland',
72
- zipCode: '21046',
73
- },
53
+ const queryAddresses = async (search) => [
54
+ {
55
+ address: {
56
+ line1: '1234 Main Street',
57
+ city: 'Columbia',
58
+ county: 'Howard',
59
+ state: 'Maryland',
60
+ zipCode: '21046',
74
61
  },
75
- ];
76
- });
62
+ },
63
+ ];
77
64
  render(React.createElement(AddressFieldComponent, { id: "addressSearch", property: addressProperty, onChange: onChangeMock, queryAddresses: queryAddresses }));
78
65
  const addressField = screen.getByRole('searchbox');
79
- yield user.type(addressField, '1234 Main');
80
- const searchResult = yield screen.findByRole('menuitem', { name: /1234 Main Street/ });
81
- yield user.click(searchResult);
66
+ await user.type(addressField, '1234 Main');
67
+ const searchResult = await screen.findByRole('menuitem', { name: /1234 Main Street/ });
68
+ await user.click(searchResult);
82
69
  expect(onChangeMock).lastCalledWith('addressLine1', {
83
70
  line1: '1234 Main Street',
84
71
  city: 'Columbia',
@@ -86,4 +73,4 @@ test('returns selected search result', () => __awaiter(void 0, void 0, void 0, f
86
73
  state: 'Maryland',
87
74
  zipCode: '21046',
88
75
  }, addressProperty, undefined);
89
- }));
76
+ });
@@ -4,16 +4,15 @@ import InputMask from 'react-input-mask';
4
4
  import { List, MenuItem, TextField, Typography } from '../../../core';
5
5
  import { Box } from '../../../layout';
6
6
  const AddressFieldComponent = (props) => {
7
- var _a;
8
7
  const { id, property, defaultValue, error, errorMessage, onBlur, readOnly, required, size, placeholder, mask, isMultiLineText, rows, inputMaskPlaceholderChar, queryAddresses, additionalProps, } = props;
9
- const [value, setValue] = useState(defaultValue !== null && defaultValue !== void 0 ? defaultValue : '');
8
+ const [value, setValue] = useState(defaultValue ?? '');
10
9
  const [selectOptions, setSelectOptions] = useState([]);
11
10
  const [anchorEl, setAnchorEl] = useState(null);
12
11
  const textFieldRef = useRef(null);
13
12
  const open = Boolean(anchorEl);
14
13
  const popoverId = open ? `${id}-popover` : undefined;
15
14
  useEffect(() => {
16
- setValue(defaultValue !== null && defaultValue !== void 0 ? defaultValue : '');
15
+ setValue(defaultValue ?? '');
17
16
  }, [defaultValue]);
18
17
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
19
18
  const handleChange = (e) => {
@@ -27,7 +26,7 @@ const AddressFieldComponent = (props) => {
27
26
  .filter((address) => address.address.line1)
28
27
  .map((address) => {
29
28
  const { line1, city, county, state, zipCode } = address.address;
30
- const label = line1 !== null && line1 !== void 0 ? line1 : '';
29
+ const label = line1 ?? '';
31
30
  let sublabel = [city, county, state].filter(Boolean).join(', ');
32
31
  if (zipCode) {
33
32
  sublabel = sublabel ? `${sublabel} ${zipCode}` : zipCode;
@@ -46,10 +45,10 @@ const AddressFieldComponent = (props) => {
46
45
  setAnchorEl(null);
47
46
  };
48
47
  return (React.createElement(Box, null,
49
- !mask ? (React.createElement(TextField, Object.assign({ id: id, inputRef: textFieldRef, onChange: !readOnly ? handleChange : undefined, error: error, errorMessage: errorMessage, value: value, fullWidth: true, onBlur: onBlur, size: size !== null && size !== void 0 ? size : 'medium', placeholder: placeholder, InputProps: {
48
+ !mask ? (React.createElement(TextField, { id: id, inputRef: textFieldRef, onChange: !readOnly ? handleChange : undefined, error: error, errorMessage: errorMessage, value: value, fullWidth: true, onBlur: onBlur, size: size ?? 'medium', placeholder: placeholder, InputProps: {
50
49
  type: 'search',
51
50
  autoComplete: 'off',
52
- }, required: required, readOnly: readOnly, multiline: property.type === 'string' && !readOnly && isMultiLineText, rows: isMultiLineText ? (rows ? rows : 3) : undefined }, (additionalProps !== null && additionalProps !== void 0 ? additionalProps : {})))) : (React.createElement(InputMask, { mask: mask, maskChar: inputMaskPlaceholderChar !== null && inputMaskPlaceholderChar !== void 0 ? inputMaskPlaceholderChar : '_', value: value, onChange: !readOnly ? handleChange : undefined, onBlur: onBlur, alwaysShowMask: true }, () => (React.createElement(TextField, Object.assign({ id: id, inputRef: textFieldRef, sx: readOnly
51
+ }, required: required, readOnly: readOnly, multiline: property.type === 'string' && !readOnly && isMultiLineText, rows: isMultiLineText ? (rows ? rows : 3) : undefined, ...(additionalProps ?? {}) })) : (React.createElement(InputMask, { mask: mask, maskChar: inputMaskPlaceholderChar ?? '_', value: value, onChange: !readOnly ? handleChange : undefined, onBlur: onBlur, alwaysShowMask: true }, () => (React.createElement(TextField, { id: id, inputRef: textFieldRef, sx: readOnly
53
52
  ? {
54
53
  '& .MuiOutlinedInput-notchedOutline': {
55
54
  border: 'none',
@@ -59,7 +58,7 @@ const AddressFieldComponent = (props) => {
59
58
  backgroundColor: '#f4f6f8',
60
59
  },
61
60
  }
62
- : undefined, required: required, error: error, errorMessage: errorMessage, InputProps: { readOnly: readOnly }, fullWidth: true, size: size !== null && size !== void 0 ? size : 'medium', type: 'text', multiline: property.type === 'string' && !readOnly && isMultiLineText, rows: isMultiLineText ? (rows ? rows : 3) : undefined, value: value }, (additionalProps !== null && additionalProps !== void 0 ? additionalProps : {})))))),
61
+ : undefined, required: required, error: error, errorMessage: errorMessage, InputProps: { readOnly: readOnly }, fullWidth: true, size: size ?? 'medium', type: 'text', multiline: property.type === 'string' && !readOnly && isMultiLineText, rows: isMultiLineText ? (rows ? rows : 3) : undefined, value: value, ...(additionalProps ?? {}) })))),
63
62
  !readOnly && (React.createElement(Popover, { id: popoverId, open: open, anchorEl: anchorEl, onClose: handleClose, disableAutoFocus: true, marginThreshold: undefined, anchorOrigin: {
64
63
  vertical: 'bottom',
65
64
  horizontal: 'left',
@@ -68,7 +67,7 @@ const AddressFieldComponent = (props) => {
68
67
  horizontal: 'left',
69
68
  }, PaperProps: {
70
69
  sx: {
71
- width: ((_a = textFieldRef === null || textFieldRef === void 0 ? void 0 : textFieldRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth)
70
+ width: textFieldRef?.current?.offsetWidth
72
71
  ? `${textFieldRef.current.offsetWidth}px`
73
72
  : '100%',
74
73
  height: 'fit-content',
@@ -21,6 +21,6 @@ const BooleanSelect = (props) => {
21
21
  value: false,
22
22
  },
23
23
  ];
24
- return readOnly ? (React.createElement(InputFieldComponent, Object.assign({}, props))) : (React.createElement(Autocomplete, Object.assign({ id: id, renderInput: (params) => (React.createElement(TextField, Object.assign({}, params, { value: value, error: error, errorMessage: errorMessage, onBlur: onBlur, fullWidth: true, sx: { background: 'white' }, size: size !== null && size !== void 0 ? size : 'medium', placeholder: placeholder }))), value: value, onChange: handleChange, inputValue: value, options: booleanOptions, disableClearable: true, sx: { background: 'white', borderRadius: '8px' } }, (additionalProps !== null && additionalProps !== void 0 ? additionalProps : {}))));
24
+ return readOnly ? (React.createElement(InputFieldComponent, { ...props })) : (React.createElement(Autocomplete, { id: id, renderInput: (params) => (React.createElement(TextField, { ...params, value: value, error: error, errorMessage: errorMessage, onBlur: onBlur, fullWidth: true, sx: { background: 'white' }, size: size ?? 'medium', placeholder: placeholder })), value: value, onChange: handleChange, inputValue: value, options: booleanOptions, disableClearable: true, sx: { background: 'white', borderRadius: '8px' }, ...(additionalProps ?? {}) }));
25
25
  };
26
26
  export default BooleanSelect;
@@ -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 '@testing-library/jest-dom/extend-expect';
11
2
  import { render, screen } from '@testing-library/react';
12
3
  import { userEvent } from '@testing-library/user-event';
@@ -19,14 +10,14 @@ const booleanProperty = {
19
10
  name: 'Question',
20
11
  type: 'boolean',
21
12
  };
22
- test('returns selected option', () => __awaiter(void 0, void 0, void 0, function* () {
13
+ test('returns selected option', async () => {
23
14
  const user = userEvent.setup();
24
15
  const onChangeMock = jest.fn((name, value, property) => { });
25
16
  render(React.createElement(BooleanSelect, { id: "chooseYesOrNo", property: booleanProperty, onChange: onChangeMock }));
26
17
  const inputField = screen.getByRole('combobox');
27
- yield user.click(inputField);
28
- const yesOption = yield screen.findByRole('option', { name: 'Yes' });
29
- yield user.click(yesOption);
18
+ await user.click(inputField);
19
+ const yesOption = await screen.findByRole('option', { name: 'Yes' });
20
+ await user.click(yesOption);
30
21
  expect(onChangeMock).toBeCalledWith('theQuestion', 'Yes', // ?? why not true/false?
31
22
  booleanProperty);
32
- }));
23
+ });
@@ -35,7 +35,7 @@ const DatePickerSelect = (props) => {
35
35
  setValue(date);
36
36
  onChange(property.id, date, property);
37
37
  };
38
- return readOnly ? (React.createElement(InputFieldComponent, Object.assign({}, Object.assign(Object.assign({}, props), { defaultValue: asMonthDayYearFormat(value) })))) : (React.createElement(LocalizationProvider, null,
39
- React.createElement(DatePicker, { value: value, onChange: handleChange, inputFormat: "MM/dd/yyyy", renderInput: (params) => (React.createElement(TextField, Object.assign({}, params, { id: id, error: error, errorMessage: errorMessage, onBlur: onBlur, fullWidth: true, required: required, sx: { background: 'white', borderRadius: '8px' }, size: size !== null && size !== void 0 ? size : 'medium' }, (additionalProps !== null && additionalProps !== void 0 ? additionalProps : {})))) })));
38
+ return readOnly ? (React.createElement(InputFieldComponent, { ...{ ...props, defaultValue: asMonthDayYearFormat(value) } })) : (React.createElement(LocalizationProvider, null,
39
+ React.createElement(DatePicker, { value: value, onChange: handleChange, inputFormat: "MM/dd/yyyy", renderInput: (params) => (React.createElement(TextField, { ...params, id: id, error: error, errorMessage: errorMessage, onBlur: onBlur, fullWidth: true, required: required, sx: { background: 'white', borderRadius: '8px' }, size: size ?? 'medium', ...(additionalProps ?? {}) })) })));
40
40
  };
41
41
  export default DatePickerSelect;
@@ -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 { LocalDate, Month } from '@js-joda/core';
11
2
  import '@testing-library/jest-dom/extend-expect';
12
3
  import { render, screen, within } from '@testing-library/react';
@@ -42,32 +33,32 @@ beforeAll(() => {
42
33
  afterAll(() => {
43
34
  jest.useRealTimers();
44
35
  });
45
- test('returns selected date', () => __awaiter(void 0, void 0, void 0, function* () {
36
+ test('returns selected date', async () => {
46
37
  const user = userEvent.setup();
47
38
  const onChangeMock = jest.fn((name, value, property) => { });
48
39
  render(React.createElement(DatePickerSelect, { id: "pickDate", property: dateProperty, onChange: onChangeMock }));
49
40
  const calendarIcon = screen.getByRole('button', { name: /Choose date/i });
50
- yield user.click(calendarIcon);
51
- const calendar = yield screen.findByRole('dialog');
52
- const feb29 = yield within(calendar).findByRole('gridcell', { name: '29' });
53
- yield user.click(feb29);
41
+ await user.click(calendarIcon);
42
+ const calendar = await screen.findByRole('dialog');
43
+ const feb29 = await within(calendar).findByRole('gridcell', { name: '29' });
44
+ await user.click(feb29);
54
45
  expect(onChangeMock).toBeCalledWith('testDate', LocalDate.of(2024, Month.FEBRUARY, 29), dateProperty);
55
- }), 10000);
56
- test('returns manually entered date', () => __awaiter(void 0, void 0, void 0, function* () {
46
+ }, 10000);
47
+ test('returns manually entered date', async () => {
57
48
  const user = userEvent.setup();
58
49
  const onChangeMock = jest.fn((name, value, property) => { });
59
50
  render(React.createElement(DatePickerSelect, { id: "pickDate", property: dateProperty, onChange: onChangeMock }));
60
51
  const input = screen.getByRole('textbox');
61
- yield user.type(input, '03/27/2024');
52
+ await user.type(input, '03/27/2024');
62
53
  expect(onChangeMock).toBeCalledTimes(8); // component ignores '/', i.e. input could also have been '03272024'
63
54
  expect(onChangeMock).lastCalledWith('testDate', LocalDate.of(2024, Month.MARCH, 27), dateProperty);
64
- }));
65
- test('returns incomplete dates', () => __awaiter(void 0, void 0, void 0, function* () {
55
+ });
56
+ test('returns incomplete dates', async () => {
66
57
  const user = userEvent.setup();
67
58
  const onChangeMock = jest.fn((name, value, property) => { });
68
59
  render(React.createElement(DatePickerSelect, { id: "pickDate", property: dateProperty, onChange: onChangeMock }));
69
60
  const input = screen.getByRole('textbox');
70
- yield user.type(input, '08/20');
61
+ await user.type(input, '08/20');
71
62
  // Component automatically appends '/' as needed.
72
63
  expect(onChangeMock).lastCalledWith('testDate', new InvalidDate('08/20/'), dateProperty);
73
- }));
64
+ });
@@ -42,7 +42,7 @@ const DateTimePickerSelect = (props) => {
42
42
  setValue(date);
43
43
  props.onChange(property.id, date, property);
44
44
  };
45
- return readOnly ? (React.createElement(InputFieldComponent, Object.assign({}, Object.assign(Object.assign({}, props), { defaultValue: formatDateTime(value) })))) : (React.createElement(LocalizationProvider, null,
46
- React.createElement(DateTimePicker, { value: value, onChange: handleChange, renderInput: (params) => (React.createElement(TextField, Object.assign({}, params, { id: id, error: error, errorMessage: errorMessage, onBlur: onBlur, fullWidth: true, required: required, sx: { background: 'white', borderRadius: '8px' }, size: size !== null && size !== void 0 ? size : 'medium' }, (additionalProps !== null && additionalProps !== void 0 ? additionalProps : {})))) })));
45
+ return readOnly ? (React.createElement(InputFieldComponent, { ...{ ...props, defaultValue: formatDateTime(value) } })) : (React.createElement(LocalizationProvider, null,
46
+ React.createElement(DateTimePicker, { value: value, onChange: handleChange, renderInput: (params) => (React.createElement(TextField, { ...params, id: id, error: error, errorMessage: errorMessage, onBlur: onBlur, fullWidth: true, required: required, sx: { background: 'white', borderRadius: '8px' }, size: size ?? 'medium', ...(additionalProps ?? {}) })) })));
47
47
  };
48
48
  export default DateTimePickerSelect;
@@ -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 { LocalDateTime, Month } from '@js-joda/core';
11
2
  import '@testing-library/jest-dom/extend-expect';
12
3
  import { render, screen, within } from '@testing-library/react';
@@ -42,39 +33,39 @@ beforeAll(() => {
42
33
  afterAll(() => {
43
34
  jest.useRealTimers();
44
35
  });
45
- test('returns selected date time', () => __awaiter(void 0, void 0, void 0, function* () {
36
+ test('returns selected date time', async () => {
46
37
  const user = userEvent.setup({ pointerEventsCheck: PointerEventsCheckLevel.Never });
47
38
  const onChangeMock = jest.fn((name, value, property) => { });
48
39
  render(React.createElement(DateTimePickerSelect, { id: "pickDateTime", property: dateTimeProperty, onChange: onChangeMock }));
49
40
  const calendarIcon = screen.getByRole('button', { name: /Choose date/i });
50
- yield user.click(calendarIcon);
51
- const calendar = yield screen.findByRole('dialog');
52
- const feb29 = yield within(calendar).findByRole('gridcell', { name: '29' });
53
- yield user.click(feb29);
41
+ await user.click(calendarIcon);
42
+ const calendar = await screen.findByRole('dialog');
43
+ const feb29 = await within(calendar).findByRole('gridcell', { name: '29' });
44
+ await user.click(feb29);
54
45
  // The test can't actually check that the correct time was picked due to issues
55
46
  // testing the time picker,
56
47
  // https://stackoverflow.com/questions/74812963/how-do-i-pick-the-time-in-an-mui-datetimepicker-using-testing-library-react-and.
57
48
  // All it can do is check the date picker part works.
58
49
  expect(onChangeMock).toBeCalledWith('testDateTime', LocalDateTime.of(2024, Month.FEBRUARY, 29, 0, 0, 0), dateTimeProperty);
59
- }), 10000);
60
- test('returns manually entered date time', () => __awaiter(void 0, void 0, void 0, function* () {
50
+ }, 10000);
51
+ test('returns manually entered date time', async () => {
61
52
  const user = userEvent.setup();
62
53
  const onChangeMock = jest.fn((name, value, property) => { });
63
54
  render(React.createElement(DateTimePickerSelect, { id: "pickDateTime", property: dateTimeProperty, onChange: onChangeMock }));
64
55
  const input = screen.getByRole('textbox');
65
- yield user.type(input, '03/27/2024 09:25 AM');
56
+ await user.type(input, '03/27/2024 09:25 AM');
66
57
  // component ignores '/', i.e. input could also have been '03272024'.
67
58
  // It also treats the AM as one event since one a user types 'A' or 'P'
68
59
  // the picker fills in the 'M'.
69
60
  expect(onChangeMock).toBeCalledTimes(13);
70
61
  expect(onChangeMock).lastCalledWith('testDateTime', LocalDateTime.of(2024, Month.MARCH, 27, 9, 25), dateTimeProperty);
71
- }));
72
- test('returns incomplete date times', () => __awaiter(void 0, void 0, void 0, function* () {
62
+ });
63
+ test('returns incomplete date times', async () => {
73
64
  const user = userEvent.setup();
74
65
  const onChangeMock = jest.fn((name, value, property) => { });
75
66
  render(React.createElement(DateTimePickerSelect, { id: "pickDateTime", property: dateTimeProperty, onChange: onChangeMock }));
76
67
  const input = screen.getByRole('textbox');
77
- yield user.type(input, '08/20');
68
+ await user.type(input, '08/20');
78
69
  // Component automatically appends '/' as needed.
79
70
  expect(onChangeMock).lastCalledWith('testDateTime', new InvalidDate('08/20/'), dateTimeProperty);
80
- }));
71
+ });
@@ -3,7 +3,6 @@ import React, { useCallback, useEffect, useState } from 'react';
3
3
  import { useDropzone } from 'react-dropzone';
4
4
  import { Button, TextField } from '../../../core';
5
5
  const FileUploadControl = (props) => {
6
- var _a;
7
6
  const [uploadedFile, setUploadedFile] = useState(undefined);
8
7
  const { id, property, required, error, errorMessage, additionalProps } = props;
9
8
  const styles = {
@@ -50,17 +49,17 @@ const FileUploadControl = (props) => {
50
49
  multiple: false,
51
50
  disabled: !!uploadedFile,
52
51
  });
53
- return (React.createElement(Grid, Object.assign({ container: true }, getRootProps({
54
- style: {
55
- border: error ? '1px solid red' : '1px solid #c4c4c4',
56
- borderRadius: '8px',
57
- height: '56px',
58
- },
59
- })),
52
+ return (React.createElement(Grid, { container: true, ...getRootProps({
53
+ style: {
54
+ border: error ? '1px solid red' : '1px solid #c4c4c4',
55
+ borderRadius: '8px',
56
+ height: '56px',
57
+ },
58
+ }) },
60
59
  React.createElement(Grid, { item: true, flexGrow: 1 },
61
- React.createElement("input", Object.assign({ disabled: true }, getInputProps())),
62
- React.createElement(TextField, Object.assign({ id: id, sx: { '& fieldset': { border: 'none' } }, fullWidth: true, value: (_a = uploadedFile === null || uploadedFile === void 0 ? void 0 : uploadedFile.name) !== null && _a !== void 0 ? _a : (isDragActive ? 'Drop your file here' : 'File'), error: error, errorMessage: errorMessage, required: required }, (additionalProps !== null && additionalProps !== void 0 ? additionalProps : {})))),
60
+ React.createElement("input", { disabled: true, ...getInputProps() }),
61
+ React.createElement(TextField, { id: id, sx: { '& fieldset': { border: 'none' } }, fullWidth: true, value: uploadedFile?.name ?? (isDragActive ? 'Drop your file here' : 'File'), error: error, errorMessage: errorMessage, required: required, ...(additionalProps ?? {}) })),
63
62
  React.createElement(Grid, { item: true },
64
- React.createElement(Button, { sx: Object.assign(Object.assign({}, styles.button), styles.selectFileBtn), onClick: () => handleSelectFile() }, uploadedFile ? 'Remove' : 'Select File'))));
63
+ React.createElement(Button, { sx: { ...styles.button, ...styles.selectFileBtn }, onClick: () => handleSelectFile() }, uploadedFile ? 'Remove' : 'Select File'))));
65
64
  };
66
65
  export default FileUploadControl;
@@ -11,7 +11,7 @@ const FormField = (props) => {
11
11
  const { id, defaultValue, error, onChange, property, readOnly, selectOptions, required, size, placeholder, errorMessage, onBlur, mask, max, min, isMultiLineText, rows, inputMaskPlaceholderChar, queryAddresses, isOptionEqualToValue, renderOption, disableCloseOnSelect, getOptionLabel, additionalProps, } = props;
12
12
  let control;
13
13
  const commonProps = {
14
- id: id !== null && id !== void 0 ? id : property.id,
14
+ id: id ?? property.id,
15
15
  property,
16
16
  onChange,
17
17
  onBlur,
@@ -32,33 +32,33 @@ const FormField = (props) => {
32
32
  additionalProps,
33
33
  };
34
34
  if (queryAddresses) {
35
- control = (React.createElement(AddressFieldComponent, Object.assign({}, commonProps, { mask: mask, inputMaskPlaceholderChar: inputMaskPlaceholderChar, isMultiLineText: isMultiLineText, rows: rows, queryAddresses: queryAddresses })));
35
+ control = (React.createElement(AddressFieldComponent, { ...commonProps, mask: mask, inputMaskPlaceholderChar: inputMaskPlaceholderChar, isMultiLineText: isMultiLineText, rows: rows, queryAddresses: queryAddresses }));
36
36
  return control;
37
37
  }
38
38
  switch (property.type) {
39
39
  case 'boolean':
40
- control = (React.createElement(BooleanSelect, Object.assign({}, commonProps, { defaultValue: defaultValue ? 'Yes' : defaultValue === undefined ? '' : 'No' })));
40
+ control = (React.createElement(BooleanSelect, { ...commonProps, defaultValue: defaultValue ? 'Yes' : defaultValue === undefined ? '' : 'No' }));
41
41
  break;
42
42
  case 'date':
43
- control = React.createElement(DatePickerSelect, Object.assign({}, commonProps));
43
+ control = React.createElement(DatePickerSelect, { ...commonProps });
44
44
  break;
45
45
  case 'date-time':
46
- control = React.createElement(DateTimePickerSelect, Object.assign({}, commonProps));
46
+ control = React.createElement(DateTimePickerSelect, { ...commonProps });
47
47
  break;
48
48
  case 'time':
49
- control = React.createElement(TimePickerSelect, Object.assign({}, commonProps));
49
+ control = React.createElement(TimePickerSelect, { ...commonProps });
50
50
  break;
51
51
  case 'fileUpload':
52
- control = React.createElement(FileUploadControl, Object.assign({}, commonProps));
52
+ control = React.createElement(FileUploadControl, { ...commonProps });
53
53
  break;
54
54
  case 'choices':
55
- control = React.createElement(Select, Object.assign({}, commonProps));
55
+ control = React.createElement(Select, { ...commonProps });
56
56
  break;
57
57
  case 'array':
58
- control = React.createElement(Select, Object.assign({}, commonProps));
58
+ control = React.createElement(Select, { ...commonProps });
59
59
  break;
60
60
  default:
61
- control = (React.createElement(InputFieldComponent, Object.assign({}, commonProps, { mask: mask, inputMaskPlaceholderChar: inputMaskPlaceholderChar, isMultiLineText: isMultiLineText, rows: rows })));
61
+ control = (React.createElement(InputFieldComponent, { ...commonProps, mask: mask, inputMaskPlaceholderChar: inputMaskPlaceholderChar, isMultiLineText: isMultiLineText, rows: rows }));
62
62
  break;
63
63
  }
64
64
  return control;
@@ -1,36 +1,24 @@
1
- var __rest = (this && this.__rest) || function (s, e) {
2
- var t = {};
3
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
- t[p] = s[p];
5
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
- t[p[i]] = s[p[i]];
9
- }
10
- return t;
11
- };
12
1
  import React, { useEffect, useState } from 'react';
13
2
  import InputMask from 'react-input-mask';
14
3
  import NumberFormat from 'react-number-format';
15
4
  import { Autocomplete, TextField } from '../../../core';
16
5
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
6
  export const NumericFormat = (props) => {
18
- const { inputRef, onChange, defaultValue } = props, other = __rest(props, ["inputRef", "onChange", "defaultValue"]);
19
- return (React.createElement(NumberFormat, Object.assign({}, other, { getInputRef: inputRef, onValueChange: (values) => {
20
- onChange === null || onChange === void 0 ? void 0 : onChange({
7
+ const { inputRef, onChange, defaultValue, ...other } = props;
8
+ return (React.createElement(NumberFormat, { ...other, getInputRef: inputRef, onValueChange: (values) => {
9
+ onChange?.({
21
10
  target: {
22
11
  value: values.floatValue,
23
12
  },
24
13
  });
25
- }, isNumericString: true, fixedDecimalScale: true, allowNegative: true })));
14
+ }, isNumericString: true, fixedDecimalScale: true, allowNegative: true }));
26
15
  };
27
16
  const InputFieldComponent = (props) => {
28
- var _a;
29
17
  const { id, property, defaultValue, error, errorMessage, onBlur, readOnly, required, size, placeholder, mask, min, max, isMultiLineText, rows, inputMaskPlaceholderChar, additionalProps, } = props;
30
- const [value, setValue] = useState(defaultValue !== null && defaultValue !== void 0 ? defaultValue : '');
18
+ const [value, setValue] = useState(defaultValue ?? '');
31
19
  const [inputValue, setInputValue] = useState('');
32
20
  useEffect(() => {
33
- setValue(defaultValue !== null && defaultValue !== void 0 ? defaultValue : '');
21
+ setValue(defaultValue ?? '');
34
22
  }, [defaultValue]);
35
23
  const handleChange = (e) => {
36
24
  const inputValue = property.type === 'integer' && /^-?\d+$/.test(e.target.value)
@@ -51,24 +39,28 @@ const InputFieldComponent = (props) => {
51
39
  : property.type === 'integer'
52
40
  ? { inputProps: { min, max } }
53
41
  : null;
54
- const selectOptions = (_a = property.enum) !== null && _a !== void 0 ? _a : [];
42
+ const selectOptions = property.enum ?? [];
55
43
  if (property.enum && !property.enum.includes(value)) {
56
44
  //note: this is different between widgets and builder
57
45
  //builder had select options being {label, value}
58
46
  //widgets had it like this, as strings w/isOptionEqualToValue
59
47
  selectOptions.push(value);
60
48
  }
61
- return property.enum && !readOnly ? (React.createElement(Autocomplete, Object.assign({ id: id, options: selectOptions, onChange: handleSelectChange, renderInput: (params) => (React.createElement(TextField, Object.assign({}, params, { value: value, error: error, errorMessage: errorMessage, fullWidth: true, onBlur: onBlur, size: size !== null && size !== void 0 ? size : 'medium', placeholder: placeholder }))), disableClearable: true, value: value, isOptionEqualToValue: (option, value) => {
49
+ return property.enum && !readOnly ? (React.createElement(Autocomplete, { id: id, options: selectOptions, onChange: handleSelectChange, renderInput: (params) => (React.createElement(TextField, { ...params, value: value, error: error, errorMessage: errorMessage, fullWidth: true, onBlur: onBlur, size: size ?? 'medium', placeholder: placeholder })), disableClearable: true, value: value, isOptionEqualToValue: (option, value) => {
62
50
  return option.value === value;
63
- }, error: error, required: required, inputValue: inputValue !== null && inputValue !== void 0 ? inputValue : '', onInputChange: handleInputValueChange }, (additionalProps !== null && additionalProps !== void 0 ? additionalProps : {})))) : !mask ? (React.createElement(TextField, Object.assign({ id: id, sx: Object.assign({ background: 'white', borderRadius: '8px' }, (readOnly && {
64
- '& .MuiOutlinedInput-notchedOutline': {
65
- border: 'none',
66
- },
67
- '.MuiOutlinedInput-root': {
68
- borderRadius: '8px',
69
- backgroundColor: '#f4f6f8',
70
- },
71
- })), error: error, errorMessage: errorMessage, value: value, onChange: !readOnly ? handleChange : undefined, InputProps: Object.assign(Object.assign({}, InputProps), { readOnly: readOnly }), required: required, fullWidth: true, onBlur: onBlur, placeholder: placeholder, size: size !== null && size !== void 0 ? size : 'medium', type: property.type === 'integer' ? 'number' : 'text', multiline: property.type === 'string' && !readOnly && isMultiLineText, rows: isMultiLineText ? (rows ? rows : 3) : undefined }, (additionalProps !== null && additionalProps !== void 0 ? additionalProps : {})))) : (React.createElement(InputMask, { mask: mask, maskChar: inputMaskPlaceholderChar !== null && inputMaskPlaceholderChar !== void 0 ? inputMaskPlaceholderChar : '_', value: value, onChange: !readOnly ? handleChange : undefined, onBlur: onBlur, alwaysShowMask: true }, () => (React.createElement(TextField, Object.assign({ id: id, sx: readOnly
51
+ }, error: error, required: required, inputValue: inputValue ?? '', onInputChange: handleInputValueChange, ...(additionalProps ?? {}) })) : !mask ? (React.createElement(TextField, { id: id, sx: {
52
+ background: 'white',
53
+ borderRadius: '8px',
54
+ ...(readOnly && {
55
+ '& .MuiOutlinedInput-notchedOutline': {
56
+ border: 'none',
57
+ },
58
+ '.MuiOutlinedInput-root': {
59
+ borderRadius: '8px',
60
+ backgroundColor: '#f4f6f8',
61
+ },
62
+ }),
63
+ }, error: error, errorMessage: errorMessage, value: value, onChange: !readOnly ? handleChange : undefined, InputProps: { ...InputProps, readOnly: readOnly }, required: required, fullWidth: true, onBlur: onBlur, placeholder: placeholder, size: size ?? 'medium', type: property.type === 'integer' ? 'number' : 'text', multiline: property.type === 'string' && !readOnly && isMultiLineText, rows: isMultiLineText ? (rows ? rows : 3) : undefined, ...(additionalProps ?? {}) })) : (React.createElement(InputMask, { mask: mask, maskChar: inputMaskPlaceholderChar ?? '_', value: value, onChange: !readOnly ? handleChange : undefined, onBlur: onBlur, alwaysShowMask: true }, () => (React.createElement(TextField, { id: id, sx: readOnly
72
64
  ? {
73
65
  '& .MuiOutlinedInput-notchedOutline': {
74
66
  border: 'none',
@@ -78,6 +70,6 @@ const InputFieldComponent = (props) => {
78
70
  backgroundColor: '#f4f6f8',
79
71
  },
80
72
  }
81
- : undefined, required: required, error: error, errorMessage: errorMessage, InputProps: Object.assign(Object.assign({}, InputProps), { readOnly: readOnly }), fullWidth: true, size: size !== null && size !== void 0 ? size : 'medium', type: property.type === 'integer' ? 'number' : 'text', multiline: property.type === 'string' && !readOnly && isMultiLineText, rows: isMultiLineText ? (rows ? rows : 3) : undefined }, (additionalProps !== null && additionalProps !== void 0 ? additionalProps : {}))))));
73
+ : undefined, required: required, error: error, errorMessage: errorMessage, InputProps: { ...InputProps, readOnly: readOnly }, fullWidth: true, size: size ?? 'medium', type: property.type === 'integer' ? 'number' : 'text', multiline: property.type === 'string' && !readOnly && isMultiLineText, rows: isMultiLineText ? (rows ? rows : 3) : undefined, ...(additionalProps ?? {}) }))));
82
74
  };
83
75
  export default InputFieldComponent;
@@ -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 '@testing-library/jest-dom/extend-expect';
11
2
  import { render, screen } from '@testing-library/react';
12
3
  import { userEvent } from '@testing-library/user-event';
@@ -20,15 +11,15 @@ describe('Free-text input', () => {
20
11
  name: 'Input Field',
21
12
  type: 'string',
22
13
  };
23
- test('returns entered value', () => __awaiter(void 0, void 0, void 0, function* () {
14
+ test('returns entered value', async () => {
24
15
  const user = userEvent.setup();
25
16
  const onChangeMock = jest.fn((name, value, property) => { });
26
17
  render(React.createElement(InputField, { id: "testInput", property: textProperty, onChange: onChangeMock }));
27
18
  const input = screen.getByRole('textbox');
28
- yield user.type(input, 'test value');
19
+ await user.type(input, 'test value');
29
20
  expect(onChangeMock).toBeCalledTimes(10);
30
21
  expect(onChangeMock).lastCalledWith('inputField', 'test value', textProperty);
31
- }));
22
+ });
32
23
  });
33
24
  describe('Autocomplete', () => {
34
25
  // Right now an object property is required for this to function, but eventually this should go
@@ -39,14 +30,14 @@ describe('Autocomplete', () => {
39
30
  type: 'string',
40
31
  enum: ['option 1', 'option 2'],
41
32
  };
42
- test('returns selected value', () => __awaiter(void 0, void 0, void 0, function* () {
33
+ test('returns selected value', async () => {
43
34
  const user = userEvent.setup();
44
35
  const onChangeMock = jest.fn((name, value, property) => { });
45
36
  render(React.createElement(InputField, { id: "testInput", property: enumProperty, onChange: onChangeMock }));
46
37
  const input = screen.getByRole('combobox');
47
- yield user.click(input);
48
- const option2 = yield screen.findByRole('option', { name: 'option 2' });
49
- yield user.click(option2);
38
+ await user.click(input);
39
+ const option2 = await screen.findByRole('option', { name: 'option 2' });
40
+ await user.click(option2);
50
41
  expect(onChangeMock).toBeCalledWith('enumField', 'option 2', enumProperty);
51
- }));
42
+ });
52
43
  });