@pega/react-sdk-overrides 0.25.5 → 0.25.6

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.
@@ -223,7 +223,7 @@ export default function CaseSummaryFields(props: CaseSummaryFieldsProps) {
223
223
 
224
224
  // Whenever theFieldsToRender changes, update theFieldsAsGridItems that's used during render
225
225
  useEffect(() => {
226
- const arGridItems = theFieldsToRender.map((field: any) => {
226
+ const arGridItems = theFieldsToRender?.map((field: any) => {
227
227
  // display the field when either visibility property doesn't exist or is true(if exists)
228
228
  if (field.config.visibility === undefined || field.config.visibility === true) {
229
229
  return (
@@ -108,7 +108,7 @@ export default function RadioButtons(props: RadioButtonsProps) {
108
108
  return (
109
109
  <div>
110
110
  <h4 style={{ marginTop: 0, marginBottom: 0 }}>{label}</h4>
111
- <div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(min(200px, 100%), 1fr))', gap: '1rem' }}>
111
+ <div id='selectable-card' style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(min(200px, 100%), 1fr))', gap: '1rem' }}>
112
112
  <SelectableCard
113
113
  hideFieldLabels={hideFieldLabels}
114
114
  additionalProps={additionalProps}
@@ -2,10 +2,6 @@ import { Link } from '@mui/material';
2
2
 
3
3
  import { Utils } from '@pega/react-sdk-components/lib/components/helpers/utils';
4
4
 
5
- export const getResolvedConstantValue = (pConnect, key) => {
6
- return pConnect.getValue(PCore.getResolvedConstantValue(key)) || pConnect.getValue(key);
7
- };
8
-
9
5
  export const resolveReferencedPConnect = pConnect => {
10
6
  if (!pConnect || !pConnect.meta) return undefined;
11
7
  const type = pConnect?._type ?? undefined;
@@ -202,7 +202,7 @@ export default function SemanticLink(props: SemanticLinkProps) {
202
202
 
203
203
  return (
204
204
  <Link component='button' {...linkComponentProps} {...restProps} onClick={openLinkClick} data-testid={testId}>
205
- {text}
205
+ {text || '--'}
206
206
  </Link>
207
207
  );
208
208
  }
@@ -0,0 +1,6 @@
1
+ const megabyteSize = 1048576;
2
+
3
+ export const validateMaxSize = (fileObj: Record<string, number>, maxSizeInMB: string) => {
4
+ const fileSize = (fileObj.size / megabyteSize).toFixed(2);
5
+ return parseFloat(fileSize) < parseFloat(maxSizeInMB);
6
+ };
@@ -1,10 +1,14 @@
1
1
  import { getLocale } from './common';
2
2
  import CurrencyMap from './CurrencyMap';
3
3
 
4
+ const isValidValue = value => {
5
+ return value !== null && value !== undefined && value !== '';
6
+ };
7
+
4
8
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
5
9
  function NumberFormatter(value, { locale = 'en-US', decPlaces = 2, style = '', currency = 'USD' } = {}): string {
6
10
  const currentLocale: string | undefined = getLocale(locale);
7
- if (value !== null && value !== undefined) {
11
+ if (isValidValue(value)) {
8
12
  return Number(value).toLocaleString(currentLocale, { minimumFractionDigits: decPlaces, maximumFractionDigits: decPlaces });
9
13
  }
10
14
  return value;
@@ -16,7 +20,7 @@ function CurrencyFormatter(
16
20
  ): string {
17
21
  const currentLocale: string | undefined = getLocale(locale);
18
22
  let formattedValue: string = value;
19
- if (value !== null && value !== undefined && value !== '') {
23
+ if (isValidValue(value)) {
20
24
  formattedValue = NumberFormatter(value, { locale: currentLocale, decPlaces, style, currency });
21
25
 
22
26
  // For currency other than EUR, we need to determine the country code from currency code
@@ -55,7 +59,7 @@ function CurrencyFormatter(
55
59
 
56
60
  function SymbolFormatter(value, { symbol = '$', suffix = true, locale = 'en-US' } = {}): string {
57
61
  let formattedValue: string = value;
58
- if (value !== null && value !== undefined) {
62
+ if (isValidValue(value)) {
59
63
  formattedValue = NumberFormatter(value, { locale });
60
64
  return suffix ? `${formattedValue}${symbol}` : `${symbol}${formattedValue}`;
61
65
  }
@@ -68,5 +72,6 @@ export default {
68
72
  Decimal: (value, options) => NumberFormatter(value, options),
69
73
  'Decimal-Auto': (value, options) => NumberFormatter(value, { ...options, decPlaces: Number.isInteger(value) ? 0 : 2 }),
70
74
  Integer: (value, options) => NumberFormatter(value, { ...options, decPlaces: 0 }),
71
- Percentage: (value, options) => SymbolFormatter(value, { ...options, symbol: '%' })
75
+ Percentage: (value, options) => SymbolFormatter(value, { ...options, symbol: '%' }),
76
+ isValidValue
72
77
  };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Returns the value of the key from objectInfo/caseInfo
3
+ * Added fallback to retrieve from caseInfo if objectInfo not present.
4
+ * @param pConnect
5
+ * @param key
6
+ * @returns the value of key
7
+ */
8
+ export const getResolvedConstantValue = (pConnect: typeof PConnect, key: string) => {
9
+ return pConnect.getValue(PCore.getResolvedConstantValue(key)) || pConnect.getValue(key);
10
+ };
@@ -96,6 +96,7 @@ const useStyles = makeStyles(theme => ({
96
96
  marginBottom: theme.spacing(0)
97
97
  },
98
98
  dlgContent: {
99
+ paddingTop: `${theme.spacing(1)} !important`,
99
100
  marginLeft: theme.spacing(2),
100
101
  marginRight: theme.spacing(2),
101
102
  marginTop: theme.spacing(0),
@@ -309,7 +310,7 @@ export default function ModalViewContainer(props: ModalViewContainerProps) {
309
310
 
310
311
  return (
311
312
  <>
312
- <Dialog open={bShowModal} aria-labelledby='form-dialog-title'>
313
+ <Dialog open={bShowModal} aria-labelledby='form-dialog-title' maxWidth={false}>
313
314
  <DialogTitle id='form-dialog-title' className={`${classes.dlgTitle} psdk-dialog-title`}>
314
315
  {title}
315
316
  </DialogTitle>
@@ -158,14 +158,12 @@ mat-horizontal-stepper {
158
158
  }
159
159
 
160
160
  .psdk-horizontal-step-header {
161
- overflow: hidden;
162
161
  outline: none;
163
162
  cursor: pointer;
164
163
  position: relative;
165
164
  box-sizing: content-box;
166
165
  display: flex;
167
166
  height: 72px;
168
- overflow: hidden;
169
167
  align-items: center;
170
168
  }
171
169
 
@@ -112,6 +112,11 @@ export default function AppShell(props: PropsWithChildren<AppShellProps>) {
112
112
  });
113
113
 
114
114
  setMapChildren(tempMap);
115
+
116
+ /* TODO: We're setting the `pyPortalTemplate` for now, this would be handled by the CoreJS in the future releases */
117
+ if (portalTemplate === 'wss') {
118
+ PCore.getEnvironmentInfo().setEnvironmentInfo({ ...PCore.getEnvironmentInfo().environmentInfoObject, pyPortalTemplate: 'wss' } as any);
119
+ }
115
120
  }, []);
116
121
 
117
122
  useEffect(() => {
@@ -1,22 +1,83 @@
1
- import type { PropsWithChildren } from 'react';
1
+ import type { PropsWithChildren, ReactElement } from 'react';
2
2
  import { getComponentFromMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
3
3
  import type { PConnProps } from '@pega/react-sdk-components/lib/types/PConnProps';
4
4
 
5
5
  interface CaseSummaryProps extends PConnProps {
6
- // If any, enter additional props that only exist on this component
7
6
  arPrimaryFields: any[];
8
7
  arSecondaryFields: any[];
8
+ // If any, enter additional props that only exist on this component
9
9
  }
10
10
 
11
11
  export default function CaseSummary(props: PropsWithChildren<CaseSummaryProps>) {
12
12
  // Get emitted components from map (so we can get any override that may exist)
13
13
  const CaseSummaryFields = getComponentFromMap('CaseSummaryFields');
14
14
 
15
- const { arPrimaryFields, arSecondaryFields } = props;
15
+ const { getPConnect, children } = props;
16
+ let { arPrimaryFields = [], arSecondaryFields = [] } = props;
17
+
18
+ const thePConn = getPConnect && getPConnect();
19
+ const theConfigProps: any = thePConn?.getConfigProps();
20
+
21
+ const status = theConfigProps?.status;
22
+ const showStatus = theConfigProps?.showStatus;
23
+ const localizedVal = PCore.getLocaleUtils().getLocaleValue;
24
+ const localeCategory = 'ModalContainer';
25
+
26
+ function prepareComponentInCaseSummary(pConnectMeta, getPConnect) {
27
+ const { config, children } = pConnectMeta;
28
+ const pConnect = getPConnect();
29
+
30
+ const caseSummaryComponentObject: any = {};
31
+
32
+ const { type } = pConnectMeta;
33
+ const createdComponent = pConnect.createComponent({
34
+ type,
35
+ children: children ? [...children] : [],
36
+ config: {
37
+ ...config
38
+ }
39
+ });
40
+
41
+ caseSummaryComponentObject.value = createdComponent;
42
+ return caseSummaryComponentObject;
43
+ }
44
+
45
+ function prepareCaseSummaryData(summaryFieldChildren) {
46
+ const convertChildrenToSummaryData = kid => {
47
+ return kid?.map((childItem, index) => {
48
+ const childMeta = childItem.getPConnect().meta;
49
+ const caseSummaryComponentObject = prepareComponentInCaseSummary(childMeta, childItem.getPConnect);
50
+ caseSummaryComponentObject.id = index + 1;
51
+ return caseSummaryComponentObject;
52
+ });
53
+ };
54
+ return summaryFieldChildren ? convertChildrenToSummaryData(summaryFieldChildren?.getChildren()) : undefined;
55
+ }
56
+
57
+ if (arPrimaryFields.length === 0 && arSecondaryFields.length === 0) {
58
+ for (const child of children as ReactElement[]) {
59
+ const childPConn = (child as ReactElement).props.getPConnect();
60
+ const childPConnData = childPConn.resolveConfigProps(childPConn.getRawMetadata());
61
+ if (childPConnData.name.toLowerCase() === 'primary fields') {
62
+ arPrimaryFields = childPConnData.children;
63
+ arPrimaryFields.forEach(field => {
64
+ if (field.config?.value && typeof field.config?.value === 'string') {
65
+ field.config.value = localizedVal(field.config.value, localeCategory);
66
+ }
67
+ });
68
+ } else if (childPConnData.name.toLowerCase() === 'secondary fields') {
69
+ const secondarySummaryFields = prepareCaseSummaryData(childPConn);
70
+ arSecondaryFields = childPConnData.children;
71
+ arSecondaryFields.forEach((field, index) => {
72
+ field.config.displayLabel = secondarySummaryFields[index]?.value?.props?.label;
73
+ });
74
+ }
75
+ }
76
+ }
16
77
 
17
78
  return (
18
79
  <div id='CaseSummary'>
19
- <CaseSummaryFields theFields={arPrimaryFields} />
80
+ <CaseSummaryFields status={status} showStatus={showStatus} theFields={arPrimaryFields} />
20
81
  <CaseSummaryFields theFields={arSecondaryFields} />
21
82
  </div>
22
83
  );
@@ -1,3 +1,4 @@
1
+ import { FormControl, FormLabel } from '@mui/material';
1
2
  import type { PConnProps } from '@pega/react-sdk-components/lib/types/PConnProps';
2
3
 
3
4
  interface SingleReferenceReadOnlyProps extends PConnProps {
@@ -59,5 +60,12 @@ export default function SingleReferenceReadOnly(props: SingleReferenceReadOnlyPr
59
60
  {}
60
61
  ); // 2nd, 3rd, and 4th args empty string/object/null until typedef marked correctly as optional
61
62
 
62
- return <>{component}</>;
63
+ return (
64
+ <>
65
+ <FormControl variant='standard' sx={{ display: 'flex', flexDirection: 'row' }}>
66
+ <FormLabel sx={{ marginRight: '2rem' }}>{label}</FormLabel>
67
+ {component}
68
+ </FormControl>
69
+ </>
70
+ );
63
71
  }