@pega/react-sdk-overrides 0.23.17 → 0.23.18

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 (57) 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/date-format-utils.ts +66 -0
  23. package/lib/helpers/formatters/Currency.js +13 -5
  24. package/lib/helpers/formatters/common.js +5 -1
  25. package/lib/helpers/formatters/index.js +5 -0
  26. package/lib/helpers/template-utils.ts +80 -0
  27. package/lib/infra/Containers/FlowContainer/FlowContainer.tsx +66 -70
  28. package/lib/infra/MultiStep/MultiStep.css +4 -18
  29. package/lib/infra/NavBar/NavBar.tsx +129 -219
  30. package/lib/infra/View/View.tsx +27 -20
  31. package/lib/template/CaseView/CaseView.tsx +2 -5
  32. package/lib/template/DefaultForm/DefaultForm.tsx +4 -0
  33. package/lib/template/Details/Details/Details.tsx +52 -21
  34. package/lib/template/Details/DetailsThreeColumn/DetailsThreeColumn.tsx +63 -31
  35. package/lib/template/Details/DetailsTwoColumn/DetailsTwoColumn.tsx +64 -30
  36. package/lib/template/ListView/DefaultViewMeta.js +222 -0
  37. package/lib/template/ListView/ListView.tsx +152 -48
  38. package/lib/template/ListView/hooks.js +97 -0
  39. package/lib/template/ListView/utils.js +636 -0
  40. package/lib/template/NarrowWide/NarrowWideDetails/NarrowWideDetails.tsx +69 -42
  41. package/lib/template/WideNarrow/WideNarrowDetails/WideNarrowDetails.tsx +69 -43
  42. package/lib/widget/Attachment/Attachment.css +7 -0
  43. package/lib/widget/Attachment/Attachment.tsx +37 -3
  44. package/lib/widget/SummaryItem/SummaryItem.tsx +1 -1
  45. package/package.json +1 -1
  46. package/lib/.DS_Store +0 -0
  47. package/lib/field/AutoComplete/.DS_Store +0 -0
  48. package/lib/field/Checkbox/.DS_Store +0 -0
  49. package/lib/field/Currency/.DS_Store +0 -0
  50. package/lib/field/Date/.DS_Store +0 -0
  51. package/lib/field/TextContent/.DS_Store +0 -0
  52. package/lib/infra/.DS_Store +0 -0
  53. package/lib/template/.DS_Store +0 -0
  54. package/lib/template/CaseView/.DS_Store +0 -0
  55. package/lib/template/SimpleTable/.DS_Store +0 -0
  56. package/lib/template/SimpleTable/SimpleTable/.DS_Store +0 -0
  57. 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
  };
@@ -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.18",
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
- }