@pega/react-sdk-overrides 0.23.26 → 8.8.20

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 (139) hide show
  1. package/lib/designSystemExtension/AlertBanner/AlertBanner.tsx +47 -0
  2. package/lib/designSystemExtension/AlertBanner/index.tsx +1 -0
  3. package/lib/designSystemExtension/Banner/Banner.tsx +12 -1
  4. package/lib/designSystemExtension/CaseSummaryFields/CaseSummaryFields.tsx +15 -10
  5. package/lib/designSystemExtension/DetailsFields/DetailsFields.tsx +10 -11
  6. package/lib/designSystemExtension/FieldGroup/FieldGroup.tsx +10 -3
  7. package/lib/designSystemExtension/FieldGroupList/FieldGroupList.tsx +11 -5
  8. package/lib/designSystemExtension/FieldValueList/FieldValueList.tsx +11 -3
  9. package/lib/designSystemExtension/Operator/Operator.tsx +30 -21
  10. package/lib/designSystemExtension/Pulse/Pulse.tsx +11 -7
  11. package/lib/designSystemExtension/RichTextEditor/RichTextEditor.tsx +121 -0
  12. package/lib/designSystemExtension/RichTextEditor/index.tsx +1 -0
  13. package/lib/designSystemExtension/WssQuickCreate/WssQuickCreate.tsx +12 -3
  14. package/lib/field/AutoComplete/AutoComplete.tsx +37 -18
  15. package/lib/field/CancelAlert/CancelAlert.tsx +21 -12
  16. package/lib/field/Checkbox/Checkbox.tsx +41 -17
  17. package/lib/field/Currency/Currency.tsx +23 -15
  18. package/lib/field/Currency/currency-utils.ts +1 -2
  19. package/lib/field/Date/Date.tsx +31 -17
  20. package/lib/field/DateTime/DateTime.tsx +26 -15
  21. package/lib/field/Decimal/Decimal.tsx +82 -19
  22. package/lib/field/Dropdown/Dropdown.tsx +57 -14
  23. package/lib/field/Email/Email.tsx +17 -9
  24. package/lib/field/Integer/Integer.tsx +15 -7
  25. package/lib/field/Percentage/Percentage.tsx +15 -7
  26. package/lib/field/Phone/Phone.tsx +21 -12
  27. package/lib/field/RadioButtons/RadioButtons.tsx +54 -27
  28. package/lib/field/RichText/RichText.tsx +93 -0
  29. package/lib/field/RichText/index.tsx +1 -0
  30. package/lib/field/ScalarList/ScalarList.tsx +64 -0
  31. package/lib/field/ScalarList/config-ext.json +8 -0
  32. package/lib/field/ScalarList/index.tsx +1 -0
  33. package/lib/field/SemanticLink/SemanticLink.tsx +26 -25
  34. package/lib/field/SemanticLink/utils.ts +2 -1
  35. package/lib/field/TextArea/TextArea.tsx +14 -5
  36. package/lib/field/TextContent/TextContent.tsx +10 -1
  37. package/lib/field/TextInput/TextInput.tsx +40 -11
  38. package/lib/field/Time/Time.tsx +29 -26
  39. package/lib/field/URL/URL.tsx +24 -8
  40. package/lib/field/UserReference/UserReference.tsx +52 -60
  41. package/lib/helpers/{attachmentHelpers.js → attachmentHelpers.ts} +5 -5
  42. package/lib/helpers/auth.js +741 -390
  43. package/lib/helpers/authManager.ts +933 -0
  44. package/lib/helpers/case-utils.tsx +103 -0
  45. package/lib/helpers/common-utils.ts +4 -0
  46. package/lib/helpers/config_access.js +63 -145
  47. package/lib/helpers/data_page.ts +2 -1
  48. package/lib/helpers/date-format-utils.ts +29 -19
  49. package/lib/helpers/{event-utils.js → event-utils.ts} +1 -1
  50. package/lib/helpers/{field-group-utils.js → field-group-utils.ts} +4 -3
  51. package/lib/helpers/formatters/{Currency.js → Currency.ts} +13 -12
  52. package/lib/helpers/formatters/{CurrencyMap.js → CurrencyMap.ts} +8 -5
  53. package/lib/helpers/formatters/{Date.js → Date.ts} +2 -2
  54. package/lib/helpers/formatters/{common.js → common.ts} +4 -4
  55. package/lib/helpers/formatters/{index.js → index.ts} +3 -3
  56. package/lib/helpers/simpleTableHelpers.ts +10 -6
  57. package/lib/helpers/state-utils.tsx +47 -0
  58. package/lib/helpers/template-utils.ts +3 -4
  59. package/lib/helpers/utils.ts +12 -4
  60. package/lib/helpers/versionHelpers.ts +0 -1
  61. package/lib/infra/ActionButtons/ActionButtons.tsx +13 -18
  62. package/lib/infra/Assignment/Assignment.tsx +38 -32
  63. package/lib/infra/AssignmentCard/AssignmentCard.tsx +15 -19
  64. package/lib/infra/Containers/FlowContainer/FlowContainer.tsx +76 -64
  65. package/lib/infra/Containers/FlowContainer/{helpers.js → helpers.ts} +18 -16
  66. package/lib/infra/Containers/ModalViewContainer/ModalViewContainer.tsx +41 -27
  67. package/lib/infra/Containers/ViewContainer/ViewContainer.tsx +19 -28
  68. package/lib/infra/DashboardFilter/DashboardFilter.tsx +16 -20
  69. package/lib/infra/DashboardFilter/filterUtils.tsx +3 -1
  70. package/lib/infra/DeferLoad/DeferLoad.tsx +16 -19
  71. package/lib/infra/ErrorBoundary/ErrorBoundary.tsx +20 -19
  72. package/lib/infra/MultiStep/MultiStep.tsx +24 -24
  73. package/lib/infra/NavBar/NavBar.tsx +23 -24
  74. package/lib/infra/Reference/Reference.tsx +13 -18
  75. package/lib/infra/Region/Region.tsx +8 -6
  76. package/lib/infra/RootContainer/RootContainer.tsx +32 -39
  77. package/lib/infra/Stages/Stages.tsx +15 -9
  78. package/lib/infra/VerticalTabs/LeftAlignVerticalTabs/LeftAlignVerticalTabs.tsx +8 -1
  79. package/lib/infra/VerticalTabs/VerticalTabs/VerticalTabs.tsx +12 -12
  80. package/lib/infra/View/View.tsx +28 -56
  81. package/lib/template/AppShell/AppShell.tsx +51 -34
  82. package/lib/template/BannerPage/BannerPage.tsx +26 -31
  83. package/lib/template/CaseSummary/CaseSummary.tsx +15 -8
  84. package/lib/template/CaseView/CaseView.tsx +137 -100
  85. package/lib/template/CaseViewActionsMenu/CaseViewActionsMenu.tsx +27 -27
  86. package/lib/template/Confirmation/Confirmation.tsx +29 -52
  87. package/lib/template/DataReference/DataReference.tsx +50 -52
  88. package/lib/template/DefaultForm/DefaultForm.tsx +29 -20
  89. package/lib/template/DefaultForm/utils/index.ts +33 -0
  90. package/lib/template/Details/Details/Details.tsx +16 -17
  91. package/lib/template/Details/DetailsSubTabs/DetailsSubTabs.tsx +13 -16
  92. package/lib/template/Details/DetailsThreeColumn/DetailsThreeColumn.tsx +19 -18
  93. package/lib/template/Details/DetailsTwoColumn/DetailsTwoColumn.tsx +20 -18
  94. package/lib/template/FieldGroupTemplate/FieldGroupTemplate.tsx +24 -27
  95. package/lib/template/InlineDashboard/InlineDashboard.tsx +11 -7
  96. package/lib/template/InlineDashboardPage/InlineDashboardPage.tsx +19 -17
  97. package/lib/template/ListPage/ListPage.tsx +14 -13
  98. package/lib/template/ListView/ListView.tsx +140 -152
  99. package/lib/template/ListView/{hooks.js → hooks.ts} +3 -1
  100. package/lib/template/ListView/{utils.js → utils.ts} +172 -23
  101. package/lib/template/MultiReferenceReadOnly/MultiReferenceReadOnly.tsx +12 -17
  102. package/lib/template/NarrowWide/NarrowWide/NarrowWide.tsx +16 -1
  103. package/lib/template/NarrowWide/NarrowWideDetails/NarrowWideDetails.tsx +19 -18
  104. package/lib/template/NarrowWide/NarrowWideForm/NarrowWideForm.tsx +9 -1
  105. package/lib/template/NarrowWide/NarrowWidePage/NarrowWidePage.tsx +17 -17
  106. package/lib/template/OneColumn/OneColumn/OneColumn.tsx +8 -7
  107. package/lib/template/OneColumn/OneColumnPage/OneColumnPage.tsx +10 -10
  108. package/lib/template/OneColumn/OneColumnTab/OneColumnTab.tsx +5 -7
  109. package/lib/template/PromotedFilters/PromotedFilters.tsx +23 -17
  110. package/lib/template/SimpleTable/SimpleTable/SimpleTable.tsx +103 -6
  111. package/lib/template/SimpleTable/SimpleTableManual/SimpleTableManual.tsx +28 -7
  112. package/lib/template/SimpleTable/SimpleTableSelect/SimpleTableSelect.tsx +26 -31
  113. package/lib/template/SingleReferenceReadOnly/SingleReferenceReadOnly.tsx +34 -36
  114. package/lib/template/SubTabs/SubTabs.tsx +10 -11
  115. package/lib/template/SubTabs/tabUtils.ts +0 -2
  116. package/lib/template/TwoColumn/TwoColumn/TwoColumn.tsx +10 -15
  117. package/lib/template/TwoColumn/TwoColumnPage/TwoColumnPage.tsx +10 -10
  118. package/lib/template/TwoColumn/TwoColumnTab/TwoColumnTab.tsx +10 -12
  119. package/lib/template/WideNarrow/WideNarrow/WideNarrow.tsx +17 -3
  120. package/lib/template/WideNarrow/WideNarrowDetails/WideNarrowDetails.tsx +35 -25
  121. package/lib/template/WideNarrow/WideNarrowForm/WideNarrowForm.tsx +7 -1
  122. package/lib/template/WideNarrow/WideNarrowPage/WideNarrowPage.tsx +15 -17
  123. package/lib/template/WssNavBar/WssNavBar.tsx +20 -3
  124. package/lib/widget/AppAnnouncement/AppAnnouncement.tsx +13 -21
  125. package/lib/widget/Attachment/Attachment.css +15 -3
  126. package/lib/widget/Attachment/Attachment.tsx +51 -32
  127. package/lib/widget/CaseHistory/CaseHistory.tsx +13 -11
  128. package/lib/widget/FileUtility/ActionButtonsForFileUtil/ActionButtonsForFileUtil.tsx +13 -1
  129. package/lib/widget/FileUtility/FileUtility/FileUtility.tsx +40 -26
  130. package/lib/widget/Followers/Followers.tsx +10 -11
  131. package/lib/widget/QuickCreate/QuickCreate.tsx +15 -6
  132. package/lib/widget/SummaryItem/SummaryItem.tsx +12 -4
  133. package/lib/widget/SummaryList/SummaryList.tsx +17 -3
  134. package/lib/widget/ToDo/ToDo.tsx +69 -104
  135. package/package.json +1 -1
  136. package/lib/helpers/authManager.js +0 -631
  137. /package/lib/helpers/formatters/{Boolean.js → Boolean.ts} +0 -0
  138. /package/lib/helpers/{reactContextHelpers.js → reactContextHelpers.ts} +0 -0
  139. /package/lib/template/ListView/{DefaultViewMeta.js → DefaultViewMeta.ts} +0 -0
@@ -1,30 +1,30 @@
1
1
  import React, { useEffect, useState } from 'react';
2
2
  import { TextField } from '@material-ui/core';
3
3
  import Autocomplete from '@material-ui/lab/Autocomplete';
4
- import Utils from '@pega/react-sdk-components/lib/components/helpers/utils';
5
- import TextInput from '@pega/react-sdk-components/lib/components/field/TextInput';
6
4
  import isDeepEqual from 'fast-deep-equal/react';
5
+ import Utils from '@pega/react-sdk-components/lib/components/helpers/utils';
7
6
  import { getDataPage } from '@pega/react-sdk-components/lib/components/helpers/data_page';
8
7
  import handleEvent from '@pega/react-sdk-components/lib/components/helpers/event-utils';
9
- import FieldValueList from '@pega/react-sdk-components/lib/components/designSystemExtension/FieldValueList';
8
+ import { getComponentFromMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
9
+ import type { PConnFieldProps } from '@pega/react-sdk-components/lib/types/PConnProps';
10
10
 
11
11
  interface IOption {
12
12
  key: string;
13
13
  value: string;
14
14
  }
15
15
 
16
- const preProcessColumns = columnList => {
17
- return columnList.map(col => {
16
+ const preProcessColumns = (columnList) => {
17
+ return columnList.map((col) => {
18
18
  const tempColObj = { ...col };
19
19
  tempColObj.value = col.value && col.value.startsWith('.') ? col.value.substring(1) : col.value;
20
20
  return tempColObj;
21
21
  });
22
22
  };
23
23
 
24
- const getDisplayFieldsMetaData = columnList => {
25
- const displayColumns = columnList.filter(col => col.display === 'true');
24
+ const getDisplayFieldsMetaData = (columnList) => {
25
+ const displayColumns = columnList.filter((col) => col.display === 'true');
26
26
  const metaDataObj: any = { key: '', primary: '', secondary: [] };
27
- const keyCol = columnList.filter(col => col.key === 'true');
27
+ const keyCol = columnList.filter((col) => col.key === 'true');
28
28
  metaDataObj.key = keyCol.length > 0 ? keyCol[0].value : 'auto';
29
29
  for (let index = 0; index < displayColumns.length; index += 1) {
30
30
  if (displayColumns[index].primary === 'true') {
@@ -36,7 +36,25 @@ const getDisplayFieldsMetaData = columnList => {
36
36
  return metaDataObj;
37
37
  };
38
38
 
39
- export default function AutoComplete(props) {
39
+ interface AutoCompleteProps extends PConnFieldProps {
40
+ // If any, enter additional props that only exist on AutoComplete here'
41
+ displayMode?: string;
42
+ deferDatasource?: boolean;
43
+ datasourceMetadata?: any;
44
+ status?: string;
45
+ onRecordChange?: any;
46
+ additionalProps?: object;
47
+ listType: string;
48
+ parameters?: any;
49
+ datasource: any;
50
+ columns: Array<any>;
51
+ }
52
+
53
+ export default function AutoComplete(props: AutoCompleteProps) {
54
+ // Get emitted components from map (so we can get any override that may exist)
55
+ const TextInput = getComponentFromMap('TextInput');
56
+ const FieldValueList = getComponentFromMap('FieldValueList');
57
+
40
58
  const {
41
59
  getPConnect,
42
60
  label,
@@ -54,6 +72,7 @@ export default function AutoComplete(props) {
54
72
  hideLabel,
55
73
  onRecordChange
56
74
  } = props;
75
+
57
76
  const context = getPConnect().getContextName();
58
77
  let { listType, parameters, datasource = [], columns = [] } = props;
59
78
  const [inputValue, setInputValue] = useState('');
@@ -73,7 +92,7 @@ export default function AutoComplete(props) {
73
92
 
74
93
  const flattenParameters = (params = {}) => {
75
94
  const flatParams = {};
76
- Object.keys(params).forEach(key => {
95
+ Object.keys(params).forEach((key) => {
77
96
  const { name, value: theVal } = params[key];
78
97
  flatParams[name] = theVal;
79
98
  });
@@ -111,7 +130,7 @@ export default function AutoComplete(props) {
111
130
 
112
131
  useEffect(() => {
113
132
  if (listType === 'associated') {
114
- setOptions(Utils.getOptionList(props, getPConnect().getDataObject()));
133
+ setOptions(Utils.getOptionList(props, getPConnect().getDataObject(context)));
115
134
  }
116
135
  }, [theDatasource]);
117
136
 
@@ -120,7 +139,7 @@ export default function AutoComplete(props) {
120
139
  getDataPage(datasource, parameters, context).then((results: any) => {
121
140
  const optionsData: Array<any> = [];
122
141
  const displayColumn = getDisplayFieldsMetaData(columns);
123
- results?.forEach(element => {
142
+ results?.forEach((element) => {
124
143
  const val = element[displayColumn.primary]?.toString();
125
144
  const obj = {
126
145
  key: element[displayColumn.key] || element.pyGUID,
@@ -138,11 +157,11 @@ export default function AutoComplete(props) {
138
157
  }
139
158
 
140
159
  if (displayMode === 'STACKED_LARGE_VAL') {
141
- return <FieldValueList name={hideLabel ? '' : label} value={value} variant='stacked' />;
160
+ return <FieldValueList name={hideLabel ? '' : label} value={value} variant="stacked" />;
142
161
  }
143
162
 
144
163
  if (value) {
145
- const index = options?.findIndex(element => element.key === value);
164
+ const index = options?.findIndex((element) => element.key === value);
146
165
  if (index > -1) {
147
166
  selectedValue = options[index].value;
148
167
  } else {
@@ -163,7 +182,7 @@ export default function AutoComplete(props) {
163
182
  };
164
183
 
165
184
  if (readOnly) {
166
- const theValAsString = options?.find(opt => opt.key === value)?.value;
185
+ const theValAsString = options?.find((opt) => opt.key === value)?.value;
167
186
  return <TextInput {...props} value={theValAsString} />;
168
187
  }
169
188
  // Need to use both getOptionLabel and getOptionSelected to map our
@@ -182,14 +201,14 @@ export default function AutoComplete(props) {
182
201
  value={selectedValue}
183
202
  inputValue={inputValue || selectedValue}
184
203
  onInputChange={handleInputValue}
185
- renderInput={params => (
204
+ renderInput={(params) => (
186
205
  <TextField
187
206
  {...params}
188
207
  fullWidth
189
- variant='outlined'
208
+ variant="outlined"
190
209
  helperText={helperTextToDisplay}
191
210
  placeholder={placeholder}
192
- size='small'
211
+ size="small"
193
212
  required={required}
194
213
  error={status === 'error'}
195
214
  label={label}
@@ -1,12 +1,21 @@
1
1
  import React, { useState } from 'react';
2
2
  import { Button, Grid, IconButton, Snackbar } from '@material-ui/core';
3
3
  import CloseIcon from '@material-ui/icons/Close';
4
-
4
+ import type { PConnFieldProps } from '@pega/react-sdk-components/lib/types/PConnProps';
5
5
  import './CancelAlert.css';
6
6
 
7
- declare const PCore;
7
+ // Remove this and use "real" PCore type once .d.ts is fixed (currently shows 2 errors)
8
+ declare const PCore: any;
9
+
10
+
11
+ interface CancelAlertProps extends PConnFieldProps {
12
+ // If any, enter additional props that only exist on CancelAlert here
13
+ pConn: any,
14
+ updateAlertState: any
15
+ }
8
16
 
9
- const CancelAlert = props => {
17
+
18
+ export default function CancelAlert(props: CancelAlertProps) {
10
19
  const { pConn, updateAlertState } = props;
11
20
  const [showSnackbar, setShowSnackbar] = useState(false);
12
21
  const [snackbarMessage, setSnackbarMessage] = useState('');
@@ -15,6 +24,8 @@ const CancelAlert = props => {
15
24
  const caseInfo = pConn.getCaseInfo();
16
25
  const caseName = caseInfo.getName();
17
26
  const ID = caseInfo.getID();
27
+ const localizedVal = PCore.getLocaleUtils().getLocaleValue;
28
+ const localeCategory = 'ModalContainer';
18
29
 
19
30
  function showToast(message: string) {
20
31
  setSnackbarMessage(message);
@@ -53,7 +64,7 @@ const CancelAlert = props => {
53
64
  );
54
65
  })
55
66
  .catch(() => {
56
- showToast('Save failed');
67
+ showToast(localizedVal('Save failed', localeCategory));
57
68
  });
58
69
  break;
59
70
 
@@ -71,7 +82,7 @@ const CancelAlert = props => {
71
82
  PCore.getPubSubUtils().publish(PCore.getConstants().PUB_SUB_EVENTS.EVENT_CANCEL);
72
83
  })
73
84
  .catch(() => {
74
- showToast('Delete failed.');
85
+ showToast(localizedVal('Delete failed.', localeCategory));
75
86
  });
76
87
  break;
77
88
 
@@ -86,22 +97,22 @@ const CancelAlert = props => {
86
97
  <div className='cancel-alert-top'>
87
98
  <h3>{`Delete ${caseName}(${ID})`}</h3>
88
99
  <div>
89
- <p>{`Are you sure you want to delete ${caseName} (${ID})?`}</p>
90
- <p>Alternatively, you can continue working or save your work for later.</p>
100
+ <p>{`${localizedVal('Are you sure you want to delete', localeCategory)} ${caseName} (${ID})?`}</p>
101
+ <p>{localizedVal('Alternatively, you can continue working or save your work for later.', localeCategory)}</p>
91
102
  </div>
92
103
  <div className='action-controls'>
93
104
  <Grid container spacing={4} justifyContent='space-between'>
94
105
  <Grid item>
95
106
  <Button variant='outlined' color='primary' onClick={() => buttonClick('save')}>
96
- Save for later
107
+ {localizedVal('Save for later', localeCategory)}
97
108
  </Button>
98
109
  </Grid>
99
110
  <Grid item>
100
111
  <Button variant='outlined' color='primary' onClick={() => buttonClick('continue')}>
101
- Continue Working
112
+ {localizedVal('Continue Working', localeCategory)}
102
113
  </Button>
103
114
  <Button variant='contained' color='primary' onClick={() => buttonClick('delete')}>
104
- Delete
115
+ {localizedVal('Delete', localeCategory)}
105
116
  </Button>
106
117
  </Grid>
107
118
  </Grid>
@@ -122,5 +133,3 @@ const CancelAlert = props => {
122
133
  </>
123
134
  );
124
135
  };
125
-
126
- export default CancelAlert;
@@ -1,15 +1,38 @@
1
1
  import React, { useState, useEffect } from 'react';
2
- import {
3
- Checkbox,
4
- FormControl,
5
- FormControlLabel,
6
- FormGroup,
7
- FormHelperText
8
- } from '@material-ui/core';
2
+ import { Checkbox, FormControl, FormControlLabel, FormGroup, FormHelperText } from '@material-ui/core';
9
3
  import handleEvent from '@pega/react-sdk-components/lib/components/helpers/event-utils';
10
- import FieldValueList from '@pega/react-sdk-components/lib/components/designSystemExtension/FieldValueList';
4
+ import type { PConnProps } from '@pega/react-sdk-components/lib/types/PConnProps';
5
+ import { getComponentFromMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
6
+
7
+ // Checkbox passes in 'value' as a boolean. So can't use the default
8
+ // PConnFieldProps since it expects value to be a string.
9
+ interface CheckboxProps extends PConnProps {
10
+ // If any, enter additional props that only exist on Checkbox here
11
+ // Everything from PConnFieldProps except value and change type of value to boolean
12
+
13
+ value?: boolean;
14
+ label: string;
15
+ required: boolean;
16
+ disabled: boolean;
17
+ validatemessage: string;
18
+ status?: string;
19
+ // eslint-disable-next-line react/no-unused-prop-types
20
+ onChange: any;
21
+ // eslint-disable-next-line react/no-unused-prop-types
22
+ onBlur?: any;
23
+ readOnly: boolean;
24
+ testId: string;
25
+ helperText: string;
26
+ displayMode?: string;
27
+ hideLabel: boolean;
28
+ // eslint-disable-next-line react/no-unused-prop-types
29
+ placeholder?: string;
30
+ }
31
+
32
+ export default function CheckboxComponent(props: CheckboxProps) {
33
+ // Get emitted components from map (so we can get any override that may exist)
34
+ const FieldValueList = getComponentFromMap('FieldValueList');
11
35
 
12
- export default function CheckboxComponent(props) {
13
36
  const {
14
37
  getPConnect,
15
38
  label,
@@ -17,6 +40,7 @@ export default function CheckboxComponent(props) {
17
40
  readOnly,
18
41
  testId,
19
42
  required,
43
+ disabled,
20
44
  status,
21
45
  helperText,
22
46
  validatemessage,
@@ -38,27 +62,27 @@ export default function CheckboxComponent(props) {
38
62
  }, [value]);
39
63
 
40
64
  if (displayMode === 'LABELS_LEFT') {
41
- return <FieldValueList name={hideLabel ? '' : label} value={value} />;
65
+ return <FieldValueList name={hideLabel ? '' : label} value={value.toString()} />;
42
66
  }
43
67
 
44
68
  if (displayMode === 'STACKED_LARGE_VAL') {
45
- return <FieldValueList name={hideLabel ? '' : label} value={value} variant='stacked' />;
69
+ return <FieldValueList name={hideLabel ? '' : label} value={value.toString()} variant="stacked" />;
46
70
  }
47
71
 
48
- const handleChange = event => {
72
+ const handleChange = (event) => {
49
73
  handleEvent(actionsApi, 'changeNblur', propName, event.target.checked);
50
74
  };
51
75
 
52
- const handleBlur = event => {
53
- thePConn.getValidationApi().validate(event.target.checked);
76
+ const handleBlur = (event) => {
77
+ thePConn.getValidationApi().validate(event.target.checked, ''); // 2nd arg empty string until typedef marked correctly as optional
54
78
  };
55
79
 
56
- let theCheckbox = <Checkbox color='primary' />;
80
+ let theCheckbox = <Checkbox color="primary" disabled={disabled} />;
57
81
 
58
82
  if (readOnly) {
59
83
  // Workaround for lack of InputProps readOnly from https://github.com/mui-org/material-ui/issues/17043
60
84
  // Also note that we need to turn off the onChange call in the FormControlLabel wrapper, too. See below!
61
- theCheckbox = <Checkbox value={value || false} onChange={handleChange} readOnly={readOnly} />;
85
+ theCheckbox = <Checkbox value={value || false} readOnly={readOnly} />;
62
86
  }
63
87
 
64
88
  return (
@@ -70,7 +94,7 @@ export default function CheckboxComponent(props) {
70
94
  onChange={!readOnly ? handleChange : undefined}
71
95
  onBlur={!readOnly ? handleBlur : undefined}
72
96
  label={caption}
73
- labelPlacement='end'
97
+ labelPlacement="end"
74
98
  data-test-id={testId}
75
99
  />
76
100
  </FormGroup>
@@ -1,14 +1,22 @@
1
1
  import React, { useState, useEffect } from 'react';
2
- // import { TextField } from "@material-ui/core";
3
2
  import CurrencyTextField from '@unicef/material-ui-currency-textfield';
4
3
  import handleEvent from '@pega/react-sdk-components/lib/components/helpers/event-utils';
5
- import FieldValueList from '@pega/react-sdk-components/lib/components/designSystemExtension/FieldValueList';
6
- import { format } from "@pega/react-sdk-components/lib/components/helpers/formatters";
4
+ import { format } from '@pega/react-sdk-components/lib/components/helpers/formatters';
7
5
  import { getCurrencyCharacters, getCurrencyOptions } from './currency-utils';
6
+ import { getComponentFromMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
7
+ import type { PConnFieldProps } from '@pega/react-sdk-components/lib/types/PConnProps';
8
8
 
9
9
  // Using control from: https://github.com/unicef/material-ui-currency-textfield
10
10
 
11
- export default function Currency(props) {
11
+ interface CurrrencyProps extends PConnFieldProps {
12
+ // If any, enter additional props that only exist on Currency here
13
+ currencyISOCode?: string;
14
+ }
15
+
16
+ export default function Currency(props: CurrrencyProps) {
17
+ // Get emitted components from map (so we can get any override that may exist)
18
+ const FieldValueList = getComponentFromMap('FieldValueList');
19
+
12
20
  const {
13
21
  getPConnect,
14
22
  label,
@@ -23,7 +31,7 @@ export default function Currency(props) {
23
31
  helperText,
24
32
  displayMode,
25
33
  hideLabel,
26
- currencyISOCode = "USD"
34
+ currencyISOCode = 'USD'
27
35
  } = props;
28
36
 
29
37
  const pConn = getPConnect();
@@ -45,10 +53,10 @@ export default function Currency(props) {
45
53
  'data-test-id': testId
46
54
  };
47
55
 
48
- const [currValue, setCurrValue] = useState();
49
- const [theCurrSym, setCurrSym] = useState("$");
50
- const [theCurrDec, setCurrDec] = useState(".");
51
- const [theCurrSep, setCurrSep] = useState(",");
56
+ const [currValue, setCurrValue] = useState('');
57
+ const [theCurrSym, setCurrSym] = useState('$');
58
+ const [theCurrDec, setCurrDec] = useState('.');
59
+ const [theCurrSep, setCurrSep] = useState(',');
52
60
 
53
61
  useEffect(() => {
54
62
  // currencySymbols looks like this: { theCurrencySymbol: '$', theDecimalIndicator: '.', theSeparator: ',' }
@@ -71,7 +79,7 @@ export default function Currency(props) {
71
79
  }
72
80
 
73
81
  if (displayMode === 'STACKED_LARGE_VAL') {
74
- return <FieldValueList name={hideLabel ? '' : label} value={formattedValue} variant='stacked' />;
82
+ return <FieldValueList name={hideLabel ? '' : label} value={formattedValue} variant="stacked" />;
75
83
  }
76
84
 
77
85
  // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
@@ -94,8 +102,8 @@ export default function Currency(props) {
94
102
  fullWidth
95
103
  variant={readOnly ? 'standard' : 'outlined'}
96
104
  helperText={helperTextToDisplay}
97
- placeholder=''
98
- size='small'
105
+ placeholder=""
106
+ size="small"
99
107
  required={required}
100
108
  disabled={disabled}
101
109
  onChange={currOnChange}
@@ -103,9 +111,9 @@ export default function Currency(props) {
103
111
  error={status === 'error'}
104
112
  label={label}
105
113
  value={currValue}
106
- type='text'
107
- outputFormat='number'
108
- textAlign='left'
114
+ type="text"
115
+ outputFormat="number"
116
+ textAlign="left"
109
117
  InputProps={{ ...readOnlyProp, inputProps: { ...testProp, value: currValue } }}
110
118
  currencySymbol={theCurrSym}
111
119
  decimalCharacter={theCurrDec}
@@ -3,11 +3,10 @@ import { default as CurrencyAlias} from '@pega/react-sdk-components/lib/componen
3
3
  // eslint-disable-next-line import/no-named-default
4
4
  import { default as CurrencyMapAlias } from '@pega/react-sdk-components/lib/components/helpers/formatters/CurrencyMap';
5
5
 
6
- declare const PCore: any;
7
6
 
8
7
  export const getCurrencyOptions = (inISOCode: string) => {
9
8
 
10
- const operatorLocale = PCore.getEnvironmentInfo().getUseLocale() || 'en-US';
9
+ const operatorLocale = PCore.getEnvironmentInfo().getUseLocale() || PCore.getEnvironmentInfo().getLocale() || 'en-US';
11
10
 
12
11
  let currMapToUse = CurrencyMapAlias.US;
13
12
  let localeToUse = operatorLocale;
@@ -1,12 +1,25 @@
1
1
  import React from 'react';
2
2
  import { KeyboardDatePicker } from '@material-ui/pickers';
3
- import TextInput from '@pega/react-sdk-components/lib/components/field/TextInput';
4
3
  import handleEvent from '@pega/react-sdk-components/lib/components/helpers/event-utils';
5
- import FieldValueList from '@pega/react-sdk-components/lib/components/designSystemExtension/FieldValueList';
6
- import { format } from '@pega/react-sdk-components/lib/components/helpers/formatters/';
7
- import { dateFormatInfoDefault, getDateFormatInfo} from '@pega/react-sdk-components/lib/components/helpers/date-format-utils';
4
+ import { format } from '@pega/react-sdk-components/lib/components/helpers/formatters';
5
+ import { dateFormatInfoDefault, getDateFormatInfo } from '@pega/react-sdk-components/lib/components/helpers/date-format-utils';
6
+ import { getComponentFromMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
7
+ import type { PConnFieldProps } from '@pega/react-sdk-components/lib/types/PConnProps';
8
+
9
+ // Will return the date string in YYYY-MM-DD format which we'll be POSTing to the server
10
+ function getFormattedDate(date) {
11
+ return `${date.$y.toString()}-${(date.$M + 1).toString().padStart(2, '0')}-${date.$D.toString().padStart(2, '0')}`;
12
+ }
13
+
14
+ interface DateProps extends PConnFieldProps {
15
+ // If any, enter additional props that only exist on Date here
16
+ }
17
+
18
+ export default function Date(props: DateProps) {
19
+ // Get emitted components from map (so we can get any override that may exist)
20
+ const TextInput = getComponentFromMap('TextInput');
21
+ const FieldValueList = getComponentFromMap('FieldValueList');
8
22
 
9
- export default function Date(props) {
10
23
  const {
11
24
  getPConnect,
12
25
  label,
@@ -32,12 +45,11 @@ export default function Date(props) {
32
45
  // Start with default dateFormatInfo
33
46
  const dateFormatInfo = dateFormatInfoDefault;
34
47
  // and then update, as needed, based on locale, etc.
35
- const theDateFormat = getDateFormatInfo()
48
+ const theDateFormat = getDateFormatInfo();
36
49
  dateFormatInfo.dateFormatString = theDateFormat.dateFormatString;
37
50
  dateFormatInfo.dateFormatStringLC = theDateFormat.dateFormatStringLC;
38
51
  dateFormatInfo.dateFormatMask = theDateFormat.dateFormatMask;
39
52
 
40
-
41
53
  if (displayMode === 'LABELS_LEFT') {
42
54
  const formattedDate = format(props.value, 'date', { format: dateFormatInfo.dateFormatString });
43
55
  return <FieldValueList name={hideLabel ? '' : label} value={formattedDate} />;
@@ -45,7 +57,7 @@ export default function Date(props) {
45
57
 
46
58
  if (displayMode === 'STACKED_LARGE_VAL') {
47
59
  const formattedDate = format(props.value, 'date', { format: dateFormatInfo.dateFormatString });
48
- return <FieldValueList name={hideLabel ? '' : label} value={formattedDate} variant='stacked' />;
60
+ return <FieldValueList name={hideLabel ? '' : label} value={formattedDate} variant="stacked" />;
49
61
  }
50
62
 
51
63
  if (readOnly) {
@@ -59,21 +71,23 @@ export default function Date(props) {
59
71
  'data-test-id': testId
60
72
  };
61
73
 
62
- const handleChange = date => {
63
- const changeValue = date && date.isValid() ? date.toISOString() : null;
64
- onChange({ value: changeValue });
74
+ const handleChange = (date) => {
75
+ if (date && date.isValid()) {
76
+ onChange({ value: getFormattedDate(date) });
77
+ }
65
78
  };
66
79
 
67
- const handleAccept = date => {
68
- const changeValue = date && date.isValid() ? date.toISOString() : null;
69
- handleEvent(actions, 'changeNblur', propName, changeValue);
80
+ const handleAccept = (date) => {
81
+ if (date && date.isValid()) {
82
+ handleEvent(actions, 'changeNblur', propName, getFormattedDate(date));
83
+ }
70
84
  };
71
85
 
72
86
  return (
73
87
  <KeyboardDatePicker
74
88
  disableToolbar
75
- variant='inline'
76
- inputVariant='outlined'
89
+ variant="inline"
90
+ inputVariant="outlined"
77
91
  placeholder={dateFormatInfo.dateFormatStringLC}
78
92
  format={dateFormatInfo.dateFormatString}
79
93
  mask={dateFormatInfo.dateFormatMask}
@@ -83,7 +97,7 @@ export default function Date(props) {
83
97
  disabled={disabled}
84
98
  error={status === 'error'}
85
99
  helperText={helperTextToDisplay}
86
- size='small'
100
+ size="small"
87
101
  label={label}
88
102
  value={value || null}
89
103
  onChange={handleChange}
@@ -1,12 +1,20 @@
1
1
  import React from 'react';
2
2
  import { KeyboardDateTimePicker } from '@material-ui/pickers';
3
- import TextInput from '@pega/react-sdk-components/lib/components/field/TextInput';
4
3
  import handleEvent from '@pega/react-sdk-components/lib/components/helpers/event-utils';
5
- import FieldValueList from '@pega/react-sdk-components/lib/components/designSystemExtension/FieldValueList';
6
- import { format } from '@pega/react-sdk-components/lib/components/helpers/formatters/';
7
- import { dateFormatInfoDefault, getDateFormatInfo} from '@pega/react-sdk-components/lib/components/helpers/date-format-utils';
4
+ import { format } from '@pega/react-sdk-components/lib/components/helpers/formatters';
5
+ import { dateFormatInfoDefault, getDateFormatInfo } from '@pega/react-sdk-components/lib/components/helpers/date-format-utils';
6
+ import { getComponentFromMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
7
+ import type { PConnFieldProps } from '@pega/react-sdk-components/lib/types/PConnProps';
8
+
9
+ interface DateTimeProps extends PConnFieldProps {
10
+ // If any, enter additional props that only exist on DateTime here
11
+ }
12
+
13
+ export default function DateTime(props: DateTimeProps) {
14
+ // Get emitted components from map (so we can get any override that may exist)
15
+ const TextInput = getComponentFromMap('TextInput');
16
+ const FieldValueList = getComponentFromMap('FieldValueList');
8
17
 
9
- export default function DateTime(props) {
10
18
  const {
11
19
  getPConnect,
12
20
  label,
@@ -31,20 +39,23 @@ export default function DateTime(props) {
31
39
  // Start with default dateFormatInfo
32
40
  const dateFormatInfo = dateFormatInfoDefault;
33
41
  // and then update, as needed, based on locale, etc.
34
- const theDateFormat = getDateFormatInfo()
42
+ const theDateFormat = getDateFormatInfo();
35
43
  dateFormatInfo.dateFormatString = theDateFormat.dateFormatString;
36
44
  dateFormatInfo.dateFormatStringLC = theDateFormat.dateFormatStringLC;
37
45
  dateFormatInfo.dateFormatMask = theDateFormat.dateFormatMask;
38
46
 
39
-
40
47
  if (displayMode === 'LABELS_LEFT') {
41
- const formattedDateTime = format(props.value, 'datetime', { format: `${dateFormatInfo.dateFormatString} hh:mm a` });
48
+ const formattedDateTime = format(props.value, 'datetime', {
49
+ format: `${dateFormatInfo.dateFormatString} hh:mm a`
50
+ });
42
51
  return <FieldValueList name={hideLabel ? '' : label} value={formattedDateTime} />;
43
52
  }
44
53
 
45
54
  if (displayMode === 'STACKED_LARGE_VAL') {
46
- const formattedDateTime = format(props.value, 'datetime', { format: `${dateFormatInfo.dateFormatString} hh:mm a` });
47
- return <FieldValueList name={hideLabel ? '' : label} value={formattedDateTime} variant='stacked' />;
55
+ const formattedDateTime = format(props.value, 'datetime', {
56
+ format: `${dateFormatInfo.dateFormatString} hh:mm a`
57
+ });
58
+ return <FieldValueList name={hideLabel ? '' : label} value={formattedDateTime} variant="stacked" />;
48
59
  }
49
60
 
50
61
  if (readOnly) {
@@ -52,12 +63,12 @@ export default function DateTime(props) {
52
63
  return <TextInput {...props} value={formattedDateTime} />;
53
64
  }
54
65
 
55
- const handleChange = date => {
66
+ const handleChange = (date) => {
56
67
  const changeValue = date && date.isValid() ? date.toISOString() : null;
57
68
  onChange({ value: changeValue });
58
69
  };
59
70
 
60
- const handleAccept = date => {
71
+ const handleAccept = (date) => {
61
72
  const changeValue = date && date.isValid() ? date.toISOString() : null;
62
73
  handleEvent(actions, 'changeNblur', propName, changeValue);
63
74
  };
@@ -69,8 +80,8 @@ export default function DateTime(props) {
69
80
 
70
81
  return (
71
82
  <KeyboardDateTimePicker
72
- variant='inline'
73
- inputVariant='outlined'
83
+ variant="inline"
84
+ inputVariant="outlined"
74
85
  fullWidth
75
86
  autoOk
76
87
  required={required}
@@ -81,7 +92,7 @@ export default function DateTime(props) {
81
92
  minutesStep={5}
82
93
  error={status === 'error'}
83
94
  helperText={helperTextToDisplay}
84
- size='small'
95
+ size="small"
85
96
  label={label}
86
97
  value={value || null}
87
98
  onChange={handleChange}