@pega/react-sdk-overrides 0.23.7 → 0.23.9

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 (32) hide show
  1. package/lib/designSystemExtensions/DetailsFields/DetailsFields.tsx +15 -21
  2. package/lib/designSystemExtensions/FieldGroupList/FieldGroupList.tsx +19 -15
  3. package/lib/forms/AutoComplete/AutoComplete.tsx +8 -2
  4. package/lib/forms/AutoComplete/config-ext.json +11 -0
  5. package/lib/forms/Checkbox/config-ext.json +10 -0
  6. package/lib/forms/Currency/config-ext.json +10 -0
  7. package/lib/forms/Date/config-ext.json +10 -0
  8. package/lib/helpers/reactContextHelpers.js +10 -0
  9. package/lib/infra/Assignment/Assignment.tsx +6 -4
  10. package/lib/infra/Attachment/Attachment.tsx +38 -3
  11. package/lib/infra/Containers/ModalViewContainer/ModalViewContainer.tsx +1 -1
  12. package/lib/infra/NavBar/NavBar.tsx +1 -1
  13. package/lib/infra/VerticalTabs/{LeftAlignVerticalTab.tsx → LeftAlignVerticalTabs/LeftAlignVerticalTabs.tsx} +2 -2
  14. package/lib/infra/VerticalTabs/LeftAlignVerticalTabs/index.tsx +1 -0
  15. package/lib/infra/VerticalTabs/{VerticalTabs.tsx → VerticalTabs/VerticalTabs.tsx} +1 -1
  16. package/lib/infra/VerticalTabs/{index.tsx → VerticalTabs/index.tsx} +0 -0
  17. package/lib/templates/AppShell/AppShell.tsx +3 -4
  18. package/lib/templates/AppShell/index.tsx +1 -1
  19. package/lib/templates/CaseView/CaseView.tsx +2 -2
  20. package/lib/templates/{CaseView → CaseViewActionsMenu}/CaseViewActionsMenu.tsx +1 -1
  21. package/lib/templates/CaseViewActionsMenu/index.tsx +1 -0
  22. package/lib/templates/FieldGroupTemplate/FieldGroupTemplate.tsx +5 -4
  23. package/lib/templates/SimpleTable/SimpleTableManual/SimpleTableManual.tsx +3 -1
  24. package/lib/widgets/FileUtility/{ActionButtonsForFileUtil.css → ActionButtonsForFileUtil/ActionButtonsForFileUtil.css} +0 -0
  25. package/lib/widgets/FileUtility/{ActionButtonsForFileUtil.tsx → ActionButtonsForFileUtil/ActionButtonsForFileUtil.tsx} +0 -0
  26. package/lib/widgets/FileUtility/ActionButtonsForFileUtil/index.tsx +1 -0
  27. package/lib/widgets/FileUtility/{FileUtility.css → FileUtility/FileUtility.css} +0 -0
  28. package/lib/widgets/FileUtility/{FileUtility.tsx → FileUtility/FileUtility.tsx} +1 -1
  29. package/lib/widgets/FileUtility/FileUtility/index.tsx +1 -0
  30. package/lib/widgets/SummaryItem/SummaryItem.tsx +1 -1
  31. package/package.json +1 -1
  32. package/lib/widgets/FileUtility/index.tsx +0 -0
@@ -40,26 +40,21 @@ export default function DetailsFields(props) {
40
40
  fields?.forEach((field, index) => {
41
41
  const thePConn = field.getPConnect();
42
42
  const theCompType = thePConn.getComponentName().toLowerCase();
43
- const { label, value } = thePConn.getConfigProps();
44
- // If value is "" then also we would have to get viewMetadata using getReferencedView.
45
- if (theCompType === 'reference' || value === '') {
46
- const configObj = thePConn?.getReferencedView();
47
- configObj.config.readOnly = theCompType === 'reference';
48
- configObj.config.displayMode = 'LABELS_LEFT';
49
- const propToUse = { ...thePConn.getInheritedProps() };
50
- configObj.config.label = theCompType === 'reference' ? propToUse?.label : label;
51
- fieldComponents.push({
52
- type: theCompType,
53
- label,
54
- value: (
55
- <React.Fragment key={index}>
56
- {createElement(createPConnectComponent(), thePConn.getReferencedViewPConnect())}
57
- </React.Fragment>
58
- )
59
- });
60
- } else {
61
- fieldComponents.push({ type: theCompType, value, label });
62
- }
43
+ const { label } = thePConn.getConfigProps();
44
+ const configObj = thePConn?.getReferencedView();
45
+ configObj.config.readOnly = theCompType === 'reference';
46
+ configObj.config.displayMode = 'LABELS_LEFT';
47
+ const propToUse = { ...thePConn.getInheritedProps() };
48
+ configObj.config.label = theCompType === 'reference' ? propToUse?.label : label;
49
+ fieldComponents.push({
50
+ type: theCompType,
51
+ label,
52
+ value: (
53
+ <React.Fragment key={index}>
54
+ {createElement(createPConnectComponent(), thePConn.getReferencedViewPConnect())}
55
+ </React.Fragment>
56
+ )
57
+ });
63
58
  });
64
59
 
65
60
  function getGridItemLabel(field: any, keyVal: string) {
@@ -110,7 +105,6 @@ export default function DetailsFields(props) {
110
105
  }
111
106
 
112
107
  function getGridItem(field: any, keyVal: string) {
113
-
114
108
  return (
115
109
  <Grid item xs={12} key={keyVal}>
116
110
  <Typography variant='body2' component='span' className={classes.fieldValue}>
@@ -24,26 +24,30 @@ const FieldGroupList = props => {
24
24
  {props.items.map(item => (
25
25
  <Grid item style={{ width: '100%' }}>
26
26
  <b>{item.name}</b>
27
- <button
28
- type='button'
29
- style={{ float: 'right' }}
30
- className='psdk-utility-button'
31
- id={`delete-row-${Utils.getLastChar(item.name)}`}
32
- onClick={() => {
33
- props.onDelete(item.id);
34
- }}
35
- >
36
- <img className='psdk-utility-card-action-svg-icon' src={menuIconOverride$}></img>
37
- </button>
27
+ {props.onDelete && (
28
+ <button
29
+ type='button'
30
+ style={{ float: 'right' }}
31
+ className='psdk-utility-button'
32
+ id={`delete-row-${Utils.getLastChar(item.name)}`}
33
+ onClick={() => {
34
+ props.onDelete(item.id);
35
+ }}
36
+ >
37
+ <img className='psdk-utility-card-action-svg-icon' src={menuIconOverride$}></img>
38
+ </button>
39
+ )}
38
40
  {item.children}
39
41
  <br />
40
- <Divider />
42
+ {props.onAdd && <Divider />}
41
43
  <br />
42
44
  </Grid>
43
45
  ))}
44
- <Link onClick={props.onAdd} style={{ cursor: 'pointer' }}>
45
- +Add
46
- </Link>
46
+ {props.onAdd && (
47
+ <Link onClick={props.onAdd} style={{ cursor: 'pointer' }}>
48
+ +Add
49
+ </Link>
50
+ )}
47
51
  </Grid>
48
52
  </Grid>
49
53
  </Grid>
@@ -5,6 +5,7 @@ import Utils from '@pega/react-sdk-components/lib/components/helpers/utils';
5
5
  import TextInput from '@pega/react-sdk-components/lib/components/forms/TextInput';
6
6
  import isDeepEqual from 'fast-deep-equal/react';
7
7
  import { getDataPage } from '@pega/react-sdk-components/lib/components/helpers/data_page';
8
+ import handleEvent from '@pega/react-sdk-components/lib/components/helpers/event-utils';
8
9
 
9
10
  interface IOption {
10
11
  key: string;
@@ -42,7 +43,6 @@ export default function AutoComplete(props) {
42
43
  placeholder,
43
44
  value = '',
44
45
  validatemessage,
45
- onChange,
46
46
  readOnly,
47
47
  testId,
48
48
  displayMode,
@@ -60,6 +60,11 @@ export default function AutoComplete(props) {
60
60
  let selectedValue: any = '';
61
61
  const helperTextToDisplay = validatemessage || helperText;
62
62
 
63
+ const thePConn = getPConnect();
64
+ const actionsApi = thePConn.getActionsApi();
65
+ const propName = thePConn.getStateProps().value;
66
+
67
+
63
68
  if (!isDeepEqual(datasource, theDatasource)) {
64
69
  // inbound datasource is different, so update theDatasource (to trigger useEffect)
65
70
  setDatasource(datasource);
@@ -137,7 +142,8 @@ export default function AutoComplete(props) {
137
142
  }
138
143
 
139
144
  const handleChange = (event: object, newValue) => {
140
- onChange({ value: newValue ? newValue.key : '' });
145
+ const val = newValue ? newValue.key : '' ;
146
+ handleEvent(actionsApi, 'changeNblur', propName, val);
141
147
  };
142
148
 
143
149
  const handleInputValue = (event, newInputValue) => {
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "AutoComplete",
3
+ "label": "Search box",
4
+ "description": "Picklist",
5
+ "type": "Field",
6
+ "subtype": "Picklist",
7
+ "componentKey" : "AutoComplete",
8
+ "icon": "",
9
+ "properties": [
10
+ ]
11
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "Checkbox",
3
+ "label": "Checkbox",
4
+ "description": "Boolean",
5
+ "type": "Field",
6
+ "subtype": "Boolean",
7
+ "componentKey" : "Checkbox",
8
+ "properties": [
9
+ ]
10
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "Currency",
3
+ "label": "Currency",
4
+ "description": "Currency",
5
+ "type": "Field",
6
+ "subtype": "Decimal-Currency",
7
+ "componentKey" : "Currency",
8
+ "properties": [
9
+ ]
10
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "Date",
3
+ "label": "Date only",
4
+ "description": "Date only",
5
+ "type": "Field",
6
+ "subtype": "Date",
7
+ "componentKey" : "Date",
8
+ "properties": [
9
+ ]
10
+ }
@@ -0,0 +1,10 @@
1
+ import { createContext, useContext } from "react";
2
+
3
+ // This file contains a shared access point for any React contexts that may need to be
4
+ // defined/used across various components.
5
+
6
+ // For example, the AppShell wants to use a NavContext that interacts with
7
+ // that context's consumption in the NavBar to handle clicks for opening/closing
8
+ // aspects of the NavBar
9
+ export const NavContext = createContext({open: false, setOpen: f => f});
10
+ export const useNavBar = () => useContext(NavContext);
@@ -10,7 +10,7 @@ import CloseIcon from '@material-ui/icons/Close';
10
10
  declare const PCore: any;
11
11
 
12
12
  export default function Assignment(props) {
13
- const { getPConnect, children, itemKey, isCreateStage } = props;
13
+ const { getPConnect, children, itemKey, isInModal } = props;
14
14
  const thePConn = getPConnect();
15
15
 
16
16
  const [bHasNavigation, setHasNavigation] = useState(false);
@@ -164,7 +164,9 @@ export default function Assignment(props) {
164
164
  // check if create stage (modal)
165
165
  const { PUB_SUB_EVENTS } = PCore.getConstants();
166
166
  const { publish } = PCore.getPubSubUtils();
167
- if (isCreateStage) {
167
+ const isAssignmentInCreateStage = thePConn.getCaseInfo().isAssignmentInCreateStage();
168
+ const isLocalAction = thePConn.getCaseInfo().isLocalAction() || getPConnect().getValue(PCore.getConstants().CASE_INFO.IS_LOCAL_ACTION);
169
+ if (isAssignmentInCreateStage && isInModal && !isLocalAction) {
168
170
  const cancelPromise = cancelCreateStageAssignment(itemKey);
169
171
 
170
172
  cancelPromise
@@ -289,13 +291,13 @@ Assignment.propTypes = {
289
291
  children: PropTypes.node.isRequired,
290
292
  getPConnect: PropTypes.func.isRequired,
291
293
  itemKey: PropTypes.string,
292
- isCreateStage: PropTypes.bool
294
+ isInModal: PropTypes.bool
293
295
  // actionButtons: PropTypes.object
294
296
  // buildName: PropTypes.string
295
297
  };
296
298
 
297
299
  Assignment.defaultProps = {
298
300
  itemKey: null,
299
- isCreateStage: false
301
+ isInModal: false
300
302
  // buildName: null
301
303
  };
@@ -133,12 +133,13 @@ export default function Attachment(props) {
133
133
  },
134
134
  primary: {
135
135
  type: att.type,
136
- name: att.name,
136
+ name: att.error ? att.fileName : att.name,
137
137
  icon: "trash",
138
138
  click: removeFile,
139
139
  },
140
140
  secondary: {
141
- text: att.meta
141
+ text: att.meta,
142
+ error: att.error
142
143
  },
143
144
  actions
144
145
  };
@@ -158,7 +159,41 @@ export default function Attachment(props) {
158
159
 
159
160
  const onUploadProgress = () => {};
160
161
 
161
- const errorHandler = () => {};
162
+ const errorHandler = (isFetchCanceled) => {
163
+ return (error) => {
164
+ if (!isFetchCanceled(error)) {
165
+ let uploadFailMsg = pConn.getLocalizedValue('Something went wrong');
166
+ if (error.response && error.response.data && error.response.data.errorDetails) {
167
+ uploadFailMsg = pConn.getLocalizedValue(error.response.data.errorDetails[0].localizedValue);
168
+ }
169
+ myFiles[0].meta = uploadFailMsg;
170
+ myFiles[0].error = true;
171
+ myFiles[0].fileName = pConn.getLocalizedValue('Unable to upload file');
172
+ arFileList$ = myFiles.map((att) => {
173
+ return getNewListUtilityItemProps({
174
+ att,
175
+ downloadFile: null,
176
+ cancelFile: null,
177
+ deleteFile: null,
178
+ removeFile: null
179
+ });
180
+ });
181
+ setFile((current) => {
182
+ return {
183
+ ...current,
184
+ props: {
185
+ ...current.props,
186
+ arFileList$
187
+ },
188
+ inProgress: false,
189
+ attachmentUploaded: true,
190
+ showMenuIcon: false
191
+ };
192
+ });
193
+ }
194
+ throw error;
195
+ };
196
+ };
162
197
 
163
198
  PCore.getAttachmentUtils()
164
199
  .uploadAttachment(
@@ -286,7 +286,7 @@ const ModalViewContainer = props => {
286
286
  </DialogTitle>
287
287
  <DialogContent className={classes.dlgContent}>
288
288
  {bShowModal ? (
289
- <Assignment getPConnect={createdView.getPConnect} itemKey={itemKey} isCreateStage>
289
+ <Assignment getPConnect={createdView.getPConnect} itemKey={itemKey} isInModal>
290
290
  {arNewChildrenAsReact}
291
291
  </Assignment>
292
292
  ) : (
@@ -34,7 +34,7 @@ import ClearOutlinedIcon from '@material-ui/icons/ClearOutlined';
34
34
  import ArrowBackIcon from '@material-ui/icons/ArrowBack';
35
35
  import useMediaQuery from '@material-ui/core/useMediaQuery';
36
36
 
37
- import { useNavBar } from "@pega/react-sdk-components/lib/components/templates/AppShell/AppShell";
37
+ import { useNavBar } from "@pega/react-sdk-components/lib/components/helpers/reactContextHelpers";
38
38
  import { logout } from '@pega/react-sdk-components/lib/components/helpers/authManager';
39
39
 
40
40
  declare const PCore;
@@ -13,7 +13,7 @@ import {
13
13
 
14
14
  // In this styling, "root" is the top-level "Tab" object (which is the button)
15
15
  // and the button contains spans that will match on the '> span'
16
- const LeftAlignVerticalTab: any = withStyles((/* theme */) => ({
16
+ const LeftAlignVerticalTabs: any = withStyles((/* theme */) => ({
17
17
  root: {
18
18
  width: '100%',
19
19
  maxWidth: '100%',
@@ -24,4 +24,4 @@ const LeftAlignVerticalTab: any = withStyles((/* theme */) => ({
24
24
  },
25
25
  }))((props) => <div><Tab {...props} /><Divider /></div>);
26
26
 
27
- export default LeftAlignVerticalTab;
27
+ export default LeftAlignVerticalTabs;
@@ -0,0 +1 @@
1
+ export { default } from './LeftAlignVerticalTabs';
@@ -3,7 +3,7 @@ import PropTypes from "prop-types";
3
3
  import { makeStyles } from '@material-ui/core/styles'
4
4
 
5
5
  import Tabs from '@material-ui/core/Tabs';
6
- import LeftAlignVerticalTab from './LeftAlignVerticalTab';
6
+ import LeftAlignVerticalTab from '@pega/react-sdk-components/lib/components/infra/VerticalTabs/LeftAlignVerticalTabs';
7
7
 
8
8
 
9
9
  // The MuiTabs-indicator class is in a span whose parent is div (under the Tabs root component)
@@ -1,7 +1,9 @@
1
- import React, { useEffect, useState, createContext, useContext } from "react";
1
+ import React, { useEffect, useState } from "react";
2
2
  import PropTypes from "prop-types";
3
3
  import { makeStyles } from '@material-ui/core/styles';
4
4
 
5
+ import { NavContext } from '@pega/react-sdk-components/lib/components/helpers/reactContextHelpers';
6
+
5
7
  // import {
6
8
  // Avatar,
7
9
  // Toaster,
@@ -33,9 +35,6 @@ const useStyles = makeStyles((theme) => ({
33
35
  declare const PCore;
34
36
 
35
37
 
36
- const NavContext = createContext({open: false, setOpen: f => f});
37
- export const useNavBar = () => useContext(NavContext);
38
-
39
38
  /*
40
39
  * The wrapper handles knowing how to take in just children and mapping
41
40
  * to the Cosmos template. This could be a combination of things but it knows...
@@ -1 +1 @@
1
- export { default } from './AppShell';
1
+ export { default } from './AppShell';
@@ -10,8 +10,8 @@ import Button from '@material-ui/core/Button';
10
10
  import Grid from '@material-ui/core/Grid';
11
11
 
12
12
  import StoreContext from "@pega/react-sdk-components/lib/bridge/Context/StoreContext";
13
- import CaseViewActionsMenu from "./CaseViewActionsMenu";
14
- import VerticalTabs from '@pega/react-sdk-components/lib/components/infra/VerticalTabs';
13
+ import CaseViewActionsMenu from "@pega/react-sdk-components/lib/components/templates/CaseViewActionsMenu";
14
+ import VerticalTabs from '@pega/react-sdk-components/lib/components/infra/VerticalTabs/VerticalTabs';
15
15
  import DeferLoad from '@pega/react-sdk-components/lib/components/infra/DeferLoad';
16
16
 
17
17
 
@@ -27,7 +27,7 @@ export default function CaseViewActionsMenu(props) {
27
27
  const actionsAPI = thePConn.getActionsApi();
28
28
  const openLocalAction = actionsAPI.openLocalAction.bind(actionsAPI);
29
29
 
30
- openLocalAction( data.ID, { ...data});
30
+ openLocalAction( data.ID, { ...data, containerName: 'modal', type: 'express'});
31
31
  // after doing the action, close the menu...
32
32
  handleClose();
33
33
 
@@ -0,0 +1 @@
1
+ export { default } from './CaseViewActionsMenu';
@@ -16,7 +16,8 @@ export default function FieldGroupTemplate(props) {
16
16
  getPConnect,
17
17
  lookForChildInConfig,
18
18
  heading,
19
- displayMode
19
+ displayMode,
20
+ allowTableEdit: allowAddEdit
20
21
  } = props;
21
22
  const pConn = getPConnect();
22
23
  const resolvedList = getReferenceList(pConn);
@@ -44,7 +45,7 @@ export default function FieldGroupTemplate(props) {
44
45
  pConn.getListActions().deleteEntry(index);
45
46
  }
46
47
  };
47
- if (referenceList.length === 0) {
48
+ if (referenceList.length === 0 && allowAddEdit !== false) {
48
49
  addFieldGroupItem();
49
50
  }
50
51
 
@@ -59,8 +60,8 @@ export default function FieldGroupTemplate(props) {
59
60
  return (
60
61
  <FieldGroupList
61
62
  items={MemoisedChildren}
62
- onAdd={addFieldGroupItem}
63
- onDelete={deleteFieldGroupItem}
63
+ onAdd={allowAddEdit !== false ? addFieldGroupItem : undefined}
64
+ onDelete={allowAddEdit !== false ? deleteFieldGroupItem : undefined}
64
65
  />
65
66
  );
66
67
  }
@@ -189,6 +189,8 @@ export default function SimpleTableManual(props) {
189
189
  }
190
190
 
191
191
  const formatRowsData = data => {
192
+ if(!data) return {};
193
+
192
194
  return data.map(item => {
193
195
  return displayedColumns.reduce((dataForRow, colKey) => {
194
196
  dataForRow[colKey] = getRowValue(item, colKey);
@@ -585,7 +587,7 @@ export default function SimpleTableManual(props) {
585
587
  .slice(0)
586
588
  .map(row => {
587
589
  return (
588
- <TableRow key={row[1]}>
590
+ <TableRow key={row[displayedColumns[0]]}>
589
591
  {displayedColumns.map(colKey => {
590
592
  return (
591
593
  <TableCell key={colKey} className={classes.tableCell}>
@@ -0,0 +1 @@
1
+ export { default } from './ActionButtonsForFileUtil';
@@ -3,7 +3,7 @@ import TextField from '@material-ui/core/TextField';
3
3
  import { Utils } from '@pega/react-sdk-components/lib/components/helpers/utils';
4
4
  import download from "downloadjs";
5
5
  import SummaryList from '@pega/react-sdk-components/lib/components/widgets/SummaryList';
6
- import ActionButtonsForFileUtil from './ActionButtonsForFileUtil';
6
+ import ActionButtonsForFileUtil from '@pega/react-sdk-components/lib/components/widgets/FileUtility/ActionButtonsForFileUtil';
7
7
  import './FileUtility.css';
8
8
  import { IconButton, Menu, MenuItem } from '@material-ui/core';
9
9
  import MoreVertIcon from '@material-ui/icons/MoreVert';
@@ -0,0 +1 @@
1
+ export { default } from './FileUtility';
@@ -44,7 +44,7 @@ export default function SummaryItem(props) {
44
44
  <img className="psdk-utility-card-actions-svg-icon" src={`${imagePath$}${item.primary.icon}.svg`}></img>
45
45
  </button>
46
46
  </div>)}
47
- {item.secondary.text && (<div>{item.secondary.text}</div>)}
47
+ {item.secondary.text && (<div style={{ color: item.secondary.error ? 'red' : undefined }}>{item.secondary.text}</div>)}
48
48
  </div>
49
49
  <div className="psdk-utility-action">
50
50
  {menuIconOverride$ && (<button type="button" className="psdk-utility-button" onClick={removeAttachment}>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/react-sdk-overrides",
3
- "version": "0.23.7",
3
+ "version": "0.23.9",
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": [
File without changes