@pega/react-sdk-overrides 0.23.13 → 0.23.15

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>
@@ -3,6 +3,7 @@ import { KeyboardDateTimePicker } from '@material-ui/pickers';
3
3
  import TextInput from '@pega/react-sdk-components/lib/components/field/TextInput';
4
4
  import handleEvent from '@pega/react-sdk-components/lib/components/helpers/event-utils';
5
5
  import FieldValueList from '@pega/react-sdk-components/lib/components/designSystemExtension/FieldValueList';
6
+ import { format } from '@pega/react-sdk-components/lib/components/helpers/formatters/';
6
7
 
7
8
  export default function DateTime(props) {
8
9
  const {
@@ -25,13 +26,16 @@ export default function DateTime(props) {
25
26
  const helperTextToDisplay = validatemessage || helperText;
26
27
 
27
28
  if(displayMode === 'LABELS_LEFT'){
29
+ const formattedDate = format(props.value, 'datetime');
28
30
  const field = {
29
- [label]: value
31
+ [label]: formattedDate
30
32
  };
31
33
  return <FieldValueList item={field}/>
32
34
  }
33
35
 
34
36
  if (readOnly) {
37
+ const formattedDate = format(props.value, 'datetime');
38
+ props.value = formattedDate;
35
39
  return <TextInput {...props} />;
36
40
  }
37
41
 
@@ -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
  };
@@ -1,4 +1,4 @@
1
- import { Utils } from '@pega/react-sdk-components/lib/components/helpers/utils';
1
+ import { Utils } from './utils';
2
2
 
3
3
  declare const PCore;
4
4
 
@@ -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
 
@@ -35,7 +35,7 @@ import IconButton from '@material-ui/core/IconButton';
35
35
  import CloseIcon from '@material-ui/icons/Close';
36
36
  import { Radio } from '@material-ui/core';
37
37
  import Checkbox from '@material-ui/core/Checkbox';
38
- import { filterData } from '@pega/react-sdk-components/lib/components/template/SimpleTable/SimpleTable/simpleTableHelpers';
38
+ import { filterData } from '@pega/react-sdk-components/lib/components/helpers/simpleTableHelpers';
39
39
  import './ListView.css';
40
40
 
41
41
  const SELECTION_MODE = { SINGLE: 'single', MULTI: 'multi' };
@@ -8,7 +8,7 @@ import TableHead from '@material-ui/core/TableHead';
8
8
  import TableRow from '@material-ui/core/TableRow';
9
9
  import Paper from '@material-ui/core/Paper';
10
10
  import { makeStyles } from '@material-ui/core/styles';
11
- import { buildFieldsForTable, filterData } from '@pega/react-sdk-components/lib/components/template/SimpleTable/simpleTableHelpers';
11
+ import { buildFieldsForTable, filterData } from '@pega/react-sdk-components/lib/components/helpers/simpleTableHelpers';
12
12
  import { getDataPage } from '@pega/react-sdk-components/lib/components/helpers/data_page';
13
13
  import Link from '@material-ui/core/Link';
14
14
  import { getReferenceList } from '@pega/react-sdk-components/lib/components/helpers/field-group-utils';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/react-sdk-overrides",
3
- "version": "0.23.13",
3
+ "version": "0.23.15",
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": [