@pega/react-sdk-overrides 24.2.11 → 25.1.10

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 (164) hide show
  1. package/lib/designSystemExtension/Banner/Banner.css +1 -1
  2. package/lib/designSystemExtension/Banner/Banner.tsx +10 -7
  3. package/lib/designSystemExtension/CaseSummaryFields/CaseSummaryFields.css +0 -1
  4. package/lib/designSystemExtension/CaseSummaryFields/CaseSummaryFields.tsx +53 -37
  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 +32 -4
  12. package/lib/designSystemExtension/WssQuickCreate/WssQuickCreate.css +7 -14
  13. package/lib/designSystemExtension/WssQuickCreate/WssQuickCreate.tsx +13 -2
  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 +10 -8
  26. package/lib/field/Integer/Integer.tsx +5 -7
  27. package/lib/field/Location/Location.css +4 -0
  28. package/lib/field/Location/Location.tsx +258 -0
  29. package/lib/field/Location/config-ext.json +8 -0
  30. package/lib/field/Location/index.tsx +1 -0
  31. package/lib/field/Multiselect/utils.ts +1 -1
  32. package/lib/field/ObjectReference/ObjectReference.tsx +235 -0
  33. package/lib/field/ObjectReference/index.tsx +1 -0
  34. package/lib/field/ObjectReference/utils.ts +111 -0
  35. package/lib/field/Percentage/Percentage.tsx +3 -7
  36. package/lib/field/Phone/Phone.tsx +7 -5
  37. package/lib/field/RadioButtons/RadioButtons.tsx +47 -2
  38. package/lib/field/RichText/RichText.css +79 -0
  39. package/lib/field/RichText/RichText.tsx +3 -1
  40. package/lib/field/ScalarList/ScalarList.tsx +2 -3
  41. package/lib/field/SelectableCard/SelectableCard.tsx +175 -0
  42. package/lib/field/SelectableCard/index.tsx +1 -0
  43. package/lib/field/SelectableCard/utils.tsx +223 -0
  44. package/lib/field/SemanticLink/SemanticLink.tsx +160 -28
  45. package/lib/field/SemanticLink/utils.ts +1 -1
  46. package/lib/field/TextArea/TextArea.tsx +5 -7
  47. package/lib/field/TextContent/TextContent.tsx +1 -2
  48. package/lib/field/TextInput/TextInput.tsx +5 -7
  49. package/lib/field/Time/Time.tsx +3 -7
  50. package/lib/field/URL/URL.tsx +5 -7
  51. package/lib/field/UserReference/UserReference.tsx +2 -3
  52. package/lib/helpers/attachmentShared.ts +6 -0
  53. package/lib/helpers/common-utils.ts +3 -4
  54. package/lib/helpers/data_page.ts +0 -1
  55. package/lib/helpers/field-group-utils.ts +1 -1
  56. package/lib/helpers/formatters/Currency.ts +9 -4
  57. package/lib/helpers/formatters/CurrencyMap.ts +0 -2
  58. package/lib/helpers/object-utils.ts +10 -0
  59. package/lib/helpers/simpleTableHelpers.ts +118 -6
  60. package/lib/helpers/utils.ts +8 -1
  61. package/lib/helpers/versionHelpers.ts +0 -1
  62. package/lib/infra/ActionButtons/ActionButtons.tsx +28 -21
  63. package/lib/infra/Assignment/Assignment.tsx +37 -30
  64. package/lib/infra/AssignmentCard/AssignmentCard.tsx +2 -2
  65. package/lib/infra/Containers/FlowContainer/FlowContainer.tsx +17 -96
  66. package/lib/infra/Containers/ModalViewContainer/ListViewActionButtons/ListViewActionButtons.tsx +1 -2
  67. package/lib/infra/Containers/ModalViewContainer/ModalViewContainer.tsx +7 -6
  68. package/lib/infra/Containers/ViewContainer/ViewContainer.tsx +4 -5
  69. package/lib/infra/Containers/container-helpers.ts +47 -1
  70. package/lib/infra/DashboardFilter/DashboardFilter.tsx +3 -6
  71. package/lib/infra/DashboardFilter/filterUtils.tsx +3 -4
  72. package/lib/infra/DeferLoad/DeferLoad.tsx +2 -4
  73. package/lib/infra/ErrorBoundary/ErrorBoundary.tsx +1 -3
  74. package/lib/infra/MultiStep/MultiStep.css +48 -70
  75. package/lib/infra/MultiStep/MultiStep.tsx +27 -53
  76. package/lib/infra/NavBar/NavBar.css +1 -1
  77. package/lib/infra/NavBar/NavBar.tsx +43 -32
  78. package/lib/infra/Reference/Reference.tsx +3 -4
  79. package/lib/infra/Region/Region.tsx +1 -1
  80. package/lib/infra/RootContainer/RootContainer.tsx +2 -3
  81. package/lib/infra/Stages/Stages.tsx +3 -4
  82. package/lib/infra/View/View.tsx +4 -3
  83. package/lib/template/AdvancedSearch/AdvancedSearch.tsx +86 -0
  84. package/lib/template/AdvancedSearch/SearchGroup/persistUtils.ts +52 -0
  85. package/lib/template/AdvancedSearch/SearchGroups/SearchGroups.tsx +244 -0
  86. package/lib/template/AdvancedSearch/SearchGroups/hooks.ts +37 -0
  87. package/lib/template/AdvancedSearch/SearchGroups/index.tsx +1 -0
  88. package/lib/template/AdvancedSearch/SearchGroups/utils.ts +29 -0
  89. package/lib/template/AdvancedSearch/TemplateContext.ts +11 -0
  90. package/lib/template/AdvancedSearch/config-ext.json +9 -0
  91. package/lib/template/AdvancedSearch/index.tsx +1 -0
  92. package/lib/template/AppShell/AppShell.css +1 -1
  93. package/lib/template/AppShell/AppShell.tsx +16 -17
  94. package/lib/template/BannerPage/BannerPage.tsx +2 -2
  95. package/lib/template/CaseSummary/CaseSummary.tsx +28 -41
  96. package/lib/template/CaseView/CaseView.tsx +28 -35
  97. package/lib/template/CaseViewActionsMenu/CaseViewActionsMenu.tsx +1 -1
  98. package/lib/template/Confirmation/Confirmation.tsx +2 -3
  99. package/lib/template/DataReference/DataReference.tsx +312 -106
  100. package/lib/template/DataReference/DataReferenceAdvancedSearchContext.ts +10 -0
  101. package/lib/template/DataReference/SearchForm.tsx +149 -0
  102. package/lib/template/DataReference/utils.ts +90 -0
  103. package/lib/template/DefaultForm/DefaultForm.tsx +3 -3
  104. package/lib/template/DefaultForm/utils/index.ts +1 -3
  105. package/lib/template/DefaultPage/DefaultPage.tsx +108 -0
  106. package/lib/template/DefaultPage/index.tsx +1 -0
  107. package/lib/template/Details/Details/Details.tsx +11 -11
  108. package/lib/template/Details/DetailsSubTabs/DetailsSubTabs.tsx +2 -2
  109. package/lib/template/Details/DetailsThreeColumn/DetailsThreeColumn.tsx +11 -11
  110. package/lib/template/Details/DetailsTwoColumn/DetailsTwoColumn.tsx +11 -11
  111. package/lib/template/Details/DynamicTabs/DynamicTabs.tsx +1 -1
  112. package/lib/template/FieldGroupTemplate/FieldGroupTemplate.tsx +2 -3
  113. package/lib/template/InlineDashboard/InlineDashboard.tsx +14 -16
  114. package/lib/template/InlineDashboardPage/InlineDashboardPage.tsx +2 -2
  115. package/lib/template/ListPage/ListPage.tsx +1 -1
  116. package/lib/template/ListView/ListView.tsx +278 -198
  117. package/lib/template/ListView/hooks.ts +1 -5
  118. package/lib/template/ListView/utils.ts +38 -5
  119. package/lib/template/MultiReferenceReadOnly/MultiReferenceReadOnly.tsx +1 -1
  120. package/lib/template/NarrowWide/NarrowWide/NarrowWide.tsx +5 -5
  121. package/lib/template/NarrowWide/NarrowWideDetails/NarrowWideDetails.tsx +11 -11
  122. package/lib/template/NarrowWide/NarrowWideForm/NarrowWideForm.tsx +2 -2
  123. package/lib/template/NarrowWide/NarrowWidePage/NarrowWidePage.tsx +2 -2
  124. package/lib/template/OneColumn/OneColumn/OneColumn.tsx +7 -7
  125. package/lib/template/OneColumn/OneColumnPage/OneColumnPage.tsx +1 -1
  126. package/lib/template/OneColumn/OneColumnTab/OneColumnTab.tsx +2 -2
  127. package/lib/template/PromotedFilters/PromotedFilters.tsx +1 -2
  128. package/lib/template/SelfServiceCaseView/SelfServiceCaseView.tsx +145 -0
  129. package/lib/template/SelfServiceCaseView/index.tsx +1 -0
  130. package/lib/template/SimpleTable/SimpleTable/SimpleTable.tsx +2 -3
  131. package/lib/template/SimpleTable/SimpleTableManual/SimpleTableManual.tsx +36 -33
  132. package/lib/template/SimpleTable/SimpleTableSelect/SimpleTableSelect.tsx +1 -1
  133. package/lib/template/SingleReferenceReadOnly/SingleReferenceReadOnly.tsx +10 -2
  134. package/lib/template/SubTabs/SubTabs.tsx +2 -2
  135. package/lib/template/SubTabs/tabUtils.ts +118 -1
  136. package/lib/template/TwoColumn/TwoColumn/TwoColumn.tsx +9 -10
  137. package/lib/template/TwoColumn/TwoColumnPage/TwoColumnPage.tsx +1 -1
  138. package/lib/template/TwoColumn/TwoColumnTab/TwoColumnTab.tsx +9 -10
  139. package/lib/template/WideNarrow/WideNarrow/WideNarrow.tsx +5 -5
  140. package/lib/template/WideNarrow/WideNarrowDetails/WideNarrowDetails.tsx +11 -11
  141. package/lib/template/WideNarrow/WideNarrowForm/WideNarrowForm.tsx +2 -2
  142. package/lib/template/WideNarrow/WideNarrowPage/WideNarrowPage.tsx +2 -2
  143. package/lib/template/WssNavBar/WssNavBar.css +1 -1
  144. package/lib/template/WssNavBar/WssNavBar.tsx +6 -6
  145. package/lib/template/utils.tsx +58 -0
  146. package/lib/widget/AppAnnouncement/AppAnnouncement.tsx +1 -1
  147. package/lib/widget/Attachment/Attachment.css +6 -8
  148. package/lib/widget/Attachment/Attachment.tsx +303 -225
  149. package/lib/widget/Attachment/Attachment.types.ts +96 -0
  150. package/lib/widget/Attachment/AttachmentUtils.ts +316 -0
  151. package/lib/widget/CaseHistory/CaseHistory.tsx +5 -5
  152. package/lib/widget/FileUtility/ActionButtonsForFileUtil/ActionButtonsForFileUtil.css +0 -14
  153. package/lib/widget/FileUtility/ActionButtonsForFileUtil/ActionButtonsForFileUtil.tsx +3 -3
  154. package/lib/widget/FileUtility/FileUtility/FileUtility.css +7 -6
  155. package/lib/widget/FileUtility/FileUtility/FileUtility.tsx +29 -22
  156. package/lib/widget/Followers/Followers.tsx +2 -4
  157. package/lib/widget/QuickCreate/QuickCreate.tsx +1 -2
  158. package/lib/widget/SummaryItem/SummaryItem.css +9 -11
  159. package/lib/widget/SummaryItem/SummaryItem.tsx +2 -2
  160. package/lib/widget/SummaryList/SummaryList.tsx +1 -1
  161. package/lib/widget/ToDo/ToDo.css +1 -13
  162. package/lib/widget/ToDo/ToDo.tsx +37 -36
  163. package/package.json +1 -1
  164. package/lib/helpers/attachmentHelpers.ts +0 -76
@@ -4,18 +4,26 @@ import { Radio, RadioGroup, FormControl, FormControlLabel, FormLabel, FormHelper
4
4
  import Utils from '@pega/react-sdk-components/lib/components/helpers/utils';
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
  // Can't use RadioButtonProps until getLocaleRuleNameFromKeys is NOT private
10
10
  interface RadioButtonsProps extends PConnFieldProps {
11
11
  // If any, enter additional props that only exist on RadioButtons here
12
12
  inline: boolean;
13
13
  fieldMetadata?: any;
14
+ variant?: string;
15
+ hideFieldLabels?: boolean;
16
+ additionalProps?: any;
17
+ imagePosition?: string;
18
+ imageSize?: string;
19
+ showImageDescription?: boolean;
20
+ datasource?: any;
14
21
  }
15
22
 
16
23
  export default function RadioButtons(props: RadioButtonsProps) {
17
24
  // Get emitted components from map (so we can get any override that may exist)
18
25
  const FieldValueList = getComponentFromMap('FieldValueList');
26
+ const SelectableCard = getComponentFromMap('SelectableCard');
19
27
 
20
28
  const {
21
29
  getPConnect,
@@ -29,7 +37,14 @@ export default function RadioButtons(props: RadioButtonsProps) {
29
37
  inline,
30
38
  displayMode,
31
39
  hideLabel,
32
- fieldMetadata
40
+ fieldMetadata,
41
+ variant,
42
+ hideFieldLabels,
43
+ additionalProps,
44
+ datasource,
45
+ imagePosition,
46
+ imageSize,
47
+ showImageDescription
33
48
  } = props;
34
49
  const [theSelectedButton, setSelectedButton] = useState(value);
35
50
 
@@ -88,6 +103,36 @@ export default function RadioButtons(props: RadioButtonsProps) {
88
103
  thePConn.getValidationApi().validate(event.target.value, ''); // 2nd arg empty string until typedef marked correctly as optional
89
104
  };
90
105
 
106
+ if (variant === 'card') {
107
+ const stateProps = thePConn.getStateProps();
108
+ return (
109
+ <div>
110
+ <h4 style={{ marginTop: 0, marginBottom: 0 }}>{label}</h4>
111
+ <div id='selectable-card' style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(min(200px, 100%), 1fr))', gap: '1rem' }}>
112
+ <SelectableCard
113
+ hideFieldLabels={hideFieldLabels}
114
+ additionalProps={additionalProps}
115
+ getPConnect={getPConnect}
116
+ dataSource={datasource}
117
+ image={{
118
+ imagePosition,
119
+ imageSize,
120
+ showImageDescription,
121
+ imageField: stateProps.image?.split('.').pop(),
122
+ imageDescription: stateProps.imageDescription?.split('.').pop()
123
+ }}
124
+ onChange={handleChange}
125
+ recordKey={stateProps.value?.split('.').pop()}
126
+ cardLabel={stateProps.primaryField?.split('.').pop()}
127
+ radioBtnValue={value}
128
+ type='radio'
129
+ setIsRadioCardSelected={displayMode !== 'DISPLAY_ONLY' ? setSelectedButton : undefined}
130
+ />
131
+ </div>
132
+ </div>
133
+ );
134
+ }
135
+
91
136
  return (
92
137
  <FormControl variant='standard' error={status === 'error'} required={required}>
93
138
  <FormLabel component='legend'>{label}</FormLabel>
@@ -0,0 +1,79 @@
1
+ .tox .tox-toolbar {
2
+ background-color: var(--app-background-color) !important;
3
+ }
4
+
5
+ .tox .tox-toolbar__primary {
6
+ background-color: var(--app-background-color) !important;
7
+ }
8
+
9
+ .tox .tox-toolbar__button {
10
+ color: var(--app-text-color) !important;
11
+ }
12
+
13
+ .tox .tox-toolbar__button--enabled {
14
+ background: var(--app-primary-color) !important;
15
+ color: #fff !important;
16
+ }
17
+
18
+ .tox .tox-dialog {
19
+ background-color: var(--modal-top-color) !important;
20
+ color: var(--app-text-color) !important;
21
+ border: 1px solid var(--modal-border-color) !important;
22
+ padding: 20px !important;
23
+ box-shadow: 0 0 10px 3px var(--modal-box-shadow-color) !important;
24
+ }
25
+
26
+ .tox .tox-dialog__header {
27
+ background-color: var(--modal-top-color) !important;
28
+ color: var(--app-text-color) !important;
29
+ font-weight: 500;
30
+ border-bottom: 1px solid var(--modal-border-color);
31
+ }
32
+
33
+ .tox .tox-dialog__footer {
34
+ background: transparent !important;
35
+ border-top: 1px solid var(--modal-border-color);
36
+ }
37
+
38
+ .tox .tox-dialog-wrap__backdrop {
39
+ background-color: var(--modal-background-color) !important;
40
+ }
41
+
42
+ .tox .tox-dialog__body input,
43
+ .tox .tox-dialog__body textarea,
44
+ .tox .tox-dialog__body select {
45
+ background: initial !important;
46
+ color: var(--app-text-color) !important;
47
+ border: 1px solid var(--app-neutral-color) !important;
48
+ border-radius: 4px !important;
49
+ padding: 6px 10px !important;
50
+ font-size: 1em !important;
51
+ font-family: inherit !important;
52
+ }
53
+
54
+ .tox .tox-dialog__body button {
55
+ background: transparent;
56
+ color: #fff !important;
57
+ border: none !important;
58
+ border-radius: 4px !important;
59
+ padding: 8px 16px !important;
60
+ font-size: 1em !important;
61
+ cursor: pointer !important;
62
+ }
63
+
64
+ .tox .tox-dialog__footer .tox-button {
65
+ background: var(--app-primary-color) !important;
66
+ color: #fff !important;
67
+ border: none !important;
68
+ border-radius: 4px !important;
69
+ padding: 8px 16px !important;
70
+ font-size: 1em !important;
71
+ cursor: pointer !important;
72
+ }
73
+
74
+ .tox .tox-dialog__footer .tox-button--secondary {
75
+ background: var(--app-secondary-color) !important;
76
+ color: var(--secondary-button-text-color) !important;
77
+ font-size: 0.875rem !important;
78
+ cursor: pointer !important;
79
+ }
@@ -2,7 +2,9 @@ import { useRef } from 'react';
2
2
 
3
3
  import handleEvent from '@pega/react-sdk-components/lib/components/helpers/event-utils';
4
4
  import { getComponentFromMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
5
- import { PConnFieldProps } from '@pega/react-sdk-components/lib/types/PConnProps';
5
+ import type { PConnFieldProps } from '@pega/react-sdk-components/lib/types/PConnProps';
6
+
7
+ import './RichText.css';
6
8
 
7
9
  interface RichTextProps extends PConnFieldProps {
8
10
  // If any, enter additional props that only exist on TextArea here
@@ -1,6 +1,5 @@
1
- /* eslint-disable react/no-array-index-key */
2
1
  import { getComponentFromMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
3
- import { PConnProps } from '@pega/react-sdk-components/lib/types/PConnProps';
2
+ import type { PConnProps } from '@pega/react-sdk-components/lib/types/PConnProps';
4
3
 
5
4
  // ScalarListProps can't extend PConnFieldProps because its 'value' has a different type
6
5
  interface ScalarListProps extends PConnProps {
@@ -44,7 +43,7 @@ export default function ScalarList(props: ScalarListProps) {
44
43
  }
45
44
  },
46
45
  '',
47
- // @ts-ignore
46
+ // @ts-expect-error
48
47
  '',
49
48
  {}
50
49
  ); // 2nd, 3rd, and 4th args empty string/object/null until typedef marked correctly as optional;
@@ -0,0 +1,175 @@
1
+ import { Radio, Checkbox, FormControlLabel, Card, CardContent, Typography } from '@mui/material';
2
+ import { resolveReferenceFields } from './utils';
3
+
4
+ export default function SelectableCard(props) {
5
+ const {
6
+ getPConnect,
7
+ type,
8
+ image: { imagePosition, imageSize, showImageDescription, imageField = '', imageDescription = '' },
9
+ dataSource,
10
+ recordKey = '',
11
+ className,
12
+ cardLabel,
13
+ hideFieldLabels = false,
14
+ readOnly,
15
+ disabled,
16
+ readOnlyList = [],
17
+ displayMode,
18
+ radioBtnValue,
19
+ onChange,
20
+ onBlur,
21
+ onClick,
22
+ onKeyDown,
23
+ additionalProps,
24
+ testId,
25
+ setIsRadioCardSelected,
26
+ showNoValue = false
27
+ } = props;
28
+
29
+ const pConn = getPConnect();
30
+
31
+ if (showNoValue) return <Typography>No Value</Typography>;
32
+
33
+ const cardDataSource = readOnly || displayMode === 'DISPLAY_ONLY' ? readOnlyList || [] : dataSource?.source;
34
+ const imageDescriptionKey = showImageDescription ? imageDescription : undefined;
35
+
36
+ let radioItemSelected = false;
37
+
38
+ return (
39
+ <>
40
+ {(cardDataSource || []).map(item => {
41
+ const resolvedFields = resolveReferenceFields(item, hideFieldLabels, recordKey, pConn);
42
+
43
+ const commonProps = {
44
+ id: item[recordKey],
45
+ key: item[recordKey],
46
+ fields: resolvedFields,
47
+ label: item[cardLabel]
48
+ };
49
+
50
+ const image = item[imageField]
51
+ ? {
52
+ src: item[imageField],
53
+ alt: showImageDescription && imageDescriptionKey ? item[imageDescriptionKey] : '',
54
+ style: { width: imageSize, objectPosition: imagePosition }
55
+ }
56
+ : undefined;
57
+
58
+ const cardContent = (
59
+ <Card className={className} style={{ display: 'flex' }} data-testid={testId}>
60
+ {image && <img src={image.src} alt={image.alt} style={{ width: '100px' }} />}
61
+ <CardContent>
62
+ <Typography variant='body1'>{item[cardLabel]}</Typography>
63
+ {commonProps.fields.map((field, index) => (
64
+ <Typography key={index} variant='body2'>
65
+ {field.value}
66
+ </Typography>
67
+ ))}
68
+ </CardContent>
69
+ </Card>
70
+ );
71
+
72
+ if (displayMode === 'DISPLAY_ONLY') {
73
+ return cardContent;
74
+ }
75
+
76
+ const component = (
77
+ <div key={item[recordKey]} style={{ paddingTop: '15px' }}>
78
+ <Card className={className} style={{ display: 'flex', flexDirection: 'column', height: '100%' }} data-testid={testId}>
79
+ <CardContent
80
+ style={{
81
+ ...((imagePosition === 'inline-start' || imagePosition === 'inline-end') && { display: 'flex', height: '100%' }),
82
+ ...(imagePosition === 'inline-end' && { flexDirection: 'row-reverse' })
83
+ }}
84
+ >
85
+ <div
86
+ style={{
87
+ ...((imagePosition === 'inline-start' || imagePosition === 'inline-end') && { width: '40%' })
88
+ }}
89
+ >
90
+ {image && (
91
+ <img
92
+ src={image.src}
93
+ alt={image.alt}
94
+ style={{
95
+ width: '100%',
96
+ backgroundColor: 'transparent',
97
+ aspectRatio: '16 / 9',
98
+ maxHeight: '100%',
99
+ height: '100%',
100
+ objectFit: 'contain',
101
+ maxWidth: '100%'
102
+ }}
103
+ />
104
+ )}
105
+ </div>
106
+ <div
107
+ style={{
108
+ ...((imagePosition === 'inline-start' || imagePosition === 'inline-end') && { width: '60%' })
109
+ }}
110
+ >
111
+ {type === 'radio' ? (
112
+ <FormControlLabel
113
+ control={
114
+ <Radio
115
+ value={item[recordKey]}
116
+ checked={radioBtnValue === item[recordKey]}
117
+ onChange={onChange}
118
+ onBlur={onBlur}
119
+ onClick={onClick}
120
+ onKeyDown={onKeyDown}
121
+ disabled={disabled}
122
+ {...additionalProps}
123
+ />
124
+ }
125
+ label={<Typography variant='body1'>{item[cardLabel]}</Typography>}
126
+ />
127
+ ) : (
128
+ <FormControlLabel
129
+ control={
130
+ <Checkbox
131
+ id={item[recordKey]}
132
+ getPConnect={getPConnect}
133
+ checked={readOnlyList.some(data => data[recordKey] === item[recordKey])}
134
+ onChange={onChange}
135
+ onBlur={onBlur}
136
+ onClick={onClick}
137
+ onKeyDown={onKeyDown}
138
+ disabled={disabled}
139
+ {...additionalProps}
140
+ />
141
+ }
142
+ label={<Typography variant='body1'>{item[cardLabel]}</Typography>}
143
+ />
144
+ )}
145
+
146
+ {commonProps.fields.map((field, index) => (
147
+ <div
148
+ key={index}
149
+ style={{
150
+ fontSize: '0.875rem',
151
+ ...(field.type !== 'TextArea' && { display: 'grid', gridTemplateColumns: '1fr 1fr' }),
152
+ margin: '5px'
153
+ }}
154
+ >
155
+ {field.name && <div>{field.name}</div>}
156
+ <div>{field?.value?.props.value}</div>
157
+ </div>
158
+ ))}
159
+ </div>
160
+ </CardContent>
161
+ </Card>
162
+ </div>
163
+ );
164
+
165
+ if (type === 'radio' && radioBtnValue === item[recordKey]) {
166
+ radioItemSelected = true;
167
+ }
168
+
169
+ return component;
170
+ })}
171
+
172
+ {type === 'radio' && setIsRadioCardSelected && setIsRadioCardSelected(radioItemSelected)}
173
+ </>
174
+ );
175
+ }
@@ -0,0 +1 @@
1
+ export { default } from './SelectableCard';
@@ -0,0 +1,223 @@
1
+ import { Link } from '@mui/material';
2
+
3
+ import { Utils } from '@pega/react-sdk-components/lib/components/helpers/utils';
4
+
5
+ export const resolveReferencedPConnect = pConnect => {
6
+ if (!pConnect || !pConnect.meta) return undefined;
7
+ const type = pConnect?._type ?? undefined;
8
+ const referencedPConnect = type === 'reference' && pConnect.getReferencedViewPConnect().getPConnect();
9
+ return referencedPConnect || pConnect;
10
+ };
11
+
12
+ /**
13
+ * A helper function to create an object consisting react component as per the type.
14
+ * This is used by CaseSummary template.
15
+ * @param {object} pConnectMeta Object containing meta information for the particular field authored
16
+ * @param {Function} getPConnect PConnect function passed along to other components.
17
+ * @param {string} displayMode displayMode string contains information about the layout of component in review mode.
18
+ */
19
+ export function prepareComponentInCaseSummary(pConnectMeta: any, getPConnect: Function) {
20
+ const { config, children } = pConnectMeta;
21
+
22
+ const noValueComponent = <div>No Value</div>;
23
+ const placeholder = '...';
24
+ const pConnect = getPConnect();
25
+
26
+ const caseSummaryComponentObject: any = {};
27
+
28
+ let { type } = pConnectMeta;
29
+ let showAddressLabel = true;
30
+
31
+ if (config && config.value === `@P .${Utils.getMappedKey('pyStatusWork')}`) {
32
+ config.displayAsStatus = true;
33
+ type = 'TextInput'; // force the type to be TextInput for status field.
34
+ // As TextInput is loaded forcefully sometimes, TextInput component might not be available in lazy map.
35
+ // Load TextInput if it is not available.
36
+ if (!PCore.getComponentsRegistry().getLazyComponent(type)) {
37
+ PCore.getAssetLoader().getLoader('component-loader')([type]);
38
+ }
39
+ }
40
+
41
+ caseSummaryComponentObject.name = pConnect.resolveConfigProps({ label: config.label }).label;
42
+
43
+ if (config.inheritedProps) {
44
+ const labelInInheritedProp = config.inheritedProps.find(inheritedProp => inheritedProp.prop === 'label');
45
+ if (labelInInheritedProp) {
46
+ labelInInheritedProp.value = pConnect.resolveConfigProps({ label: labelInInheritedProp.value }).label;
47
+ }
48
+ }
49
+
50
+ switch (type) {
51
+ case 'CaseOperator': {
52
+ if (config.label.includes('Create operator')) {
53
+ caseSummaryComponentObject.name = pConnect.resolveConfigProps({
54
+ createLabel: config.createLabel
55
+ }).createLabel;
56
+ } else if (config.label.includes('Update operator')) {
57
+ caseSummaryComponentObject.name = pConnect.resolveConfigProps({
58
+ updateLabel: config.updateLabel
59
+ }).updateLabel;
60
+ } else {
61
+ caseSummaryComponentObject.name = pConnect.resolveConfigProps({
62
+ resolveLabel: config.resolveLabel
63
+ }).resolveLabel;
64
+ }
65
+
66
+ break;
67
+ }
68
+ case 'Checkbox': {
69
+ caseSummaryComponentObject.name = pConnect.resolveConfigProps({
70
+ label: config.caption
71
+ }).label;
72
+
73
+ break;
74
+ }
75
+ case 'Pega_UI_PercentageWidget': {
76
+ const rawValue = pConnect.resolveConfigProps({
77
+ value: config.value
78
+ }).value;
79
+
80
+ caseSummaryComponentObject.simpleValue = rawValue || rawValue === 0 ? `${rawValue}%` : noValueComponent;
81
+ break;
82
+ }
83
+ case 'Address': {
84
+ showAddressLabel = false;
85
+
86
+ caseSummaryComponentObject.variant = 'stacked';
87
+ break;
88
+ }
89
+ case 'Location':
90
+ case 'RichText': {
91
+ const rawValue = pConnect.resolveConfigProps({
92
+ value: config.value
93
+ }).value;
94
+
95
+ caseSummaryComponentObject.variant = 'stacked';
96
+ caseSummaryComponentObject.simpleValue = rawValue?.length ? rawValue : noValueComponent;
97
+ break;
98
+ }
99
+ case 'TextArea': {
100
+ const rawValue = pConnect.resolveConfigProps({
101
+ value: config.value
102
+ }).value;
103
+
104
+ if (rawValue?.length > 22) {
105
+ caseSummaryComponentObject.variant = 'stacked';
106
+ }
107
+
108
+ caseSummaryComponentObject.simpleValue = rawValue?.length ? rawValue : noValueComponent;
109
+ break;
110
+ }
111
+ case 'URL': {
112
+ if (config.displayAs === 'Image') {
113
+ const rawValue = pConnect.resolveConfigProps({
114
+ value: config.value
115
+ }).value;
116
+
117
+ caseSummaryComponentObject.variant = 'stacked';
118
+ caseSummaryComponentObject.simpleValue = rawValue?.length ? <Link href={rawValue}>{rawValue}</Link> : noValueComponent;
119
+ }
120
+ break;
121
+ }
122
+ case 'reference': {
123
+ const referencedPConnect = resolveReferencedPConnect(pConnect);
124
+ const viewType = referencedPConnect?.meta?.config.type;
125
+ const viewTemplate = referencedPConnect?.meta?.config.template;
126
+ const isTable = ['multirecordlist'].includes(viewType);
127
+ const isDataReference = viewTemplate === 'DataReference';
128
+
129
+ if (isTable || !isDataReference) {
130
+ caseSummaryComponentObject.variant = 'stacked';
131
+ caseSummaryComponentObject.simpleValue = placeholder;
132
+ }
133
+ break;
134
+ }
135
+ case 'view': {
136
+ caseSummaryComponentObject.variant = 'stacked';
137
+ caseSummaryComponentObject.simpleValue = placeholder;
138
+ break;
139
+ }
140
+ default:
141
+ break;
142
+ }
143
+
144
+ const createdComponent = pConnect.createComponent({
145
+ type,
146
+ children: children ? [...children] : [],
147
+ showAddressLabel,
148
+ config: {
149
+ ...config,
150
+ // Need a unique key for each summary component which helps in creating new component based on visibility
151
+ // Also a consistent key helps in rerendering summary components instead of remounting
152
+ key: config
153
+ }
154
+ });
155
+
156
+ createdComponent.props.getPConnect().setInheritedProp('displayMode', 'DISPLAY_ONLY');
157
+ createdComponent.props.getPConnect().setInheritedProp('readOnly', true);
158
+
159
+ if (type === 'Address') {
160
+ createdComponent.props.getPConnect().setInheritedProp('showAddressLabel', showAddressLabel);
161
+ }
162
+ // Add field label for reference summary item when not Embedded data
163
+ if (type === 'reference') {
164
+ const isEmbeddedData = config.context && config.displayAs === 'Form';
165
+ if (!isEmbeddedData) {
166
+ caseSummaryComponentObject.name = createdComponent.props.getPConnect().getInheritedProps().label;
167
+ }
168
+ }
169
+
170
+ caseSummaryComponentObject.value = createdComponent;
171
+
172
+ return caseSummaryComponentObject;
173
+ }
174
+
175
+ export function resolveReferenceFields(
176
+ item: {
177
+ [key: string]: unknown;
178
+ },
179
+ hideFieldLabels: boolean,
180
+ recordKey: string,
181
+ pConnect: typeof PConnect
182
+ ) {
183
+ const presets: {
184
+ children?: {
185
+ children?: {
186
+ config;
187
+ type;
188
+ };
189
+ config?;
190
+ };
191
+ } = (pConnect.getRawMetadata()?.config as any).presets ?? [];
192
+
193
+ const presetChildren = presets[0]?.children?.[0]?.children ?? [];
194
+
195
+ const maxFields = 5;
196
+ return presetChildren.slice(0, maxFields).map((preset, index) => {
197
+ const fieldMeta = {
198
+ meta: {
199
+ ...preset,
200
+ config: {
201
+ ...preset.config,
202
+ displayMode: 'DISPLAY_ONLY',
203
+ contextName: pConnect.getContextName()
204
+ }
205
+ },
206
+ useCustomContext: item
207
+ };
208
+ const configObj = PCore.createPConnect(fieldMeta);
209
+ const meta = configObj.getPConnect().getMetadata();
210
+ const fieldInfo: {
211
+ name?: string;
212
+ value?: React.ReactNode;
213
+ } = meta ? prepareComponentInCaseSummary(meta, configObj.getPConnect) : {};
214
+ return hideFieldLabels
215
+ ? { id: `${item[recordKey]} - ${index}`, value: fieldInfo.value }
216
+ : {
217
+ id: `${item[recordKey]} - ${index}`,
218
+ name: fieldInfo.name,
219
+ value: fieldInfo.value,
220
+ type: preset.type
221
+ };
222
+ });
223
+ }