@pega/react-sdk-overrides 0.23.17 → 0.23.19

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 (65) hide show
  1. package/lib/designSystemExtension/CaseSummaryFields/CaseSummaryFields.tsx +37 -3
  2. package/lib/designSystemExtension/FieldGroup/FieldGroup.tsx +1 -2
  3. package/lib/designSystemExtension/FieldValueList/FieldValueList.tsx +38 -56
  4. package/lib/field/AutoComplete/AutoComplete.tsx +6 -4
  5. package/lib/field/Checkbox/Checkbox.tsx +7 -5
  6. package/lib/field/Currency/Currency.tsx +31 -6
  7. package/lib/field/Currency/currency-utils.ts +76 -0
  8. package/lib/field/Date/Date.tsx +25 -9
  9. package/lib/field/DateTime/DateTime.tsx +24 -10
  10. package/lib/field/Decimal/Decimal.tsx +8 -6
  11. package/lib/field/Dropdown/Dropdown.tsx +6 -4
  12. package/lib/field/Email/Email.tsx +8 -8
  13. package/lib/field/Integer/Integer.tsx +8 -6
  14. package/lib/field/Percentage/Percentage.tsx +8 -6
  15. package/lib/field/Phone/Phone.tsx +8 -7
  16. package/lib/field/RadioButtons/RadioButtons.tsx +7 -5
  17. package/lib/field/SemanticLink/SemanticLink.tsx +6 -0
  18. package/lib/field/TextArea/TextArea.tsx +8 -6
  19. package/lib/field/TextInput/TextInput.tsx +8 -6
  20. package/lib/field/Time/Time.tsx +7 -5
  21. package/lib/field/URL/URL.tsx +8 -6
  22. package/lib/helpers/authManager.js +1 -0
  23. package/lib/helpers/date-format-utils.ts +66 -0
  24. package/lib/helpers/event-utils.js +1 -1
  25. package/lib/helpers/formatters/Currency.js +13 -5
  26. package/lib/helpers/formatters/common.js +5 -1
  27. package/lib/helpers/formatters/index.js +5 -0
  28. package/lib/helpers/template-utils.ts +80 -0
  29. package/lib/infra/Containers/FlowContainer/FlowContainer.tsx +67 -72
  30. package/lib/infra/ErrorBoundary/ErrorBoundary.tsx +0 -44
  31. package/lib/infra/MultiStep/MultiStep.css +4 -18
  32. package/lib/infra/NavBar/NavBar.tsx +129 -219
  33. package/lib/infra/RootContainer/RootContainer.tsx +2 -54
  34. package/lib/infra/Stages/Stages.tsx +1 -2
  35. package/lib/infra/View/View.tsx +28 -21
  36. package/lib/template/AppShell/AppShell.tsx +2 -343
  37. package/lib/template/CaseSummary/CaseSummary.tsx +1 -1
  38. package/lib/template/CaseView/CaseView.tsx +2 -5
  39. package/lib/template/DefaultForm/DefaultForm.tsx +4 -0
  40. package/lib/template/Details/Details/Details.tsx +52 -21
  41. package/lib/template/Details/DetailsThreeColumn/DetailsThreeColumn.tsx +63 -31
  42. package/lib/template/Details/DetailsTwoColumn/DetailsTwoColumn.tsx +64 -30
  43. package/lib/template/ListView/DefaultViewMeta.js +222 -0
  44. package/lib/template/ListView/ListView.tsx +155 -94
  45. package/lib/template/ListView/hooks.js +97 -0
  46. package/lib/template/ListView/utils.js +636 -0
  47. package/lib/template/NarrowWide/NarrowWideDetails/NarrowWideDetails.tsx +69 -42
  48. package/lib/template/SimpleTable/SimpleTableManual/SimpleTableManual.tsx +3 -24
  49. package/lib/template/WideNarrow/WideNarrowDetails/WideNarrowDetails.tsx +69 -43
  50. package/lib/widget/Attachment/Attachment.css +7 -0
  51. package/lib/widget/Attachment/Attachment.tsx +37 -3
  52. package/lib/widget/SummaryItem/SummaryItem.tsx +1 -1
  53. package/package.json +1 -1
  54. package/lib/.DS_Store +0 -0
  55. package/lib/field/AutoComplete/.DS_Store +0 -0
  56. package/lib/field/Checkbox/.DS_Store +0 -0
  57. package/lib/field/Currency/.DS_Store +0 -0
  58. package/lib/field/Date/.DS_Store +0 -0
  59. package/lib/field/TextContent/.DS_Store +0 -0
  60. package/lib/infra/.DS_Store +0 -0
  61. package/lib/template/.DS_Store +0 -0
  62. package/lib/template/CaseView/.DS_Store +0 -0
  63. package/lib/template/SimpleTable/.DS_Store +0 -0
  64. package/lib/template/SimpleTable/SimpleTable/.DS_Store +0 -0
  65. package/lib/template/utils.ts +0 -23
@@ -1,53 +1,80 @@
1
- import React from "react";
2
- // import PropTypes from "prop-types";
3
- // import Grid from '@material-ui/core/Grid';
4
- import DetailsFields from '@pega/react-sdk-components/lib/components/designSystemExtension/DetailsFields';
1
+ import React, { createElement } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import Grid from '@material-ui/core/Grid';
4
+ import { GridSize } from '@material-ui/core/Grid';
5
+ import createPConnectComponent from '@pega/react-sdk-components/lib/bridge/react_pconnect';
6
+ import FieldGroup from '@pega/react-sdk-components/lib/components/designSystemExtension/FieldGroup';
7
+
8
+ const COLUMN_WIDTHS = [4, 8];
5
9
 
6
10
  export default function NarrowWideDetails(props) {
7
- const { a, b, children } = props;
8
- const arFields: Array<any> = [];
11
+ const { label, showLabel, getPConnect, showHighlightedData } = props;
9
12
 
10
- for (const child of children) {
11
- const theChildPConn = child.props.getPConnect();
12
- const theChildrenOfChild = theChildPConn.getChildren();
13
- arFields.push(theChildrenOfChild);
14
- }
13
+ // Get the inherited props from the parent to determine label settings
14
+ const propsToUse = { label, showLabel, ...getPConnect().getInheritedProps() };
15
15
 
16
- if (arFields.length !== 2) {
17
- // eslint-disable-next-line no-console
18
- console.error(`NarrowWideDetails expects 2 children and received ${arFields.length}`);
19
- }
16
+ // Set display mode prop and re-create the children so this part of the dom tree renders
17
+ // in a readonly (display) mode instead of a editable
18
+ getPConnect().setInheritedProp('displayMode', 'LABELS_LEFT');
19
+ getPConnect().setInheritedProp('readOnly', true);
20
+ const children = getPConnect()
21
+ .getChildren()
22
+ .map((configObject, index) =>
23
+ createElement(createPConnectComponent(), {
24
+ ...configObject,
25
+ // eslint-disable-next-line react/no-array-index-key
26
+ key: index.toString()
27
+ })
28
+ );
29
+
30
+ // Set up highlighted data to pass in return if is set to show, need raw metadata to pass to createComponent
31
+ let highlightedDataArr = [];
32
+ if (showHighlightedData) {
33
+ const { highlightedData = [] } = getPConnect().getRawMetadata().config;
34
+ highlightedDataArr = highlightedData.map(field => {
35
+ field.config.displayMode = 'STACKED_LARGE_VAL';
20
36
 
37
+ // Mark as status display when using pyStatusWork
38
+ if (field.config.value === '@P .pyStatusWork') {
39
+ field.type = 'TextInput';
40
+ field.config.displayAsStatus = true;
41
+ }
42
+
43
+ return getPConnect().createComponent(field);
44
+ });
45
+ }
21
46
 
22
47
  return (
23
- <React.Fragment>
24
- {children && children.length === 2 &&
25
- <div className="psdk-narrow-wide-column">
26
- <div className="psdk-narrow-column-column">
27
- <DetailsFields fields={arFields[0]} />
28
- </div>
29
- <div className="psdk-wide-column-column">
30
- <DetailsFields fields={arFields[1]} />
31
- </div>
32
- </div>
33
- }
34
- {a && b &&
35
- <div className="psdk-narrow-wide-column">
36
- <div className="psdk-narrow-column-column">
37
- {a}
38
- </div>
39
- <div className="psdk-wide-column-column">
40
- {b}
41
- </div>
42
- </div>
43
- }
44
- </React.Fragment>
45
- )
48
+ <FieldGroup name={propsToUse.showLabel ? propsToUse.label : ''}>
49
+ {showHighlightedData && highlightedDataArr.length > 0 && (
50
+ <Grid container spacing={1} style={{ padding: '0 0 1em' }}>
51
+ {highlightedDataArr.map((child, i) => (
52
+ <Grid item xs={COLUMN_WIDTHS[i] as GridSize} key={`hf-${i + 1}`}>
53
+ {child}
54
+ </Grid>
55
+ ))}
56
+ </Grid>
57
+ )}
58
+ <Grid container spacing={1}>
59
+ {children.map((child, i) => (
60
+ <Grid item xs={COLUMN_WIDTHS[i] as GridSize} key={`r-${i + 1}`}>
61
+ {child}
62
+ </Grid>
63
+ ))}
64
+ </Grid>
65
+ </FieldGroup>
66
+ );
46
67
  }
47
68
 
69
+ NarrowWideDetails.defaultProps = {
70
+ label: undefined,
71
+ showLabel: true,
72
+ showHighlightedData: false
73
+ };
74
+
48
75
  NarrowWideDetails.propTypes = {
49
- // showLabel: PropTypes.bool,
50
- // label: PropTypes.string,
51
- // getPConnect: PropTypes.func.isRequired,
52
- // template: PropTypes.string.isRequired
76
+ showLabel: PropTypes.bool,
77
+ label: PropTypes.string,
78
+ getPConnect: PropTypes.func.isRequired,
79
+ showHighlightedData: PropTypes.bool
53
80
  };
@@ -147,14 +147,12 @@ export default function SimpleTableManual(props) {
147
147
  }
148
148
  }, [referenceList.length]);
149
149
 
150
- // Nebula has other handling for isReadOnlyMode but has Cosmos-specific code
151
- // so ignoring that for now...
152
150
  // fieldDefs will be an array where each entry will have a "name" which will be the
153
151
  // "resolved" property name (that we can use as the colId) though it's not really
154
152
  // resolved. The buildFieldsForTable helper just removes the "@P " (which is what
155
- // Nebula does). It will also have the "label", and "meta" contains the original,
153
+ // Constellation DX Components do). It will also have the "label", and "meta" contains the original,
156
154
  // unchanged config info. For now, much of the info here is carried over from
157
- // Nebula and we may not end up using it all.
155
+ // Constellation DX Components.
158
156
  const fieldDefs = buildFieldsForTable(rawFields, resolvedFields, showDeleteButton);
159
157
 
160
158
  const displayedColumns = fieldDefs.map(field => {
@@ -164,18 +162,6 @@ export default function SimpleTableManual(props) {
164
162
  // console.log(`SimpleTable displayedColumns:`);
165
163
  // console.log(displayedColumns);
166
164
 
167
- // And now we can process the resolvedFields to add in the "name"
168
- // from from the fieldDefs. This "name" is the value that
169
- // we'll share to connect things together in the table.
170
-
171
- // const processedFields = resolvedFields.map((field, i) => {
172
- // field.config['name'] = displayedColumns[i]; // .config["value"].replace(/ ./g,"_"); // replace space dot with underscore
173
- // return field;
174
- // });
175
-
176
- // console.log("SimpleTable processedFields:");
177
- // console.log(processedFields);
178
-
179
165
  // return the value that should be shown as the contents for the given row data
180
166
  // of the given row field
181
167
  function getRowValue(inRowData: Object, inColKey: string): any {
@@ -226,25 +212,18 @@ export default function SimpleTableManual(props) {
226
212
  }
227
213
  }
228
214
 
215
+ // May be useful for debugging or understanding how it works.
229
216
  // These are the data structures referred to in the html file.
230
217
  // These are the relationships that make the table work
231
218
  // displayedColumns: key/value pairs where key is order of column and
232
219
  // value is the property shown in that column. Ex: 1: "FirstName"
233
- // processedFields: key/value pairs where each key is order of column
234
- // and each value is an object of more detailed information about that
235
- // column.
236
220
  // rowData: array of each row's key/value pairs. Inside each row,
237
221
  // each key is an entry in displayedColumns: ex: "FirstName": "Charles"
238
222
  // Ex: { 1: {config: {label: "First Name", readOnly: true: name: "FirstName"}}, type: "TextInput" }
239
223
  // The "type" indicates the type of component that should be used for editing (when editing is enabled)
240
224
  //
241
- // Note that the "property" shown in the column ("FirstName" in the above examples) is what
242
- // ties the 3 data structures together.
243
-
244
225
  // console.log("SimpleTable displayedColumns:");
245
226
  // console.log(displayedColumns);
246
- // console.log("SimpleTable processedFields:");
247
- // console.log(processedFields);
248
227
  // console.log(`SimpleTable rowData (${rowData.length} row(s)):`);
249
228
  // console.log(JSON.stringify(rowData));
250
229
 
@@ -1,54 +1,80 @@
1
- import React from "react";
2
- // import PropTypes from "prop-types";
3
- // import Grid from '@material-ui/core/Grid';
4
- import DetailsFields from '@pega/react-sdk-components/lib/components/designSystemExtension/DetailsFields';
1
+ import React, { createElement } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import Grid from '@material-ui/core/Grid';
4
+ import { GridSize } from '@material-ui/core/Grid';
5
+ import createPConnectComponent from '@pega/react-sdk-components/lib/bridge/react_pconnect';
6
+ import FieldGroup from '@pega/react-sdk-components/lib/components/designSystemExtension/FieldGroup';
7
+
8
+ const COLUMN_WIDTHS = [8, 4];
5
9
 
6
10
  export default function WideNarrowDetails(props) {
7
- const { a, b, children } = props;
8
- const arFields: Array<any> = [];
11
+ const { label, showLabel, getPConnect, showHighlightedData } = props;
9
12
 
10
- for (const child of children) {
11
- const theChildPConn = child.props.getPConnect();
12
- const theChildrenOfChild = theChildPConn.getChildren();
13
- arFields.push(theChildrenOfChild);
14
- }
13
+ // Get the inherited props from the parent to determine label settings
14
+ const propsToUse = { label, showLabel, ...getPConnect().getInheritedProps() };
15
15
 
16
- if (arFields.length !== 2) {
17
- // eslint-disable-next-line no-console
18
- console.error(`WideNarrowDetails expects 2 children and received ${arFields.length}`);
19
- }
16
+ // Set display mode prop and re-create the children so this part of the dom tree renders
17
+ // in a readonly (display) mode instead of a editable
18
+ getPConnect().setInheritedProp('displayMode', 'LABELS_LEFT');
19
+ getPConnect().setInheritedProp('readOnly', true);
20
+ const children = getPConnect()
21
+ .getChildren()
22
+ .map((configObject, index) =>
23
+ createElement(createPConnectComponent(), {
24
+ ...configObject,
25
+ // eslint-disable-next-line react/no-array-index-key
26
+ key: index.toString()
27
+ })
28
+ );
20
29
 
30
+ // Set up highlighted data to pass in return if is set to show, need raw metadata to pass to createComponent
31
+ let highlightedDataArr = [];
32
+ if (showHighlightedData) {
33
+ const { highlightedData = [] } = getPConnect().getRawMetadata().config;
34
+ highlightedDataArr = highlightedData.map(field => {
35
+ field.config.displayMode = 'STACKED_LARGE_VAL';
21
36
 
22
- return (
23
- <React.Fragment>
24
- {children && children.length === 2 &&
25
- <div className="psdk-wide-narrow-column">
26
- <div className="psdk-wide-column-column">
27
- <DetailsFields fields={arFields[0]} />
28
- </div>
29
- <div className="psdk-narrow-column-column">
30
- <DetailsFields fields={arFields[1]} />
31
- </div>
32
- </div>
33
- }
34
- {a && b &&
35
- <div className="psdk-wide-narrow-column">
36
- <div className="psdk-wide-column-column">
37
- {a}
38
- </div>
39
- <div className="psdk-narrow-column-column">
40
- {b}
41
- </div>
42
- </div>
43
- }
44
- </React.Fragment>
45
- )
37
+ // Mark as status display when using pyStatusWork
38
+ if (field.config.value === '@P .pyStatusWork') {
39
+ field.type = 'TextInput';
40
+ field.config.displayAsStatus = true;
41
+ }
46
42
 
43
+ return getPConnect().createComponent(field);
44
+ });
45
+ }
46
+
47
+ return (
48
+ <FieldGroup name={propsToUse.showLabel ? propsToUse.label : ''}>
49
+ {showHighlightedData && highlightedDataArr.length > 0 && (
50
+ <Grid container spacing={1} style={{ padding: '0 0 1em' }}>
51
+ {highlightedDataArr.map((child, i) => (
52
+ <Grid item xs={COLUMN_WIDTHS[i] as GridSize} key={`hf-${i + 1}`}>
53
+ {child}
54
+ </Grid>
55
+ ))}
56
+ </Grid>
57
+ )}
58
+ <Grid container spacing={1}>
59
+ {children.map((child, i) => (
60
+ <Grid item xs={COLUMN_WIDTHS[i] as GridSize} key={`r-${i + 1}`}>
61
+ {child}
62
+ </Grid>
63
+ ))}
64
+ </Grid>
65
+ </FieldGroup>
66
+ );
47
67
  }
48
68
 
69
+ WideNarrowDetails.defaultProps = {
70
+ label: undefined,
71
+ showLabel: true,
72
+ showHighlightedData: false
73
+ };
74
+
49
75
  WideNarrowDetails.propTypes = {
50
- // showLabel: PropTypes.bool,
51
- // label: PropTypes.string,
52
- // getPConnect: PropTypes.func.isRequired,
53
- // template: PropTypes.string.isRequired
76
+ showLabel: PropTypes.bool,
77
+ label: PropTypes.string,
78
+ getPConnect: PropTypes.func.isRequired,
79
+ showHighlightedData: PropTypes.bool
54
80
  };
@@ -16,3 +16,10 @@
16
16
  position: absolute;
17
17
  left: 47%;
18
18
  }
19
+
20
+ file-label::after {
21
+ display: inline;
22
+ content: " *";
23
+ vertical-align: top;
24
+ color: rgb(217, 28, 41);
25
+ }
@@ -23,7 +23,7 @@ export default function Attachment(props) {
23
23
  );
24
24
  let arFileList$: Array<any> = [];
25
25
  const pConn = getPConnect();
26
-
26
+ const caseID = PCore.getStoreValue('.pyID', 'caseInfo.content', pConn.getContextName());
27
27
  let fileTemp: any = {};
28
28
 
29
29
  let categoryName = '';
@@ -35,6 +35,13 @@ export default function Attachment(props) {
35
35
  valueRef = valueRef.indexOf('.') === 0 ? valueRef.substring(1) : valueRef;
36
36
  const [file, setFile] = useState(fileTemp);
37
37
 
38
+ const resetAttachmentStoredState = () => {
39
+ PCore.getStateUtils().updateState(pConn.getContextName(), 'attachmentsList', undefined, {
40
+ pageReference: 'context_data',
41
+ isArrayDeepMerge: false
42
+ });
43
+ };
44
+
38
45
  const fileDownload = (data, fileName, ext) => {
39
46
  const fileData = ext ? `${fileName}.${ext}` : fileName;
40
47
  download(atob(data), fileData);
@@ -396,9 +403,36 @@ export default function Attachment(props) {
396
403
  };
397
404
  });
398
405
  }
406
+
407
+ if (fileTemp) {
408
+ const currentAttachmentList = getCurrentAttachmentsList(pConn.getContextName());
409
+ const index = currentAttachmentList.findIndex(element => element.props.ID === fileTemp.props.ID);
410
+ let tempFiles: any = [];
411
+ if (index < 0) {
412
+ tempFiles = [fileTemp];
413
+ }
414
+ PCore.getStateUtils().updateState(
415
+ pConn.getContextName(),
416
+ 'attachmentsList',
417
+ [...currentAttachmentList, ...tempFiles],
418
+ {
419
+ pageReference: 'context_data',
420
+ isArrayDeepMerge: false
421
+ }
422
+ );
423
+ }
424
+
425
+ PCore.getPubSubUtils().subscribe(
426
+ PCore.getConstants().PUB_SUB_EVENTS.CASE_EVENTS.ASSIGNMENT_SUBMISSION,
427
+ resetAttachmentStoredState,
428
+ caseID
429
+ );
430
+ return () => {
431
+ PCore.getPubSubUtils().unsubscribe(PCore.getConstants().PUB_SUB_EVENTS.CASE_EVENTS.ASSIGNMENT_SUBMISSION, caseID);
432
+ };
399
433
  }
400
434
  }
401
- }, [""]);
435
+ }, []);
402
436
 
403
437
  let content = (
404
438
  <div className='file-div'>
@@ -432,7 +466,7 @@ export default function Attachment(props) {
432
466
 
433
467
  return (
434
468
  <div className='file-upload-container'>
435
- <span className='label'>{label}</span>
469
+ <span className={`label ${required ? 'file-label' : ''}`}>{label}</span>
436
470
  <section>{content}</section>
437
471
  </div>
438
472
  );
@@ -68,7 +68,7 @@ export default function SummaryItem(props) {
68
68
  onClose={handleClose}
69
69
  >
70
70
  {item.actions && item.actions.map((option) => (
71
- <MenuItem style={{fontSize: '14px'}} key={option.id} onClick={option.onClick}>
71
+ <MenuItem style={{fontSize: '14px'}} key={option.id || option.text} onClick={option.onClick}>
72
72
  {option.text}
73
73
  </MenuItem>
74
74
  ))}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/react-sdk-overrides",
3
- "version": "0.23.17",
3
+ "version": "0.23.19",
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": [
package/lib/.DS_Store DELETED
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1,23 +0,0 @@
1
- // This file is adapted from React DX components/template/utils.js
2
-
3
- export function getAllFields(pConnect: any) {
4
- const metadata = pConnect.getRawMetadata();
5
- let allFields = [];
6
- if (metadata.children && metadata.children.map) {
7
- allFields = metadata.children.map((fields) => {
8
- const children = fields.children instanceof Array ? fields.children : [];
9
- return children.map((field) => field.config);
10
- });
11
- }
12
- return allFields;
13
- }
14
-
15
- export function filterForFieldValueList(fields : any) {
16
- return fields
17
- .filter(({ visibility }) => visibility !== false)
18
- .map(({ value, label }) => ({
19
- id: label.toLowerCase(),
20
- name: label,
21
- value
22
- }));
23
- }