@pega/react-sdk-overrides 0.23.14 → 0.23.16

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.
@@ -1,18 +1,6 @@
1
1
  import React from 'react';
2
2
  import Grid from '@material-ui/core/Grid';
3
- import Typography from '@material-ui/core/Typography';
4
3
  import { makeStyles } from '@material-ui/core/styles';
5
- import Utils from '@pega/react-sdk-components/lib/components/helpers/utils';
6
-
7
- function generateFields(item, fields) {
8
- for (const label in item) {
9
- if (Utils.isObject(item[label])) {
10
- generateFields(item[label], fields);
11
- } else if (label !== 'classID') {
12
- fields.push({ label, value: item[label] });
13
- }
14
- }
15
- }
16
4
 
17
5
  const useStyles = makeStyles(theme => ({
18
6
  root: {
@@ -27,83 +15,31 @@ const useStyles = makeStyles(theme => ({
27
15
  marginTop: theme.spacing(1),
28
16
  marginBottom: theme.spacing(1)
29
17
  },
30
- fieldLabel: {
31
- fontWeight: 400,
32
- color: theme.palette.text.secondary
33
- },
34
- fieldValue: {
35
- fontWeight: 400,
36
- color: theme.palette.text.primary
18
+ fullWidth: {
19
+ width: '100%'
37
20
  }
38
21
  }));
39
22
 
40
23
  const FieldGroup = props => {
24
+ const { children, name } = props;
41
25
  const classes = useStyles();
42
26
 
43
- const fields: any = [];
44
- generateFields(props.item, fields);
45
-
46
- function getGridItemLabel(label) {
47
- const dispValue = label;
48
-
49
- return (
50
- <Grid item xs={6}>
51
- <Typography
52
- variant='body2'
53
- component='span'
54
- className={`${classes.fieldLabel} ${classes.fieldMargin}`}
55
- >
56
- {dispValue}
57
- </Typography>
58
- </Grid>
59
- );
60
- }
61
-
62
- function formatItemValue(value) {
63
- let formattedVal = value;
64
-
65
- // if the value is an empty string, we want to display it as "---"
66
- if (formattedVal === '') {
67
- formattedVal = '---';
68
- }
69
-
70
- return formattedVal;
71
- }
72
-
73
- function getGridItemValue(value) {
74
- const formattedValue = formatItemValue(value);
75
-
76
- return (
77
- <Grid item xs={6}>
78
- <Typography variant='body2' component='span' className={classes.fieldValue}>
79
- {formattedValue}
80
- </Typography>
81
- </Grid>
82
- );
83
- }
84
-
85
- function getGridItems() {
86
- const gridItems = fields.map((item) => {
87
- return (
88
- <Grid key={`${item.label}-${item.value}`} container spacing={1}>
89
- {getGridItemLabel(item.label)}
90
- {getGridItemValue(item.value)}
91
- </Grid>
92
- );
93
- });
94
- return gridItems;
95
- }
27
+ const descAndChildren = (
28
+ <Grid container>
29
+ <div className={classes.fullWidth}>{children}</div>
30
+ </Grid>
31
+ );
96
32
 
97
33
  return (
98
34
  <React.Fragment>
99
35
  <Grid container spacing={4} justifyContent='space-between'>
100
36
  <Grid item style={{ width: '100%' }}>
101
- {fields.length > 0 && (
37
+ {name && (
102
38
  <div className={classes.fieldMargin}>
103
39
  <b>{props.name}</b>
104
40
  </div>
105
41
  )}
106
- {getGridItems()}
42
+ {descAndChildren}
107
43
  </Grid>
108
44
  </Grid>
109
45
  </React.Fragment>
@@ -50,11 +50,11 @@ export default function AutoComplete(props) {
50
50
  deferDatasource,
51
51
  datasourceMetadata,
52
52
  status,
53
- helperText
53
+ helperText,
54
+ onRecordChange
54
55
  } = props;
55
- let parameters = datasourceMetadata?.datasource?.parameters;
56
56
  const context = getPConnect().getContextName();
57
- let { listType, datasource = [], columns = [] } = props;
57
+ let { listType, parameters, datasource = [], columns = [] } = props;
58
58
  const [inputValue, setInputValue] = useState('');
59
59
  const [options, setOptions] = useState<Array<IOption>>([]);
60
60
  const [theDatasource, setDatasource] = useState(null);
@@ -85,7 +85,7 @@ export default function AutoComplete(props) {
85
85
  if (deferDatasource && datasourceMetadata?.datasource?.name) {
86
86
  listType = 'datapage';
87
87
  datasource = datasourceMetadata.datasource.name;
88
- parameters = flattenParameters(parameters);
88
+ parameters = flattenParameters(datasourceMetadata?.datasource?.parameters);
89
89
  const displayProp = datasourceMetadata.datasource.propertyForDisplayText.startsWith('@P')
90
90
  ? datasourceMetadata.datasource.propertyForDisplayText.substring(3)
91
91
  : datasourceMetadata.datasource.propertyForDisplayText;
@@ -151,6 +151,9 @@ export default function AutoComplete(props) {
151
151
  const handleChange = (event: object, newValue) => {
152
152
  const val = newValue ? newValue.key : '';
153
153
  handleEvent(actionsApi, 'changeNblur', propName, val);
154
+ if (onRecordChange) {
155
+ onRecordChange(event);
156
+ }
154
157
  };
155
158
 
156
159
  const handleInputValue = (event, newInputValue) => {
@@ -24,7 +24,8 @@ export default function Dropdown(props) {
24
24
  readOnly,
25
25
  testId,
26
26
  helperText,
27
- displayMode
27
+ displayMode,
28
+ onRecordChange
28
29
  } = props;
29
30
  const [options, setOptions] = useState<Array<IOption>>([]);
30
31
  const helperTextToDisplay = validatemessage || helperText;
@@ -61,6 +62,9 @@ export default function Dropdown(props) {
61
62
  const handleChange = evt => {
62
63
  const selectedValue = evt.target.value === 'Select' ? '' : evt.target.value;
63
64
  handleEvent(actionsApi, 'changeNblur', propName, selectedValue);
65
+ if (onRecordChange) {
66
+ onRecordChange(evt);
67
+ }
64
68
  };
65
69
 
66
70
  // Material UI shows a warning if the component is rendered before options are set.
@@ -17,8 +17,6 @@ export const getReferenceList = pConn => {
17
17
  } else if (resolvePage.startsWith('D_') && !resolvePage.endsWith('.pxResults')) {
18
18
  resolvePage = `${resolvePage}.pxResults`;
19
19
  }
20
- } else {
21
- resolvePage = `${pConn.getPageReference().replace('caseInfo.content', '')}${resolvePage}`;
22
20
  }
23
21
  return resolvePage;
24
22
  };
@@ -104,7 +104,7 @@ export default function View(props) {
104
104
 
105
105
  return (
106
106
  <div className='grid-column'>
107
- {showLabel && template !== 'SubTabs' && template !== 'SimpleTable' && (
107
+ {showLabel && template !== 'SubTabs' && template !== 'SimpleTable' && template !== 'Details' && (
108
108
  <div className='template-title-container'>
109
109
  <span>{label}</span>
110
110
  </div>
@@ -1,12 +1,15 @@
1
- import React from "react";
2
- // import PropTypes from "prop-types";
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
3
  import Grid from '@material-ui/core/Grid';
4
4
  import DetailsFields from '@pega/react-sdk-components/lib/components/designSystemExtension/DetailsFields';
5
5
 
6
6
  export default function Details(props) {
7
- const { children } = props;
7
+ const { children, label, showLabel, getPConnect } = props;
8
8
  const arFields: Array<any> = [];
9
9
 
10
+ // Get the inherited props from the parent to determine label settings
11
+ const propsToUse = { label, showLabel, ...getPConnect().getInheritedProps() };
12
+
10
13
  for (const child of children) {
11
14
  const theChildPConn = child.props.getPConnect();
12
15
  theChildPConn.setInheritedProp('displayMode', 'LABELS_LEFT');
@@ -16,20 +19,28 @@ export default function Details(props) {
16
19
  }
17
20
 
18
21
  return (
19
- <div id="DetailsOneColumn">
20
- <Grid container spacing={1}>
21
- <Grid item xs={12}>
22
- <DetailsFields fields={arFields[0]} />
23
- </Grid>
22
+ <div id='DetailsOneColumn'>
23
+ {propsToUse.showLabel && (
24
+ <div className='template-title-container'>
25
+ <span>{propsToUse.label}</span>
26
+ </div>
27
+ )}
28
+ <Grid container spacing={1}>
29
+ <Grid item xs={12}>
30
+ <DetailsFields fields={arFields[0]} />
24
31
  </Grid>
25
- </div>
26
- );
32
+ </Grid>
33
+ </div>
34
+ );
27
35
  }
28
36
 
29
37
  Details.defaultProps = {
30
- // children: []
31
- }
38
+ label: undefined,
39
+ showLabel: true
40
+ };
32
41
 
33
42
  Details.propTypes = {
34
- // children: PropTypes.arrayOf(PropTypes.node)
43
+ showLabel: PropTypes.bool,
44
+ label: PropTypes.string,
45
+ getPConnect: PropTypes.func.isRequired
35
46
  };
@@ -80,8 +80,12 @@ export default function FieldGroupTemplate(props) {
80
80
  pConn.setInheritedProp('displayMode', 'LABELS_LEFT');
81
81
  const memoisedReadOnlyList = useMemo(() => {
82
82
  return referenceList.map((item, index) => (
83
- // eslint-disable-next-line react/no-array-index-key
84
- <FieldGroup item={item} key={index} name={`${HEADING} ${index + 1}`} />
83
+ <FieldGroup
84
+ key={item[heading]}
85
+ name={fieldHeader === 'propertyRef' ? getDynamicHeaderProp(item, index) : `${HEADING} ${index + 1}`}
86
+ >
87
+ {buildView(pConn, index, lookForChildInConfig)}
88
+ </FieldGroup>
85
89
  ));
86
90
  }, []);
87
91
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/react-sdk-overrides",
3
- "version": "0.23.14",
3
+ "version": "0.23.16",
4
4
  "description": "React SDK - Code for overriding components",
5
5
  "_filesComment": "During packing, npm ignores everything NOT in the files list",
6
6
  "files": [