@pega/react-sdk-overrides 23.1.10 → 23.1.12

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 (232) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +17 -0
  3. package/SECURITY.md +10 -0
  4. package/lib/designSystemExtension/AlertBanner/AlertBanner.tsx +6 -14
  5. package/lib/designSystemExtension/Banner/Banner.tsx +14 -11
  6. package/lib/designSystemExtension/CaseSummaryFields/CaseSummaryFields.css +0 -1
  7. package/lib/designSystemExtension/CaseSummaryFields/CaseSummaryFields.tsx +27 -22
  8. package/lib/designSystemExtension/DetailsFields/DetailsFields.tsx +14 -20
  9. package/lib/designSystemExtension/DetailsFields/index.tsx +1 -1
  10. package/lib/designSystemExtension/FieldGroup/FieldGroup.tsx +44 -19
  11. package/lib/designSystemExtension/FieldGroupList/FieldGroupList.tsx +7 -12
  12. package/lib/designSystemExtension/FieldValueList/FieldValueList.tsx +21 -32
  13. package/lib/designSystemExtension/Operator/Operator.tsx +94 -82
  14. package/lib/designSystemExtension/Pulse/Pulse.tsx +14 -16
  15. package/lib/designSystemExtension/RichTextEditor/RichTextEditor.tsx +6 -5
  16. package/lib/designSystemExtension/WssQuickCreate/WssQuickCreate.tsx +14 -14
  17. package/lib/field/AutoComplete/AutoComplete.tsx +24 -26
  18. package/lib/field/AutoComplete/config-ext.json +2 -3
  19. package/lib/field/CancelAlert/CancelAlert.tsx +98 -84
  20. package/lib/field/CancelAlert/index.tsx +1 -1
  21. package/lib/field/Checkbox/Checkbox.tsx +120 -63
  22. package/lib/field/Checkbox/config-ext.json +2 -3
  23. package/lib/field/Currency/Currency.tsx +25 -50
  24. package/lib/field/Currency/config-ext.json +2 -3
  25. package/lib/field/Currency/currency-utils.ts +9 -16
  26. package/lib/field/Date/Date.tsx +15 -11
  27. package/lib/field/Date/config-ext.json +2 -3
  28. package/lib/field/DateTime/DateTime.tsx +9 -9
  29. package/lib/field/DateTime/config-ext.json +1 -2
  30. package/lib/field/Decimal/Decimal.tsx +33 -44
  31. package/lib/field/Decimal/config-ext.json +1 -2
  32. package/lib/field/Decimal/index.tsx +1 -1
  33. package/lib/field/Dropdown/Dropdown.tsx +122 -31
  34. package/lib/field/Dropdown/config-ext.json +1 -2
  35. package/lib/field/Email/Email.tsx +11 -10
  36. package/lib/field/Email/config-ext.json +1 -2
  37. package/lib/field/Email/index.tsx +1 -1
  38. package/lib/field/Group/Group.tsx +39 -0
  39. package/lib/field/Group/config-ext.json +7 -0
  40. package/lib/field/Group/index.tsx +1 -0
  41. package/lib/field/Integer/Integer.tsx +8 -7
  42. package/lib/field/Integer/config-ext.json +1 -2
  43. package/lib/field/MultiSelect/Multiselect.tsx +244 -0
  44. package/lib/field/MultiSelect/index.tsx +1 -0
  45. package/lib/field/MultiSelect/utils.ts +230 -0
  46. package/lib/field/Percentage/Percentage.tsx +46 -41
  47. package/lib/field/Percentage/config-ext.json +1 -2
  48. package/lib/field/Phone/Phone.tsx +13 -12
  49. package/lib/field/Phone/index.tsx +1 -1
  50. package/lib/field/RadioButtons/RadioButtons.tsx +20 -18
  51. package/lib/field/RadioButtons/config-ext.json +1 -2
  52. package/lib/field/RichText/RichText.tsx +8 -7
  53. package/lib/field/ScalarList/ScalarList.tsx +3 -13
  54. package/lib/field/ScalarList/config-ext.json +1 -2
  55. package/lib/field/SemanticLink/SemanticLink.tsx +7 -7
  56. package/lib/field/SemanticLink/config-ext.json +1 -2
  57. package/lib/field/SemanticLink/utils.ts +8 -11
  58. package/lib/field/TextArea/TextArea.tsx +7 -6
  59. package/lib/field/TextArea/config-ext.json +1 -2
  60. package/lib/field/TextContent/TextContent.tsx +4 -6
  61. package/lib/field/TextContent/config-ext.json +1 -2
  62. package/lib/field/TextInput/TextInput.tsx +9 -7
  63. package/lib/field/TextInput/config-ext.json +1 -2
  64. package/lib/field/TextInput/index.tsx +1 -1
  65. package/lib/field/Time/Time.tsx +11 -11
  66. package/lib/field/Time/config-ext.json +1 -2
  67. package/lib/field/URL/URL.tsx +9 -8
  68. package/lib/field/URL/config-ext.json +1 -2
  69. package/lib/field/URL/index.tsx +1 -1
  70. package/lib/field/UserReference/UserReference.tsx +18 -16
  71. package/lib/field/UserReference/UserReferenceUtils.ts +2 -2
  72. package/lib/field/UserReference/config-ext.json +1 -2
  73. package/lib/helpers/attachmentHelpers.ts +13 -8
  74. package/lib/helpers/case-utils.tsx +4 -8
  75. package/lib/helpers/common-utils.ts +5 -1
  76. package/lib/helpers/data_page.ts +3 -7
  77. package/lib/helpers/date-format-utils.ts +3 -3
  78. package/lib/helpers/event-utils.ts +3 -3
  79. package/lib/helpers/field-group-utils.ts +1 -1
  80. package/lib/helpers/formatters/Boolean.ts +9 -26
  81. package/lib/helpers/formatters/Currency.ts +15 -21
  82. package/lib/helpers/formatters/CurrencyMap.ts +505 -501
  83. package/lib/helpers/formatters/Date.ts +20 -26
  84. package/lib/helpers/formatters/common.ts +1 -2
  85. package/lib/helpers/formatters/index.ts +26 -19
  86. package/lib/helpers/instructions-utils.ts +38 -0
  87. package/lib/helpers/reactContextHelpers.ts +2 -2
  88. package/lib/helpers/simpleTableHelpers.ts +59 -83
  89. package/lib/helpers/state-utils.tsx +5 -9
  90. package/lib/helpers/template-utils.ts +3 -6
  91. package/lib/helpers/utils.ts +5 -5
  92. package/lib/helpers/versionHelpers.ts +1 -4
  93. package/lib/infra/ActionButtons/ActionButtons.tsx +38 -29
  94. package/lib/infra/ActionButtons/index.tsx +1 -1
  95. package/lib/infra/Assignment/Assignment.tsx +99 -79
  96. package/lib/infra/Assignment/index.tsx +1 -1
  97. package/lib/infra/AssignmentCard/AssignmentCard.tsx +13 -16
  98. package/lib/infra/AssignmentCard/index.tsx +1 -1
  99. package/lib/infra/Containers/FlowContainer/FlowContainer.tsx +67 -213
  100. package/lib/infra/Containers/FlowContainer/helpers.ts +34 -45
  101. package/lib/infra/Containers/FlowContainer/index.tsx +1 -1
  102. package/lib/infra/Containers/ModalViewContainer/ListViewActionButtons/ListViewActionButtons.tsx +65 -0
  103. package/lib/infra/Containers/ModalViewContainer/ListViewActionButtons/index.tsx +1 -0
  104. package/lib/infra/Containers/ModalViewContainer/ModalViewContainer.tsx +227 -218
  105. package/lib/infra/Containers/ModalViewContainer/index.tsx +1 -1
  106. package/lib/infra/Containers/SimpleView/SimpleView.tsx +48 -0
  107. package/lib/infra/Containers/SimpleView/helper.ts +125 -0
  108. package/lib/infra/Containers/SimpleView/index.tsx +1 -0
  109. package/lib/infra/Containers/ViewContainer/ViewContainer.tsx +36 -46
  110. package/lib/infra/Containers/helpers.ts +6 -0
  111. package/lib/infra/DashboardFilter/DashboardFilter.tsx +21 -42
  112. package/lib/infra/DashboardFilter/filterUtils.tsx +12 -43
  113. package/lib/infra/DeferLoad/DeferLoad.tsx +22 -28
  114. package/lib/infra/DeferLoad/index.tsx +1 -1
  115. package/lib/infra/ErrorBoundary/ErrorBoundary.tsx +16 -30
  116. package/lib/infra/MultiStep/MultiStep.css +11 -15
  117. package/lib/infra/MultiStep/MultiStep.tsx +176 -212
  118. package/lib/infra/MultiStep/index.tsx +1 -1
  119. package/lib/infra/NavBar/NavBar.css +103 -105
  120. package/lib/infra/NavBar/NavBar.tsx +19 -31
  121. package/lib/infra/Reference/Reference.tsx +16 -18
  122. package/lib/infra/Region/Region.tsx +4 -6
  123. package/lib/infra/RootContainer/RootContainer.tsx +75 -111
  124. package/lib/infra/RootContainer/index.tsx +1 -1
  125. package/lib/infra/Stages/Stages.tsx +32 -39
  126. package/lib/infra/VerticalTabs/LeftAlignVerticalTabs/LeftAlignVerticalTabs.tsx +11 -11
  127. package/lib/infra/VerticalTabs/VerticalTabs/VerticalTabs.tsx +21 -28
  128. package/lib/infra/View/View.tsx +17 -21
  129. package/lib/template/AppShell/AppShell.css +22 -23
  130. package/lib/template/AppShell/AppShell.tsx +39 -74
  131. package/lib/template/BannerPage/BannerPage.tsx +12 -14
  132. package/lib/template/CaseSummary/CaseSummary.tsx +58 -18
  133. package/lib/template/CaseSummary/config-ext.json +1 -2
  134. package/lib/template/CaseView/CaseView.tsx +34 -63
  135. package/lib/template/CaseView/config-ext.json +1 -2
  136. package/lib/template/CaseViewActionsMenu/CaseViewActionsMenu.tsx +63 -19
  137. package/lib/template/Confirmation/Confirmation.tsx +12 -17
  138. package/lib/template/Confirmation/config-ext.json +1 -2
  139. package/lib/template/DataReference/DataReference.tsx +95 -121
  140. package/lib/template/DataReference/config-ext.json +1 -2
  141. package/lib/template/DefaultForm/DefaultForm.css +7 -3
  142. package/lib/template/DefaultForm/DefaultForm.tsx +13 -16
  143. package/lib/template/DefaultForm/config-ext.json +1 -2
  144. package/lib/template/Details/Details/Details.tsx +19 -22
  145. package/lib/template/Details/DetailsSubTabs/DetailsSubTabs.tsx +9 -13
  146. package/lib/template/Details/DetailsSubTabs/config-ext.json +1 -2
  147. package/lib/template/Details/DetailsThreeColumn/DetailsThreeColumn.tsx +19 -24
  148. package/lib/template/Details/DetailsThreeColumn/config-ext.json +1 -2
  149. package/lib/template/Details/DetailsTwoColumn/DetailsTwoColumn.tsx +19 -25
  150. package/lib/template/Details/DetailsTwoColumn/config-ext.json +1 -2
  151. package/lib/template/Details/DetailsTwoColumn/index.tsx +1 -1
  152. package/lib/template/Details/DynamicTabs/DynamicTabs.tsx +15 -14
  153. package/lib/template/FieldGroupTemplate/FieldGroupTemplate.tsx +15 -22
  154. package/lib/template/InlineDashboard/InlineDashboard.tsx +12 -14
  155. package/lib/template/InlineDashboardPage/InlineDashboardPage.tsx +12 -16
  156. package/lib/template/ListPage/ListPage.tsx +5 -10
  157. package/lib/template/ListPage/config-ext.json +1 -2
  158. package/lib/template/ListView/DefaultViewMeta.ts +1 -3
  159. package/lib/template/ListView/ListView.tsx +185 -175
  160. package/lib/template/ListView/config-ext.json +1 -2
  161. package/lib/template/ListView/hooks.ts +24 -26
  162. package/lib/template/ListView/utils.ts +51 -87
  163. package/lib/template/MultiReferenceReadOnly/MultiReferenceReadOnly.tsx +20 -20
  164. package/lib/template/NarrowWide/NarrowWide/NarrowWide.css +0 -2
  165. package/lib/template/NarrowWide/NarrowWide/NarrowWide.tsx +25 -38
  166. package/lib/template/NarrowWide/NarrowWideDetails/NarrowWideDetails.tsx +20 -25
  167. package/lib/template/NarrowWide/NarrowWideDetails/config-ext.json +1 -2
  168. package/lib/template/NarrowWide/NarrowWideForm/NarrowWideForm.css +0 -2
  169. package/lib/template/NarrowWide/NarrowWideForm/NarrowWideForm.tsx +14 -24
  170. package/lib/template/NarrowWide/NarrowWideForm/config-ext.json +1 -2
  171. package/lib/template/NarrowWide/NarrowWidePage/NarrowWidePage.tsx +9 -19
  172. package/lib/template/NarrowWide/NarrowWidePage/config-ext.json +1 -2
  173. package/lib/template/OneColumn/OneColumn/OneColumn.tsx +14 -15
  174. package/lib/template/OneColumn/OneColumn/config-ext.json +1 -2
  175. package/lib/template/OneColumn/OneColumnPage/OneColumnPage.tsx +3 -10
  176. package/lib/template/OneColumn/OneColumnPage/config-ext.json +1 -2
  177. package/lib/template/OneColumn/OneColumnTab/OneColumnTab.tsx +6 -10
  178. package/lib/template/OneColumn/OneColumnTab/config-ext.json +1 -2
  179. package/lib/template/PromotedFilters/PromotedFilters.css +1 -1
  180. package/lib/template/PromotedFilters/PromotedFilters.tsx +32 -28
  181. package/lib/template/SimpleTable/SimpleTable/SimpleTable.tsx +37 -33
  182. package/lib/template/SimpleTable/SimpleTable/config-ext.json +1 -2
  183. package/lib/template/SimpleTable/SimpleTableManual/SimpleTableManual.tsx +187 -121
  184. package/lib/template/SimpleTable/SimpleTableSelect/SimpleTableSelect.tsx +24 -25
  185. package/lib/template/SingleReferenceReadOnly/SingleReferenceReadOnly.tsx +30 -30
  186. package/lib/template/SubTabs/SubTabs.tsx +22 -40
  187. package/lib/template/SubTabs/config-ext.json +1 -2
  188. package/lib/template/SubTabs/tabUtils.ts +2 -5
  189. package/lib/template/TwoColumn/TwoColumn/TwoColumn.css +0 -1
  190. package/lib/template/TwoColumn/TwoColumn/TwoColumn.tsx +30 -28
  191. package/lib/template/TwoColumn/TwoColumn/config-ext.json +1 -2
  192. package/lib/template/TwoColumn/TwoColumnPage/TwoColumnPage.tsx +3 -10
  193. package/lib/template/TwoColumn/TwoColumnPage/config-ext.json +1 -2
  194. package/lib/template/TwoColumn/TwoColumnTab/TwoColumnTab.tsx +30 -28
  195. package/lib/template/TwoColumn/TwoColumnTab/config-ext.json +1 -2
  196. package/lib/template/WideNarrow/WideNarrow/WideNarrow.css +0 -2
  197. package/lib/template/WideNarrow/WideNarrow/WideNarrow.tsx +22 -34
  198. package/lib/template/WideNarrow/WideNarrowDetails/WideNarrowDetails.tsx +24 -28
  199. package/lib/template/WideNarrow/WideNarrowDetails/config-ext.json +1 -2
  200. package/lib/template/WideNarrow/WideNarrowForm/WideNarrowForm.css +0 -2
  201. package/lib/template/WideNarrow/WideNarrowForm/WideNarrowForm.tsx +13 -21
  202. package/lib/template/WideNarrow/WideNarrowForm/config-ext.json +1 -2
  203. package/lib/template/WideNarrow/WideNarrowPage/WideNarrowPage.tsx +8 -16
  204. package/lib/template/WideNarrow/WideNarrowPage/config-ext.json +1 -2
  205. package/lib/template/WideNarrow/WideNarrowPage/index.tsx +1 -1
  206. package/lib/template/WssNavBar/WssNavBar.tsx +18 -21
  207. package/lib/widget/AppAnnouncement/AppAnnouncement.tsx +29 -28
  208. package/lib/widget/AppAnnouncement/config-ext.json +1 -2
  209. package/lib/widget/Attachment/Attachment.css +60 -1
  210. package/lib/widget/Attachment/Attachment.tsx +378 -405
  211. package/lib/widget/Attachment/index.tsx +1 -1
  212. package/lib/widget/CaseHistory/CaseHistory.tsx +64 -66
  213. package/lib/widget/CaseHistory/config-ext.json +1 -2
  214. package/lib/widget/CaseHistory/index.tsx +1 -1
  215. package/lib/widget/FileUtility/ActionButtonsForFileUtil/ActionButtonsForFileUtil.tsx +16 -18
  216. package/lib/widget/FileUtility/FileUtility/FileUtility.css +2 -2
  217. package/lib/widget/FileUtility/FileUtility/FileUtility.tsx +310 -246
  218. package/lib/widget/FileUtility/FileUtility/config-ext.json +1 -2
  219. package/lib/widget/Followers/Followers.tsx +23 -20
  220. package/lib/widget/Followers/config-ext.json +1 -2
  221. package/lib/widget/QuickCreate/QuickCreate.tsx +68 -42
  222. package/lib/widget/SummaryItem/SummaryItem.css +9 -9
  223. package/lib/widget/SummaryItem/SummaryItem.tsx +58 -58
  224. package/lib/widget/SummaryItem/index.tsx +1 -1
  225. package/lib/widget/SummaryList/SummaryList.tsx +7 -10
  226. package/lib/widget/ToDo/ToDo.css +4 -4
  227. package/lib/widget/ToDo/ToDo.tsx +52 -53
  228. package/lib/widget/ToDo/config-ext.json +1 -2
  229. package/package.json +5 -2
  230. package/lib/helpers/auth.js +0 -834
  231. package/lib/helpers/authManager.ts +0 -933
  232. package/lib/helpers/config_access.js +0 -186
@@ -1,30 +1,31 @@
1
- import React, { useEffect, useState } from 'react';
1
+ import { useEffect, useState } from 'react';
2
2
  import { TextField } from '@material-ui/core';
3
3
  import Autocomplete from '@material-ui/lab/Autocomplete';
4
4
  import isDeepEqual from 'fast-deep-equal/react';
5
+
5
6
  import Utils from '@pega/react-sdk-components/lib/components/helpers/utils';
6
7
  import { getDataPage } from '@pega/react-sdk-components/lib/components/helpers/data_page';
7
8
  import handleEvent from '@pega/react-sdk-components/lib/components/helpers/event-utils';
8
9
  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
+ import { PConnFieldProps } from '@pega/react-sdk-components/lib/types/PConnProps';
10
11
 
11
12
  interface IOption {
12
13
  key: string;
13
14
  value: string;
14
15
  }
15
16
 
16
- const preProcessColumns = (columnList) => {
17
- return columnList.map((col) => {
17
+ const preProcessColumns = columnList => {
18
+ return columnList.map(col => {
18
19
  const tempColObj = { ...col };
19
20
  tempColObj.value = col.value && col.value.startsWith('.') ? col.value.substring(1) : col.value;
20
21
  return tempColObj;
21
22
  });
22
23
  };
23
24
 
24
- const getDisplayFieldsMetaData = (columnList) => {
25
- const displayColumns = columnList.filter((col) => col.display === 'true');
25
+ const getDisplayFieldsMetaData = columnList => {
26
+ const displayColumns = columnList.filter(col => col.display === 'true');
26
27
  const metaDataObj: any = { key: '', primary: '', secondary: [] };
27
- const keyCol = columnList.filter((col) => col.key === 'true');
28
+ const keyCol = columnList.filter(col => col.key === 'true');
28
29
  metaDataObj.key = keyCol.length > 0 ? keyCol[0].value : 'auto';
29
30
  for (let index = 0; index < displayColumns.length; index += 1) {
30
31
  if (displayColumns[index].primary === 'true') {
@@ -47,7 +48,7 @@ interface AutoCompleteProps extends PConnFieldProps {
47
48
  listType: string;
48
49
  parameters?: any;
49
50
  datasource: any;
50
- columns: Array<any>;
51
+ columns: any[];
51
52
  }
52
53
 
53
54
  export default function AutoComplete(props: AutoCompleteProps) {
@@ -76,14 +77,14 @@ export default function AutoComplete(props: AutoCompleteProps) {
76
77
  const context = getPConnect().getContextName();
77
78
  let { listType, parameters, datasource = [], columns = [] } = props;
78
79
  const [inputValue, setInputValue] = useState('');
79
- const [options, setOptions] = useState<Array<IOption>>([]);
80
+ const [options, setOptions] = useState<IOption[]>([]);
80
81
  const [theDatasource, setDatasource] = useState(null);
81
82
  let selectedValue: any = '';
82
83
  const helperTextToDisplay = validatemessage || helperText;
83
84
 
84
85
  const thePConn = getPConnect();
85
86
  const actionsApi = thePConn.getActionsApi();
86
- const propName = thePConn.getStateProps()["value"];
87
+ const propName = (thePConn.getStateProps() as any).value;
87
88
 
88
89
  if (!isDeepEqual(datasource, theDatasource)) {
89
90
  // inbound datasource is different, so update theDatasource (to trigger useEffect)
@@ -92,7 +93,7 @@ export default function AutoComplete(props: AutoCompleteProps) {
92
93
 
93
94
  const flattenParameters = (params = {}) => {
94
95
  const flatParams = {};
95
- Object.keys(params).forEach((key) => {
96
+ Object.keys(params).forEach(key => {
96
97
  const { name, value: theVal } = params[key];
97
98
  flatParams[name] = theVal;
98
99
  });
@@ -105,13 +106,10 @@ export default function AutoComplete(props: AutoCompleteProps) {
105
106
  if (deferDatasource && datasourceMetadata?.datasource?.name) {
106
107
  listType = 'datapage';
107
108
  datasource = datasourceMetadata.datasource.name;
108
- parameters = flattenParameters(datasourceMetadata?.datasource?.parameters);
109
- const displayProp = datasourceMetadata.datasource.propertyForDisplayText.startsWith('@P')
110
- ? datasourceMetadata.datasource.propertyForDisplayText.substring(3)
111
- : datasourceMetadata.datasource.propertyForDisplayText;
112
- const valueProp = datasourceMetadata.datasource.propertyForValue.startsWith('@P')
113
- ? datasourceMetadata.datasource.propertyForValue.substring(3)
114
- : datasourceMetadata.datasource.propertyForValue;
109
+ const { parameters: dataSourceParameters, propertyForDisplayText, propertyForValue } = datasourceMetadata.datasource;
110
+ parameters = flattenParameters(dataSourceParameters);
111
+ const displayProp = propertyForDisplayText.startsWith('@P') ? propertyForDisplayText.substring(3) : propertyForDisplayText;
112
+ const valueProp = propertyForValue.startsWith('@P') ? propertyForValue.substring(3) : propertyForValue;
115
113
  columns = [
116
114
  {
117
115
  key: 'true',
@@ -137,9 +135,9 @@ export default function AutoComplete(props: AutoCompleteProps) {
137
135
  useEffect(() => {
138
136
  if (!displayMode && listType !== 'associated') {
139
137
  getDataPage(datasource, parameters, context).then((results: any) => {
140
- const optionsData: Array<any> = [];
138
+ const optionsData: any[] = [];
141
139
  const displayColumn = getDisplayFieldsMetaData(columns);
142
- results?.forEach((element) => {
140
+ results?.forEach(element => {
143
141
  const val = element[displayColumn.primary]?.toString();
144
142
  const obj = {
145
143
  key: element[displayColumn.key] || element.pyGUID,
@@ -157,11 +155,11 @@ export default function AutoComplete(props: AutoCompleteProps) {
157
155
  }
158
156
 
159
157
  if (displayMode === 'STACKED_LARGE_VAL') {
160
- return <FieldValueList name={hideLabel ? '' : label} value={value} variant="stacked" />;
158
+ return <FieldValueList name={hideLabel ? '' : label} value={value} variant='stacked' />;
161
159
  }
162
160
 
163
161
  if (value) {
164
- const index = options?.findIndex((element) => element.key === value);
162
+ const index = options?.findIndex(element => element.key === value);
165
163
  if (index > -1) {
166
164
  selectedValue = options[index].value;
167
165
  } else {
@@ -182,7 +180,7 @@ export default function AutoComplete(props: AutoCompleteProps) {
182
180
  };
183
181
 
184
182
  if (readOnly) {
185
- const theValAsString = options?.find((opt) => opt.key === value)?.value;
183
+ const theValAsString = options?.find(opt => opt.key === value)?.value;
186
184
  return <TextInput {...props} value={theValAsString} />;
187
185
  }
188
186
  // Need to use both getOptionLabel and getOptionSelected to map our
@@ -201,14 +199,14 @@ export default function AutoComplete(props: AutoCompleteProps) {
201
199
  value={selectedValue}
202
200
  inputValue={inputValue || selectedValue}
203
201
  onInputChange={handleInputValue}
204
- renderInput={(params) => (
202
+ renderInput={params => (
205
203
  <TextField
206
204
  {...params}
207
205
  fullWidth
208
- variant="outlined"
206
+ variant='outlined'
209
207
  helperText={helperTextToDisplay}
210
208
  placeholder={placeholder}
211
- size="small"
209
+ size='small'
212
210
  required={required}
213
211
  error={status === 'error'}
214
212
  label={label}
@@ -4,8 +4,7 @@
4
4
  "description": "Picklist",
5
5
  "type": "Field",
6
6
  "subtype": "Picklist",
7
- "componentKey" : "AutoComplete",
7
+ "componentKey": "AutoComplete",
8
8
  "icon": "",
9
- "properties": [
10
- ]
9
+ "properties": []
11
10
  }
@@ -1,44 +1,91 @@
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
- import type { PConnFieldProps } from '@pega/react-sdk-components/lib/types/PConnProps';
5
- import './CancelAlert.css';
6
-
7
- // Remove this and use "real" PCore type once .d.ts is fixed (currently shows 2 errors)
8
- declare const PCore: any;
9
4
 
5
+ import { PConnFieldProps } from '@pega/react-sdk-components/lib/types/PConnProps';
6
+ import './CancelAlert.css';
10
7
 
11
8
  interface CancelAlertProps extends PConnFieldProps {
12
9
  // If any, enter additional props that only exist on CancelAlert here
13
- pConn: any,
14
- updateAlertState: any
10
+ heading: string;
11
+ content: string;
12
+ itemKey: string;
13
+ hideDelete: boolean;
14
+ isDataObject: boolean;
15
+ skipReleaseLockRequest: any;
16
+ dismiss: Function;
15
17
  }
16
18
 
17
-
18
19
  export default function CancelAlert(props: CancelAlertProps) {
19
- const { pConn, updateAlertState } = props;
20
- const [showSnackbar, setShowSnackbar] = useState(false);
21
- const [snackbarMessage, setSnackbarMessage] = useState('');
22
-
23
- const itemKey = pConn.getContextName();
24
- const caseInfo = pConn.getCaseInfo();
25
- const caseName = caseInfo.getName();
26
- const ID = caseInfo.getID();
20
+ const { heading, content, getPConnect, itemKey: containerItemID, hideDelete, isDataObject, skipReleaseLockRequest, dismiss } = props;
21
+ const actionsAPI = getPConnect().getActionsApi();
22
+ const containerManagerAPI = getPConnect().getContainerManager();
23
+ const isLocalAction = getPConnect().getValue(PCore.getConstants().CASE_INFO.IS_LOCAL_ACTION);
24
+ const isBulkAction = getPConnect()?.options?.isBulkAction;
27
25
  const localizedVal = PCore.getLocaleUtils().getLocaleValue;
26
+ const broadCastUtils: any = PCore.getCoexistenceManager().getBroadcastUtils();
27
+ const isReverseCoexistence = broadCastUtils.isReverseCoexistenceCaseLoaded();
28
28
  const localeCategory = 'ModalContainer';
29
+ const btnIds = {
30
+ SAVE_AND_CLOSE: 'saveAndClose',
31
+ CONTINUE_WORKING: 'continueWorking',
32
+ DELETE: 'delete'
33
+ };
29
34
 
30
- function showToast(message: string) {
31
- setSnackbarMessage(message);
32
- setShowSnackbar(true);
35
+ const [buttonsState, setButtonsState] = useState({
36
+ [btnIds.SAVE_AND_CLOSE]: false,
37
+ [btnIds.DELETE]: false
38
+ });
39
+
40
+ const [showSnackbar, setShowSnackbar] = useState(false);
41
+ const [snackbarMessage, setSnackbarMessage] = useState('');
42
+
43
+ function disableButton(id) {
44
+ setButtonsState(prevState => ({
45
+ ...prevState,
46
+ [id]: true
47
+ }));
33
48
  }
34
49
 
35
- const dismissCancelAlertOnly = () => {
36
- updateAlertState(true);
37
- };
50
+ function enableButton(id) {
51
+ setButtonsState(prevState => ({
52
+ ...prevState,
53
+ [id]: false
54
+ }));
55
+ }
38
56
 
39
- const dismissModal = () => {
40
- updateAlertState(false);
41
- };
57
+ function cancelHandler() {
58
+ if (isReverseCoexistence) {
59
+ dismiss(true);
60
+ // @ts-ignore - An argument for 'payload' was not provided.
61
+ PCore.getPubSubUtils().publish(PCore.getConstants().PUB_SUB_EVENTS.REVERSE_COEXISTENCE_EVENTS.HANDLE_DISCARD);
62
+ } else if (!isDataObject && !isLocalAction && !isBulkAction) {
63
+ disableButton(btnIds.DELETE);
64
+ actionsAPI
65
+ .deleteCaseInCreateStage(containerItemID, hideDelete)
66
+ .then(() => {
67
+ // @ts-ignore - An argument for 'payload' was not provided.
68
+ PCore.getPubSubUtils().publish(PCore.getConstants().PUB_SUB_EVENTS.EVENT_CANCEL);
69
+ })
70
+ .catch(() => {
71
+ setSnackbarMessage(localizedVal('Delete failed.', localeCategory));
72
+ setShowSnackbar(true);
73
+ })
74
+ .finally(() => {
75
+ enableButton(btnIds.DELETE);
76
+ dismiss(true);
77
+ });
78
+ } else if (isLocalAction) {
79
+ dismiss(true);
80
+ actionsAPI.cancelAssignment(containerItemID);
81
+ } else if (isBulkAction) {
82
+ dismiss(true);
83
+ actionsAPI.cancelBulkAction(containerItemID);
84
+ } else {
85
+ dismiss(true);
86
+ containerManagerAPI.removeContainerItem({ containerItemID, skipReleaseLockRequest });
87
+ }
88
+ }
42
89
 
43
90
  function handleSnackbarClose(event: React.SyntheticEvent | React.MouseEvent, reason?: string) {
44
91
  if (reason === 'clickaway') {
@@ -47,74 +94,41 @@ export default function CancelAlert(props: CancelAlertProps) {
47
94
  setShowSnackbar(false);
48
95
  }
49
96
 
50
- const buttonClick = action => {
51
- const actionsAPI = pConn.getActionsApi();
52
-
53
- switch (action) {
54
- case 'save':
55
- // eslint-disable-next-line no-case-declarations
56
- const savePromise = actionsAPI.saveAndClose(itemKey);
57
-
58
- savePromise
59
- .then(() => {
60
- dismissModal();
61
-
62
- PCore.getPubSubUtils().publish(
63
- PCore.getConstants().PUB_SUB_EVENTS.CASE_EVENTS.CASE_CREATED
64
- );
65
- })
66
- .catch(() => {
67
- showToast(localizedVal('Save failed', localeCategory));
68
- });
69
- break;
70
-
71
- case 'continue':
72
- dismissCancelAlertOnly();
73
- break;
74
-
75
- case 'delete':
76
- // eslint-disable-next-line no-case-declarations
77
- const deletePromise = actionsAPI.deleteCaseInCreateStage(itemKey);
78
-
79
- deletePromise
80
- .then(() => {
81
- dismissModal();
82
- PCore.getPubSubUtils().publish(PCore.getConstants().PUB_SUB_EVENTS.EVENT_CANCEL);
83
- })
84
- .catch(() => {
85
- showToast(localizedVal('Delete failed.', localeCategory));
86
- });
87
- break;
97
+ const leftButton = (
98
+ <Button
99
+ name={btnIds.CONTINUE_WORKING}
100
+ variant='contained'
101
+ color='secondary'
102
+ onClick={() => {
103
+ dismiss();
104
+ if (isReverseCoexistence) {
105
+ broadCastUtils.setCallBackFunction(null);
106
+ broadCastUtils.setIsDirtyDialogActive(false);
107
+ }
108
+ }}
109
+ >
110
+ {localizedVal('Go back', localeCategory)}
111
+ </Button>
112
+ );
88
113
 
89
- default:
90
- break;
91
- }
92
- };
114
+ const rightButton = (
115
+ <Button name={btnIds.DELETE} variant='contained' color='primary' disabled={buttonsState[btnIds.DELETE]} onClick={cancelHandler}>
116
+ {localizedVal('Discard', localeCategory)}
117
+ </Button>
118
+ );
93
119
 
94
120
  return (
95
121
  <>
96
122
  <div className='cancel-alert-background'>
97
123
  <div className='cancel-alert-top'>
98
- <h3>{`Delete ${caseName}(${ID})`}</h3>
124
+ <h3>{localizedVal(heading, localeCategory)}</h3>
99
125
  <div>
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>
126
+ <p>{localizedVal(content, localeCategory)}</p>
102
127
  </div>
103
128
  <div className='action-controls'>
104
129
  <Grid container spacing={4} justifyContent='space-between'>
105
- <Grid item>
106
- <Button variant='outlined' color='primary' onClick={() => buttonClick('save')}>
107
- {localizedVal('Save for later', localeCategory)}
108
- </Button>
109
- </Grid>
110
- <Grid item>
111
- <Button variant='outlined' color='primary' onClick={() => buttonClick('continue')}>
112
- {localizedVal('Continue Working', localeCategory)}
113
- </Button>
114
- <Button variant='contained' color='primary' onClick={() => buttonClick('delete')}>
115
- {localizedVal('Delete', localeCategory)}
116
- </Button>
117
- </Grid>
130
+ <Grid item>{leftButton}</Grid>
131
+ <Grid item>{rightButton}</Grid>
118
132
  </Grid>
119
133
  </div>
120
134
  </div>
@@ -132,4 +146,4 @@ export default function CancelAlert(props: CancelAlertProps) {
132
146
  />
133
147
  </>
134
148
  );
135
- };
149
+ }
@@ -1 +1 @@
1
- export { default } from './CancelAlert';
1
+ export { default } from './CancelAlert';
@@ -1,49 +1,44 @@
1
- import React, { useState, useEffect } from 'react';
2
- import {
3
- Checkbox,
4
- FormControl,
5
- FormControlLabel,
6
- FormGroup,
7
- FormHelperText
8
- } from '@material-ui/core';
1
+ /* eslint-disable react/no-array-index-key */
2
+ import { useState, useEffect } from 'react';
3
+ import { Checkbox, FormControl, FormControlLabel, FormGroup, FormHelperText, FormLabel } from '@material-ui/core';
4
+
9
5
  import handleEvent from '@pega/react-sdk-components/lib/components/helpers/event-utils';
10
6
  import { getComponentFromMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
11
- // import type { PConnProps } from '../../../types/PConnProps';
7
+ import { insertInstruction, deleteInstruction, updateNewInstuctions } from '@pega/react-sdk-components/lib/components/helpers/instructions-utils';
8
+ import { PConnFieldProps } from '@pega/react-sdk-components/lib/types/PConnProps';
9
+ import { makeStyles } from '@material-ui/core/styles';
12
10
 
13
- // Checkbox passes in 'value' as a boolean. So can't use the default
14
- // PConnFieldProps since it expects value to be a string.
15
- // But can't use CheckBoxProps until getValidationApi() knows about validate method
16
- // Currently just thinks that returns an "object"
17
- // interface CheckboxProps extends PConnProps {
18
- // // If any, enter additional props that only exist on Checkbox here
19
- // // Everything from PConnFieldProps except value and change type of value to boolean
11
+ interface CheckboxProps extends Omit<PConnFieldProps, 'value'> {
12
+ // If any, enter additional props that only exist on Checkbox here
13
+ value?: boolean;
14
+ caption?: string;
15
+ trueLabel?: string;
16
+ falseLabel?: string;
17
+ selectionMode?: string;
18
+ datasource?: any;
19
+ selectionKey?: string;
20
+ selectionList?: any;
21
+ primaryField: string;
22
+ readonlyContextList: any;
23
+ referenceList: string;
24
+ }
20
25
 
21
- // value?: boolean,
22
- // label: string,
23
- // required: boolean,
24
- // disabled: boolean,
25
- // validatemessage: string,
26
- // status?: string,
27
- // // eslint-disable-next-line react/no-unused-prop-types
28
- // onChange: any,
29
- // // eslint-disable-next-line react/no-unused-prop-types
30
- // onBlur?: any,
31
- // readOnly: boolean,
32
- // testId: string,
33
- // helperText: string,
34
- // displayMode?: string,
35
- // hideLabel: boolean,
36
- // // eslint-disable-next-line react/no-unused-prop-types
37
- // placeholder?: string
38
- // }
39
- export default function CheckboxComponent(props /* : CheckboxProps */) {
26
+ const useStyles = makeStyles(() => ({
27
+ checkbox: {
28
+ display: 'flex',
29
+ flexDirection: 'column'
30
+ }
31
+ }));
32
+
33
+ export default function CheckboxComponent(props: CheckboxProps) {
40
34
  // Get emitted components from map (so we can get any override that may exist)
41
35
  const FieldValueList = getComponentFromMap('FieldValueList');
42
36
 
43
37
  const {
44
38
  getPConnect,
45
39
  label,
46
- value = false,
40
+ caption,
41
+ value,
47
42
  readOnly,
48
43
  testId,
49
44
  required,
@@ -52,30 +47,42 @@ export default function CheckboxComponent(props /* : CheckboxProps */) {
52
47
  helperText,
53
48
  validatemessage,
54
49
  displayMode,
55
- hideLabel
50
+ hideLabel,
51
+ trueLabel,
52
+ falseLabel,
53
+ selectionMode,
54
+ datasource,
55
+ selectionKey,
56
+ selectionList,
57
+ primaryField,
58
+ referenceList,
59
+ readonlyContextList: selectedvalues
56
60
  } = props;
61
+ const classes = useStyles();
57
62
  const helperTextToDisplay = validatemessage || helperText;
58
-
59
63
  const thePConn = getPConnect();
60
- const theConfigProps = thePConn.getConfigProps();
61
- const caption = theConfigProps['caption'];
62
64
  const actionsApi = thePConn.getActionsApi();
63
- const propName = thePConn.getStateProps()['value'];
65
+ const propName = (thePConn.getStateProps() as any).value;
64
66
 
65
- const [checked, setChecked] = useState(false);
67
+ const [checked, setChecked] = useState<any>(false);
66
68
  useEffect(() => {
67
69
  // This update theSelectedButton which will update the UI to show the selected button correctly
68
70
  setChecked(value);
69
71
  }, [value]);
70
72
 
73
+ useEffect(() => {
74
+ if (referenceList?.length > 0) {
75
+ thePConn.setReferenceList(selectionList);
76
+ updateNewInstuctions(thePConn, selectionList);
77
+ }
78
+ }, [thePConn]);
79
+
71
80
  if (displayMode === 'LABELS_LEFT') {
72
- return <FieldValueList name={hideLabel ? '' : label} value={value.toString()} />;
81
+ return <FieldValueList name={hideLabel ? '' : caption} value={value ? trueLabel : falseLabel} />;
73
82
  }
74
83
 
75
84
  if (displayMode === 'STACKED_LARGE_VAL') {
76
- return (
77
- <FieldValueList name={hideLabel ? '' : label} value={value.toString()} variant='stacked' />
78
- );
85
+ return <FieldValueList name={hideLabel ? '' : caption} value={value ? trueLabel : falseLabel} variant='stacked' />;
79
86
  }
80
87
 
81
88
  const handleChange = event => {
@@ -83,30 +90,80 @@ export default function CheckboxComponent(props /* : CheckboxProps */) {
83
90
  };
84
91
 
85
92
  const handleBlur = event => {
86
- thePConn.getValidationApi().validate(event.target.checked, ''); // 2nd arg empty string until typedef marked correctly as optional
93
+ thePConn.getValidationApi().validate(event.target.checked);
87
94
  };
88
95
 
89
- let theCheckbox = <Checkbox color='primary' disabled={disabled} />;
90
-
91
- if (readOnly) {
92
- // Workaround for lack of InputProps readOnly from https://github.com/mui-org/material-ui/issues/17043
93
- // Also note that we need to turn off the onChange call in the FormControlLabel wrapper, too. See below!
94
- theCheckbox = <Checkbox value={value || false} readOnly={readOnly} />;
95
- }
96
+ const handleChangeMultiMode = (event, element) => {
97
+ if (event.target.checked) {
98
+ insertInstruction(thePConn, selectionList, selectionKey, primaryField, {
99
+ id: element.key,
100
+ primary: element.text ?? element.value
101
+ });
102
+ } else {
103
+ deleteInstruction(thePConn, selectionList, selectionKey, {
104
+ id: element.key,
105
+ primary: element.text ?? element.value
106
+ });
107
+ }
108
+ thePConn.clearErrorMessages({
109
+ property: selectionList,
110
+ category: '',
111
+ context: ''
112
+ });
113
+ };
96
114
 
97
- return (
98
- <FormControl required={required} error={status === 'error'}>
99
- <FormGroup>
115
+ let theCheckbox;
116
+ const listOfCheckboxes: any = [];
117
+ if (selectionMode === 'multi') {
118
+ const listSourceItems = datasource?.source ?? [];
119
+ const dataField: any = selectionKey?.split?.('.')[1];
120
+ listSourceItems.forEach((element, index) => {
121
+ listOfCheckboxes.push(
100
122
  <FormControlLabel
101
- control={theCheckbox}
102
- checked={checked}
103
- onChange={!readOnly ? handleChange : undefined}
104
- onBlur={!readOnly ? handleBlur : undefined}
105
- label={caption}
123
+ control={
124
+ <Checkbox
125
+ key={index}
126
+ checked={selectedvalues?.some?.(data => data[dataField] === element.key)}
127
+ onChange={event => handleChangeMultiMode(event, element)}
128
+ onBlur={() => {
129
+ thePConn.getValidationApi().validate(selectedvalues, selectionList);
130
+ }}
131
+ data-testid={`${testId}:${element.value}`}
132
+ />
133
+ }
134
+ key={index}
135
+ label={element.text ?? element.value}
106
136
  labelPlacement='end'
107
137
  data-test-id={testId}
108
138
  />
109
- </FormGroup>
139
+ );
140
+ });
141
+ theCheckbox = <div className={classes.checkbox}>{listOfCheckboxes}</div>;
142
+ } else {
143
+ theCheckbox = (
144
+ <FormControlLabel
145
+ control={
146
+ <Checkbox
147
+ color='primary'
148
+ checked={checked}
149
+ onChange={!readOnly ? handleChange : undefined}
150
+ onBlur={!readOnly ? handleBlur : undefined}
151
+ value={value}
152
+ disabled={disabled}
153
+ readOnly={readOnly}
154
+ />
155
+ }
156
+ label={caption}
157
+ labelPlacement='end'
158
+ data-test-id={testId}
159
+ />
160
+ );
161
+ }
162
+
163
+ return (
164
+ <FormControl required={required} error={status === 'error'}>
165
+ {!hideLabel && <FormLabel component='legend'>{label}</FormLabel>}
166
+ <FormGroup>{theCheckbox}</FormGroup>
110
167
  <FormHelperText>{helperTextToDisplay}</FormHelperText>
111
168
  </FormControl>
112
169
  );
@@ -4,7 +4,6 @@
4
4
  "description": "Boolean",
5
5
  "type": "Field",
6
6
  "subtype": "Boolean",
7
- "componentKey" : "Checkbox",
8
- "properties": [
9
- ]
7
+ "componentKey": "Checkbox",
8
+ "properties": []
10
9
  }