@pega/react-sdk-overrides 0.25.1 → 0.25.3

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 (144) hide show
  1. package/lib/designSystemExtension/Banner/Banner.css +1 -1
  2. package/lib/designSystemExtension/Banner/Banner.tsx +7 -7
  3. package/lib/designSystemExtension/CaseSummaryFields/CaseSummaryFields.css +0 -1
  4. package/lib/designSystemExtension/CaseSummaryFields/CaseSummaryFields.tsx +52 -36
  5. package/lib/designSystemExtension/DetailsFields/DetailsFields.tsx +11 -13
  6. package/lib/designSystemExtension/FieldGroup/FieldGroup.tsx +8 -9
  7. package/lib/designSystemExtension/FieldGroupList/FieldGroupList.tsx +9 -9
  8. package/lib/designSystemExtension/FieldValueList/FieldValueList.tsx +7 -8
  9. package/lib/designSystemExtension/Operator/Operator.tsx +21 -19
  10. package/lib/designSystemExtension/Pulse/Pulse.tsx +1 -1
  11. package/lib/designSystemExtension/RichTextEditor/RichTextEditor.tsx +28 -3
  12. package/lib/designSystemExtension/WssQuickCreate/WssQuickCreate.css +4 -4
  13. package/lib/designSystemExtension/WssQuickCreate/WssQuickCreate.tsx +1 -1
  14. package/lib/field/AutoComplete/AutoComplete.tsx +1 -1
  15. package/lib/field/CancelAlert/CancelAlert.css +4 -4
  16. package/lib/field/CancelAlert/CancelAlert.tsx +6 -6
  17. package/lib/field/Checkbox/Checkbox.tsx +97 -4
  18. package/lib/field/Currency/Currency.tsx +3 -3
  19. package/lib/field/Currency/currency-utils.ts +1 -2
  20. package/lib/field/Date/Date.tsx +3 -7
  21. package/lib/field/DateTime/DateTime.tsx +3 -8
  22. package/lib/field/Decimal/Decimal.tsx +3 -5
  23. package/lib/field/Dropdown/Dropdown.tsx +5 -7
  24. package/lib/field/Email/Email.tsx +11 -13
  25. package/lib/field/Group/Group.tsx +7 -7
  26. package/lib/field/Integer/Integer.tsx +5 -7
  27. package/lib/field/Location/Location.tsx +256 -0
  28. package/lib/field/Location/config-ext.json +8 -0
  29. package/lib/field/Location/index.tsx +1 -0
  30. package/lib/field/ObjectReference/ObjectReference.tsx +235 -0
  31. package/lib/field/ObjectReference/index.tsx +1 -0
  32. package/lib/field/ObjectReference/utils.ts +111 -0
  33. package/lib/field/Percentage/Percentage.tsx +3 -7
  34. package/lib/field/Phone/Phone.tsx +7 -5
  35. package/lib/field/RadioButtons/RadioButtons.tsx +47 -2
  36. package/lib/field/RichText/RichText.tsx +1 -1
  37. package/lib/field/ScalarList/ScalarList.tsx +2 -3
  38. package/lib/field/SelectableCard/SelectableCard.tsx +175 -0
  39. package/lib/field/SelectableCard/index.tsx +1 -0
  40. package/lib/field/SelectableCard/utils.tsx +226 -0
  41. package/lib/field/SemanticLink/SemanticLink.tsx +160 -28
  42. package/lib/field/SemanticLink/utils.ts +1 -1
  43. package/lib/field/TextArea/TextArea.tsx +5 -7
  44. package/lib/field/TextContent/TextContent.tsx +1 -2
  45. package/lib/field/TextInput/TextInput.tsx +5 -7
  46. package/lib/field/Time/Time.tsx +3 -7
  47. package/lib/field/URL/URL.tsx +5 -7
  48. package/lib/field/UserReference/UserReference.tsx +1 -2
  49. package/lib/helpers/attachmentHelpers.ts +56 -35
  50. package/lib/helpers/common-utils.ts +2 -2
  51. package/lib/helpers/data_page.ts +0 -1
  52. package/lib/helpers/field-group-utils.ts +1 -1
  53. package/lib/helpers/formatters/CurrencyMap.ts +0 -2
  54. package/lib/helpers/simpleTableHelpers.ts +118 -6
  55. package/lib/helpers/utils.ts +8 -1
  56. package/lib/helpers/versionHelpers.ts +0 -1
  57. package/lib/infra/ActionButtons/ActionButtons.tsx +28 -21
  58. package/lib/infra/Assignment/Assignment.tsx +4 -4
  59. package/lib/infra/AssignmentCard/AssignmentCard.tsx +2 -2
  60. package/lib/infra/Containers/FlowContainer/FlowContainer.tsx +15 -94
  61. package/lib/infra/Containers/ModalViewContainer/ListViewActionButtons/ListViewActionButtons.tsx +1 -2
  62. package/lib/infra/Containers/ModalViewContainer/ModalViewContainer.tsx +3 -3
  63. package/lib/infra/Containers/ViewContainer/ViewContainer.tsx +4 -5
  64. package/lib/infra/Containers/container-helpers.ts +47 -1
  65. package/lib/infra/DashboardFilter/DashboardFilter.tsx +2 -4
  66. package/lib/infra/DashboardFilter/filterUtils.tsx +3 -4
  67. package/lib/infra/DeferLoad/DeferLoad.tsx +2 -4
  68. package/lib/infra/ErrorBoundary/ErrorBoundary.tsx +1 -3
  69. package/lib/infra/MultiStep/MultiStep.css +8 -8
  70. package/lib/infra/MultiStep/MultiStep.tsx +2 -2
  71. package/lib/infra/NavBar/NavBar.css +1 -1
  72. package/lib/infra/NavBar/NavBar.tsx +29 -27
  73. package/lib/infra/Reference/Reference.tsx +3 -4
  74. package/lib/infra/Region/Region.tsx +1 -1
  75. package/lib/infra/RootContainer/RootContainer.tsx +2 -3
  76. package/lib/infra/Stages/Stages.tsx +1 -1
  77. package/lib/infra/View/View.tsx +2 -2
  78. package/lib/template/AdvancedSearch/AdvancedSearch.tsx +0 -1
  79. package/lib/template/AdvancedSearch/SearchGroup/persistUtils.ts +3 -9
  80. package/lib/template/AdvancedSearch/SearchGroups/SearchGroups.tsx +3 -4
  81. package/lib/template/AdvancedSearch/SearchGroups/hooks.ts +1 -1
  82. package/lib/template/AppShell/AppShell.css +1 -1
  83. package/lib/template/AppShell/AppShell.tsx +6 -10
  84. package/lib/template/BannerPage/BannerPage.tsx +2 -2
  85. package/lib/template/CaseSummary/CaseSummary.tsx +2 -3
  86. package/lib/template/CaseView/CaseView.tsx +15 -21
  87. package/lib/template/CaseViewActionsMenu/CaseViewActionsMenu.tsx +1 -1
  88. package/lib/template/Confirmation/Confirmation.tsx +2 -3
  89. package/lib/template/DataReference/DataReference.tsx +9 -12
  90. package/lib/template/DataReference/SearchForm.tsx +6 -5
  91. package/lib/template/DataReference/{utils.js → utils.ts} +3 -3
  92. package/lib/template/DefaultForm/DefaultForm.tsx +3 -3
  93. package/lib/template/Details/Details/Details.tsx +11 -11
  94. package/lib/template/Details/DetailsSubTabs/DetailsSubTabs.tsx +2 -2
  95. package/lib/template/Details/DetailsThreeColumn/DetailsThreeColumn.tsx +11 -11
  96. package/lib/template/Details/DetailsTwoColumn/DetailsTwoColumn.tsx +11 -11
  97. package/lib/template/Details/DynamicTabs/DynamicTabs.tsx +1 -1
  98. package/lib/template/FieldGroupTemplate/FieldGroupTemplate.tsx +2 -3
  99. package/lib/template/InlineDashboard/InlineDashboard.tsx +14 -16
  100. package/lib/template/InlineDashboardPage/InlineDashboardPage.tsx +2 -2
  101. package/lib/template/ListPage/ListPage.tsx +1 -1
  102. package/lib/template/ListView/ListView.tsx +10 -22
  103. package/lib/template/ListView/hooks.ts +1 -5
  104. package/lib/template/ListView/utils.ts +1 -1
  105. package/lib/template/MultiReferenceReadOnly/MultiReferenceReadOnly.tsx +1 -1
  106. package/lib/template/NarrowWide/NarrowWide/NarrowWide.tsx +5 -5
  107. package/lib/template/NarrowWide/NarrowWideDetails/NarrowWideDetails.tsx +11 -11
  108. package/lib/template/NarrowWide/NarrowWideForm/NarrowWideForm.tsx +2 -2
  109. package/lib/template/NarrowWide/NarrowWidePage/NarrowWidePage.tsx +2 -2
  110. package/lib/template/OneColumn/OneColumn/OneColumn.tsx +7 -7
  111. package/lib/template/OneColumn/OneColumnPage/OneColumnPage.tsx +1 -1
  112. package/lib/template/OneColumn/OneColumnTab/OneColumnTab.tsx +2 -2
  113. package/lib/template/PromotedFilters/PromotedFilters.tsx +1 -2
  114. package/lib/template/SimpleTable/SimpleTable/SimpleTable.tsx +2 -3
  115. package/lib/template/SimpleTable/SimpleTableManual/SimpleTableManual.tsx +35 -32
  116. package/lib/template/SimpleTable/SimpleTableSelect/SimpleTableSelect.tsx +1 -1
  117. package/lib/template/SingleReferenceReadOnly/SingleReferenceReadOnly.tsx +1 -1
  118. package/lib/template/SubTabs/SubTabs.tsx +2 -2
  119. package/lib/template/TwoColumn/TwoColumn/TwoColumn.tsx +9 -10
  120. package/lib/template/TwoColumn/TwoColumnPage/TwoColumnPage.tsx +1 -1
  121. package/lib/template/TwoColumn/TwoColumnTab/TwoColumnTab.tsx +9 -10
  122. package/lib/template/WideNarrow/WideNarrow/WideNarrow.tsx +5 -5
  123. package/lib/template/WideNarrow/WideNarrowDetails/WideNarrowDetails.tsx +11 -11
  124. package/lib/template/WideNarrow/WideNarrowForm/WideNarrowForm.tsx +2 -2
  125. package/lib/template/WideNarrow/WideNarrowPage/WideNarrowPage.tsx +2 -2
  126. package/lib/template/WssNavBar/WssNavBar.css +1 -1
  127. package/lib/template/WssNavBar/WssNavBar.tsx +5 -5
  128. package/lib/widget/AppAnnouncement/AppAnnouncement.tsx +1 -1
  129. package/lib/widget/Attachment/Attachment.css +6 -8
  130. package/lib/widget/Attachment/Attachment.tsx +62 -58
  131. package/lib/widget/CaseHistory/CaseHistory.tsx +5 -5
  132. package/lib/widget/FileUtility/ActionButtonsForFileUtil/ActionButtonsForFileUtil.css +0 -14
  133. package/lib/widget/FileUtility/ActionButtonsForFileUtil/ActionButtonsForFileUtil.tsx +3 -3
  134. package/lib/widget/FileUtility/FileUtility/FileUtility.css +7 -6
  135. package/lib/widget/FileUtility/FileUtility/FileUtility.tsx +5 -7
  136. package/lib/widget/Followers/Followers.tsx +2 -4
  137. package/lib/widget/QuickCreate/QuickCreate.tsx +1 -2
  138. package/lib/widget/SummaryItem/SummaryItem.css +9 -11
  139. package/lib/widget/SummaryItem/SummaryItem.tsx +2 -2
  140. package/lib/widget/SummaryList/SummaryList.tsx +1 -1
  141. package/lib/widget/ToDo/ToDo.css +1 -13
  142. package/lib/widget/ToDo/ToDo.tsx +26 -26
  143. package/package.json +1 -1
  144. /package/lib/template/DataReference/{DataReferenceAdvancedSearchContext.js → DataReferenceAdvancedSearchContext.ts} +0 -0
@@ -1,13 +1,11 @@
1
- import Typography from '@mui/material/Typography';
2
- import Grid from '@mui/material/Grid';
1
+ import { Link } from '@mui/material';
3
2
  import makeStyles from '@mui/styles/makeStyles';
4
3
 
5
- import { getComponentFromMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
6
- import { PConnFieldProps } from '@pega/react-sdk-components/lib/types/PConnProps';
4
+ import type { PConnFieldProps } from '@pega/react-sdk-components/lib/types/PConnProps';
7
5
 
8
- /* although this is called the SemanticLink component, we are not yet displaying as a
9
- SemanticLink in SDK and only showing the value as a read only text field. */
6
+ import semanticUtils from './utils';
10
7
 
8
+ // eslint-disable-next-line
11
9
  const useStyles = makeStyles(theme => ({
12
10
  root: {
13
11
  paddingRight: theme.spacing(1),
@@ -41,36 +39,170 @@ const useStyles = makeStyles(theme => ({
41
39
 
42
40
  interface SemanticLinkProps extends PConnFieldProps {
43
41
  // If any, enter additional props that only exist on SemanticLink here
44
- // from previous PropTypes
45
42
  text: string;
43
+ resourcePayload: any;
44
+ resourceParams: any;
45
+ previewKey: string | null;
46
+ onClick: (event: any) => void;
47
+ testId: string;
48
+ referenceType: string | null;
49
+ dataRelationshipContext: string | null;
50
+ contextPage: any;
46
51
  }
47
52
 
48
53
  export default function SemanticLink(props: SemanticLinkProps) {
49
- // Get emitted components from map (so we can get any override that may exist)
50
- const FieldValueList = getComponentFromMap('FieldValueList');
54
+ const {
55
+ text,
56
+ resourcePayload = {},
57
+ resourceParams = {},
58
+ getPConnect,
59
+ previewKey,
60
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
61
+ onClick,
62
+ testId = '',
63
+ referenceType,
64
+ dataRelationshipContext = null,
65
+ contextPage,
66
+ ...restProps
67
+ } = props;
68
+ const { ACTION_OPENWORKBYHANDLE, ACTION_SHOWDATA }: any = PCore.getSemanticUrlUtils().getActions();
69
+ const pConnect = getPConnect();
70
+ const dataResourcePayLoad = resourcePayload?.resourceType === 'DATA' ? resourcePayload : null;
51
71
 
52
- const { text, displayMode, label, hideLabel } = props;
53
- const classes = useStyles();
72
+ const {
73
+ RESOURCE_TYPES: { DATA },
74
+ WORKCLASS,
75
+ CASE_INFO: { CASE_INFO_CLASSID }
76
+ } = PCore.getConstants();
54
77
 
55
- if (displayMode === 'DISPLAY_ONLY' || (!displayMode && label !== undefined)) {
56
- const value = text || '---';
57
- return (
58
- <Grid container spacing={1} style={{ padding: '4px 0px' }} id='semantic-link-grid'>
59
- <Grid item xs={6}>
60
- <Typography variant='body2' component='span' className={`${classes.fieldLabel} ${classes.fieldMargin}`}>
61
- {label}
62
- </Typography>
63
- </Grid>
64
- <Grid item xs={6}>
65
- <Typography variant='body2' component='span' className={classes.fieldValue}>
66
- {value}
67
- </Typography>
68
- </Grid>
69
- </Grid>
78
+ let linkURL = '';
79
+ let payload = {};
80
+ let dataViewName;
81
+ let linkComponentProps = {
82
+ href: linkURL
83
+ };
84
+ if (text) {
85
+ (linkComponentProps as any).href = linkURL;
86
+ }
87
+ let isData = false;
88
+ const shouldTreatAsDataReference = !previewKey && resourcePayload.caseClassName;
89
+ if (contextPage?.classID) {
90
+ resourcePayload.caseClassName = contextPage.classID;
91
+ }
92
+ /* TODO : In case of duplicate search case the classID is Work- need to set it to
93
+ the current case class ID */
94
+ if (resourcePayload.caseClassName === WORKCLASS) {
95
+ resourcePayload.caseClassName = pConnect.getValue(CASE_INFO_CLASSID);
96
+ }
97
+
98
+ function showDataAction() {
99
+ if (dataResourcePayLoad && dataResourcePayLoad.resourceType === 'DATA') {
100
+ const { content } = dataResourcePayLoad;
101
+ const lookUpDataPageInfo = PCore.getDataTypeUtils().getLookUpDataPageInfo(dataResourcePayLoad?.className);
102
+ const lookUpDataPage = PCore.getDataTypeUtils().getLookUpDataPage(dataResourcePayLoad?.className);
103
+ if (lookUpDataPageInfo) {
104
+ const { parameters }: any = lookUpDataPageInfo;
105
+ payload = Object.keys(parameters).reduce((acc, param) => {
106
+ const paramValue = parameters[param];
107
+ return {
108
+ ...acc,
109
+ [param]: PCore.getAnnotationUtils().isProperty(paramValue) ? content[PCore.getAnnotationUtils().getPropertyName(paramValue)] : paramValue
110
+ };
111
+ }, {});
112
+ }
113
+ getPConnect()
114
+ .getActionsApi()
115
+ .showData('pyDetails', lookUpDataPage, {
116
+ ...payload
117
+ });
118
+ }
119
+ if ((referenceType && referenceType.toUpperCase() === DATA) || shouldTreatAsDataReference) {
120
+ getPConnect()
121
+ .getActionsApi()
122
+ .showData('pyDetails', dataViewName, {
123
+ ...payload
124
+ });
125
+ }
126
+ }
127
+
128
+ function openLinkClick(e) {
129
+ if (!e.metaKey && !e.ctrlKey) {
130
+ e.preventDefault();
131
+ if (
132
+ (dataResourcePayLoad && dataResourcePayLoad.resourceType === 'DATA') ||
133
+ (referenceType && referenceType.toUpperCase() === DATA) ||
134
+ shouldTreatAsDataReference
135
+ ) {
136
+ showDataAction();
137
+ } else if (previewKey) {
138
+ getPConnect().getActionsApi().openWorkByHandle(previewKey, resourcePayload.caseClassName);
139
+ }
140
+ }
141
+ }
142
+
143
+ if ((referenceType && referenceType.toUpperCase() === DATA) || shouldTreatAsDataReference) {
144
+ try {
145
+ isData = true;
146
+ // @ts-expect-error
147
+ const dataRefContext = semanticUtils.getDataReferenceInfo(pConnect, dataRelationshipContext, contextPage);
148
+ dataViewName = dataRefContext.dataContext;
149
+ payload = dataRefContext.dataContextParameters as any;
150
+ } catch (error) {
151
+ console.log('Error in getting the data reference info', error);
152
+ }
153
+ } else if (resourcePayload && resourcePayload.resourceType === 'DATA') {
154
+ isData = true;
155
+ dataViewName = PCore.getDataTypeUtils().getLookUpDataPage(resourcePayload.className);
156
+ const lookUpDataPageInfo = PCore.getDataTypeUtils().getLookUpDataPageInfo(resourcePayload.className);
157
+ const { content } = resourcePayload;
158
+ if (lookUpDataPageInfo) {
159
+ const { parameters }: any = lookUpDataPageInfo;
160
+ payload = Object.keys(parameters).reduce((acc, param) => {
161
+ const paramValue = parameters[param];
162
+ return {
163
+ ...acc,
164
+ [param]: PCore.getAnnotationUtils().isProperty(paramValue) ? content[PCore.getAnnotationUtils().getPropertyName(paramValue)] : paramValue
165
+ };
166
+ }, {});
167
+ } else {
168
+ const keysInfo = PCore.getDataTypeUtils().getDataPageKeys(dataViewName) ?? [];
169
+ payload = keysInfo.reduce((acc, curr) => {
170
+ return {
171
+ ...acc,
172
+ [curr.keyName]: content[curr.isAlternateKeyStorage ? curr.linkedField : curr.keyName]
173
+ };
174
+ }, {});
175
+ }
176
+ }
177
+
178
+ if (isData && dataViewName && payload) {
179
+ linkURL = PCore.getSemanticUrlUtils().getResolvedSemanticURL(
180
+ ACTION_SHOWDATA,
181
+ { pageName: 'pyDetails', dataViewName },
182
+ {
183
+ ...payload
184
+ }
70
185
  );
186
+ } else {
187
+ // BUG-678282 fix to handle scenario when workID was not populated.
188
+ // Check renderParentLink in Caseview / CasePreview
189
+ resourceParams.objectID = resourceParams.workID === '' && typeof previewKey === 'string' ? previewKey.split(' ')[1] : resourceParams.workID;
190
+ if (previewKey) {
191
+ resourceParams.id = previewKey;
192
+ }
193
+ linkURL = PCore.getSemanticUrlUtils().getResolvedSemanticURL(ACTION_OPENWORKBYHANDLE, resourcePayload, resourceParams);
71
194
  }
72
195
 
73
- if (displayMode === 'STACKED_LARGE_VAL') {
74
- return <FieldValueList name={hideLabel ? '' : label} value={text} variant='stacked' />;
196
+ if (text) {
197
+ linkComponentProps = {
198
+ ...linkComponentProps,
199
+ href: linkURL
200
+ };
75
201
  }
202
+
203
+ return (
204
+ <Link component='button' {...linkComponentProps} {...restProps} onClick={openLinkClick} data-testid={testId}>
205
+ {text}
206
+ </Link>
207
+ );
76
208
  }
@@ -32,7 +32,7 @@ function getDataReferenceInfo(pConnect, dataRelationshipContext) {
32
32
  dataContext = name;
33
33
  for (const [key, value] of Object.entries(parameters)) {
34
34
  const property =
35
- // @ts-ignore - Property 'getLeafPropertyName' is private and only accessible within class 'AnnotationUtils'
35
+ // @ts-expect-error - Property 'getLeafPropertyName' is private and only accessible within class 'AnnotationUtils'
36
36
  dataRelationshipContext !== null ? annotationUtils.getPropertyName(value as string) : annotationUtils.getLeafPropertyName(value);
37
37
  payload[key] = pConnect.getValue(`.${property}`);
38
38
  }
@@ -3,7 +3,7 @@ import { TextField } from '@mui/material';
3
3
 
4
4
  import handleEvent from '@pega/react-sdk-components/lib/components/helpers/event-utils';
5
5
  import { getComponentFromMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
6
- import { PConnFieldProps } from '@pega/react-sdk-components/lib/types/PConnProps';
6
+ import type { PConnFieldProps } from '@pega/react-sdk-components/lib/types/PConnProps';
7
7
 
8
8
  interface TextAreaProps extends PConnFieldProps {
9
9
  // If any, enter additional props that only exist on TextArea here
@@ -58,11 +58,7 @@ export default function TextArea(props: TextAreaProps) {
58
58
  readOnlyProp = { readOnly: true };
59
59
  }
60
60
 
61
- let testProp = {};
62
-
63
- testProp = {
64
- 'data-test-id': testId
65
- };
61
+ const testProps: any = { 'data-test-id': testId };
66
62
 
67
63
  function handleChange(event) {
68
64
  // update internal value
@@ -90,7 +86,9 @@ export default function TextArea(props: TextAreaProps) {
90
86
  error={status === 'error'}
91
87
  label={label}
92
88
  value={inputValue}
93
- InputProps={{ ...readOnlyProp, inputProps: { maxLength, ...testProp } }}
89
+ slotProps={{
90
+ input: { ...readOnlyProp, inputProps: { maxLength, ...testProps } }
91
+ }}
94
92
  />
95
93
  );
96
94
  }
@@ -1,6 +1,6 @@
1
1
  import { Typography } from '@mui/material';
2
2
 
3
- import { PConnProps } from '@pega/react-sdk-components/lib/types/PConnProps';
3
+ import type { PConnProps } from '@pega/react-sdk-components/lib/types/PConnProps';
4
4
 
5
5
  interface TextContentProps extends PConnProps {
6
6
  // If any, enter additional props that only exist on TextContent here
@@ -38,7 +38,6 @@ export default function TextContent(props: TextContentProps) {
38
38
  break;
39
39
 
40
40
  default:
41
- // eslint-disable-next-line no-console
42
41
  console.error(`TextContent got an expected displayAs prop: ${displayAs}`);
43
42
  break;
44
43
  }
@@ -3,7 +3,7 @@ import { TextField } from '@mui/material';
3
3
 
4
4
  import handleEvent from '@pega/react-sdk-components/lib/components/helpers/event-utils';
5
5
  import { getComponentFromMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
6
- import { PConnFieldProps } from '@pega/react-sdk-components/lib/types/PConnProps';
6
+ import type { PConnFieldProps } from '@pega/react-sdk-components/lib/types/PConnProps';
7
7
 
8
8
  interface TextInputProps extends PConnFieldProps {
9
9
  // If any, enter additional props that only exist on TextInput here
@@ -59,11 +59,7 @@ export default function TextInput(props: TextInputProps) {
59
59
  readOnlyProp = { readOnly: true };
60
60
  }
61
61
 
62
- let testProp = {};
63
-
64
- testProp = {
65
- 'data-test-id': testId
66
- };
62
+ const testProps: any = { 'data-test-id': testId };
67
63
 
68
64
  function handleChange(event) {
69
65
  // update internal value
@@ -88,7 +84,9 @@ export default function TextInput(props: TextInputProps) {
88
84
  error={status === 'error'}
89
85
  label={label}
90
86
  value={inputValue}
91
- InputProps={{ ...readOnlyProp, inputProps: { maxLength, ...testProp } }}
87
+ slotProps={{
88
+ input: { ...readOnlyProp, inputProps: { maxLength, ...testProps } }
89
+ }}
92
90
  />
93
91
  );
94
92
  }
@@ -4,7 +4,7 @@ import dayjs from 'dayjs';
4
4
 
5
5
  import handleEvent from '@pega/react-sdk-components/lib/components/helpers/event-utils';
6
6
  import { getComponentFromMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
7
- import { PConnFieldProps } from '@pega/react-sdk-components/lib/types/PConnProps';
7
+ import type { PConnFieldProps } from '@pega/react-sdk-components/lib/types/PConnProps';
8
8
 
9
9
  interface TimeProps extends PConnFieldProps {
10
10
  // If any, enter additional props that only exist on Time here
@@ -32,11 +32,7 @@ export default function Time(props: TimeProps) {
32
32
  return <TextInput {...props} />;
33
33
  }
34
34
 
35
- let testProp = {};
36
-
37
- testProp = {
38
- 'data-test-id': testId
39
- };
35
+ const testProps: any = { 'data-test-id': testId };
40
36
 
41
37
  const handleChange = date => {
42
38
  const theValue = date && date.isValid() ? date.format('HH:mm:ss') : null;
@@ -75,7 +71,7 @@ export default function Time(props: TimeProps) {
75
71
  error: status === 'error',
76
72
  helperText: helperTextToDisplay,
77
73
  size: 'small',
78
- InputProps: { ...testProp }
74
+ InputProps: { ...testProps }
79
75
  }
80
76
  }}
81
77
  />
@@ -3,7 +3,7 @@ import { TextField } from '@mui/material';
3
3
 
4
4
  import handleEvent from '@pega/react-sdk-components/lib/components/helpers/event-utils';
5
5
  import { getComponentFromMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
6
- import { PConnFieldProps } from '@pega/react-sdk-components/lib/types/PConnProps';
6
+ import type { PConnFieldProps } from '@pega/react-sdk-components/lib/types/PConnProps';
7
7
 
8
8
  interface URLComponentProps extends PConnFieldProps {
9
9
  // If any, enter additional props that only exist on URLComponent here
@@ -56,11 +56,7 @@ export default function URLComponent(props: URLComponentProps) {
56
56
  return <TextInput {...props} />;
57
57
  }
58
58
 
59
- let testProp = {};
60
-
61
- testProp = {
62
- 'data-test-id': testId
63
- };
59
+ const testProps: any = { 'data-test-id': testId };
64
60
 
65
61
  const handleChange = event => {
66
62
  setInputValue(event?.target?.value);
@@ -85,7 +81,9 @@ export default function URLComponent(props: URLComponentProps) {
85
81
  error={status === 'error'}
86
82
  label={label}
87
83
  value={inputValue}
88
- InputProps={{ inputProps: { ...testProp } }}
84
+ slotProps={{
85
+ input: { inputProps: { ...testProps } }
86
+ }}
89
87
  />
90
88
  );
91
89
  }
@@ -2,7 +2,7 @@ import { memo, useEffect, useState } from 'react';
2
2
  import { Typography } from '@mui/material';
3
3
 
4
4
  import { getComponentFromMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
5
- import { PConnProps } from '@pega/react-sdk-components/lib/types/PConnProps';
5
+ import type { PConnProps } from '@pega/react-sdk-components/lib/types/PConnProps';
6
6
 
7
7
  import FieldValueList from '@pega/react-sdk-components/lib/components/designSystemExtension/FieldValueList';
8
8
  import { getUserId, isUserNameAvailable } from './UserReferenceUtils';
@@ -89,7 +89,6 @@ const UserReference = (props: UserReferenceProps) => {
89
89
  setDropDownDataSource(ddDataSource);
90
90
  })
91
91
  .catch(err => {
92
- // eslint-disable-next-line no-console
93
92
  console.error(err);
94
93
  });
95
94
  }
@@ -1,20 +1,67 @@
1
+ import { useCallback } from 'react';
1
2
  import download from 'downloadjs';
2
3
 
3
- export const validateMaxSize = (fileObj: any, maxSizeInMB: string): boolean => {
4
- const fileSize = (fileObj.size / 1048576).toFixed(2);
5
- return parseFloat(fileSize) < parseFloat(maxSizeInMB);
4
+ export const isContentBinary = headers => {
5
+ return headers && headers['content-transfer-encoding'] === 'binary';
6
6
  };
7
7
 
8
- export const fileDownload = (data, fileName, ext) => {
8
+ export const isContentBase64 = headers => {
9
+ return headers && headers['content-transfer-encoding'] === 'base64';
10
+ };
11
+
12
+ export const fileDownload = (data, fileName, ext, headers) => {
9
13
  const name = ext ? `${fileName}.${ext}` : fileName;
10
14
  // Temp fix: downloading EMAIl type attachment as html file
11
15
  if (ext === 'html') {
12
- download(data, name, 'text/html');
16
+ download(isContentBase64(headers) ? atob(data) : data, name, 'text/html');
17
+ } else if (isContentBinary(headers)) {
18
+ download(data, name);
13
19
  } else {
14
20
  download(atob(data), name);
15
21
  }
16
22
  };
17
23
 
24
+ export const fileDownloadVar = (content, type, name, extension) => {
25
+ if (type === 'FILE' || type === undefined) {
26
+ fileDownload(content.data, name, extension, content.headers);
27
+ } else if (type === 'URL') {
28
+ let { data } = content;
29
+ if (!/^(http|https):\/\//.test(data)) {
30
+ data = `//${data}`;
31
+ }
32
+ window.open(content.data, '_blank');
33
+ } else if (type === 'EMAIL') {
34
+ // Temp Fix: for EMAIL type attachment
35
+ fileDownload(content.data, name, 'html', content.headers);
36
+ }
37
+ };
38
+
39
+ export const useFileDownload = context => {
40
+ return useCallback(
41
+ ({ ID, name, extension, type, category, responseType }) => {
42
+ if (category !== 'pxDocument') {
43
+ PCore.getAttachmentUtils()
44
+ .downloadAttachment(ID, context, responseType)
45
+ .then(content => {
46
+ fileDownloadVar(content, type, name, extension);
47
+ })
48
+
49
+ .catch(console.error);
50
+ } else {
51
+ PCore.getAttachmentUtils()
52
+ // @ts-expect-error
53
+ .downloadDocument(ID, context, responseType)
54
+ .then(content => {
55
+ fileDownloadVar(content, type, name, extension);
56
+ })
57
+
58
+ .catch(console.error);
59
+ }
60
+ },
61
+ [context]
62
+ );
63
+ };
64
+
18
65
  export const getIconFromFileType = (fileType): string => {
19
66
  let icon = 'document-doc';
20
67
  if (!fileType) return icon;
@@ -42,35 +89,9 @@ export const getIconFromFileType = (fileType): string => {
42
89
  return icon;
43
90
  };
44
91
 
45
- export const getIconForAttachment = (inThis: any, attachment: any): string => {
46
- let icon;
47
- switch (attachment.type) {
48
- case 'FILE':
49
- icon = inThis.getIconFromFileType(attachment.mimeType);
50
- break;
51
- case 'URL':
52
- icon = 'chain';
53
- break;
54
- default:
55
- icon = 'document-doc';
56
- }
57
- return icon;
92
+ export const validateMaxSize = (fileObj: any, maxSizeInMB: string): boolean => {
93
+ const fileSize = (fileObj.size / 1048576).toFixed(2);
94
+ return parseFloat(fileSize) < parseFloat(maxSizeInMB);
58
95
  };
59
96
 
60
- export const buildFilePropsFromResponse = (
61
- respObj
62
- ): {
63
- props: { meta: string; name: string; icon: string };
64
- responseProps: any;
65
- } => {
66
- return {
67
- props: {
68
- meta: `${respObj.pyCategoryName}, ${respObj.pxCreateOperator}`,
69
- name: respObj.pyAttachName,
70
- icon: getIconFromFileType(respObj.pyMimeFileExtension)
71
- },
72
- responseProps: {
73
- ...respObj
74
- }
75
- };
76
- };
97
+ export const isFileUploadedToServer = file => file.responseProps && !file.responseProps.ID?.includes('temp');
@@ -1,4 +1,4 @@
1
- export function isEmptyObject(obj: Object): boolean {
1
+ export function isEmptyObject(obj: object): boolean {
2
2
  return Object.keys(obj).length === 0;
3
3
  }
4
4
 
@@ -16,7 +16,7 @@ export function getGenericFieldsLocalizedValue(path: string, key: string): strin
16
16
 
17
17
  // Split the path and traverse the object
18
18
  const pathParts = path.split('.');
19
- let currentObj = localeStore;
19
+ let currentObj: any = localeStore;
20
20
 
21
21
  for (const part of pathParts) {
22
22
  if (!currentObj[part]) return key;
@@ -1,4 +1,3 @@
1
- // eslint-disable-next-line import/prefer-default-export
2
1
  export const getDataPage = (dataPageName, parameters, context) => {
3
2
  let dataViewParams;
4
3
  if (parameters) {
@@ -1,4 +1,4 @@
1
- import { createElement, ReactElement } from 'react';
1
+ import { createElement, type ReactElement } from 'react';
2
2
 
3
3
  import createPConnectComponent from '@pega/react-sdk-components/lib/bridge/react_pconnect';
4
4
 
@@ -1,5 +1,3 @@
1
- /* eslint-disable no-template-curly-in-string */
2
-
3
1
  type CurrencyMapType = {
4
2
  name: string;
5
3
  symbolFormat: string;