@pega/custom-dx-components 2.0.23 → 2.0.25

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 (122) hide show
  1. package/README.md +1 -1
  2. package/package.json +3 -6
  3. package/src/cli.js +0 -18
  4. package/src/constants.js +2 -32
  5. package/src/tasks/authenticate/helper.js +5 -63
  6. package/src/tasks/authenticate/index.js +50 -107
  7. package/src/tasks/create/index.js +63 -59
  8. package/src/tasks/create/templates/Constellation/Field/Boolean/boolean-format.js.mustache +1 -1
  9. package/src/tasks/create/templates/Constellation/Field/Boolean/demo.stories.jsx.mustache +16 -33
  10. package/src/tasks/create/templates/Constellation/Field/Boolean/index.jsx.mustache +2 -1
  11. package/src/tasks/create/templates/Constellation/Field/Date/date.js.mustache +67 -179
  12. package/src/tasks/create/templates/Constellation/Field/Date/demo.stories.jsx.mustache +17 -46
  13. package/src/tasks/create/templates/Constellation/Field/Date/index.jsx.mustache +1 -3
  14. package/src/tasks/create/templates/Constellation/Field/DateTime/date-time.js.mustache +1 -0
  15. package/src/tasks/create/templates/Constellation/Field/DateTime/{date-utils.js.mustache → date-utils.js} +0 -1
  16. package/src/tasks/create/templates/Constellation/Field/DateTime/date.js.mustache +0 -1
  17. package/src/tasks/create/templates/Constellation/Field/DateTime/demo.stories.jsx.mustache +17 -46
  18. package/src/tasks/create/templates/Constellation/Field/DateTime/index.jsx.mustache +0 -2
  19. package/src/tasks/create/templates/Constellation/Field/Decimal/demo.stories.jsx.mustache +17 -22
  20. package/src/tasks/create/templates/Constellation/Field/Decimal/index.jsx.mustache +1 -2
  21. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/demo.stories.jsx.mustache +17 -26
  22. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/index.jsx.mustache +4 -3
  23. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/demo.stories.jsx.mustache +17 -22
  24. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/index.jsx.mustache +2 -8
  25. package/src/tasks/create/templates/Constellation/Field/Integer/demo.stories.jsx.mustache +17 -22
  26. package/src/tasks/create/templates/Constellation/Field/Integer/index.jsx.mustache +1 -2
  27. package/src/tasks/create/templates/Constellation/Field/Picklist/demo.stories.jsx.mustache +16 -50
  28. package/src/tasks/create/templates/Constellation/Field/Picklist/index.jsx.mustache +1 -44
  29. package/src/tasks/create/templates/Constellation/Field/Picklist/picklist.js.mustache +43 -0
  30. package/src/tasks/create/templates/Constellation/Field/Text/demo.stories.jsx.mustache +16 -23
  31. package/src/tasks/create/templates/Constellation/Field/Text-Email/demo.stories.jsx.mustache +17 -21
  32. package/src/tasks/create/templates/Constellation/Field/Text-Email/index.jsx.mustache +2 -44
  33. package/src/tasks/create/templates/Constellation/Field/Text-Email/text-email.js.mustache +43 -0
  34. package/src/tasks/create/templates/Constellation/Field/Text-Input/{StatusWork.jsx → StatusWork.js} +1 -0
  35. package/src/tasks/create/templates/Constellation/Field/Text-Input/demo.stories.jsx.mustache +17 -21
  36. package/src/tasks/create/templates/Constellation/Field/Text-Input/index.jsx.mustache +3 -46
  37. package/src/tasks/create/templates/Constellation/Field/Text-Input/text-input.js.mustache +43 -0
  38. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/demo.stories.jsx.mustache +17 -21
  39. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/index.jsx.mustache +2 -44
  40. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/text-paragraph.js.mustache +43 -0
  41. package/src/tasks/create/templates/Constellation/Field/Text-Phone/demo.stories.jsx.mustache +17 -19
  42. package/src/tasks/create/templates/Constellation/Field/Text-Phone/index.jsx.mustache +3 -47
  43. package/src/tasks/create/templates/Constellation/Field/Text-Phone/text-phone.js.mustache +43 -0
  44. package/src/tasks/create/templates/Constellation/Field/Text-URL/demo.stories.jsx.mustache +17 -19
  45. package/src/tasks/create/templates/Constellation/Field/Text-URL/index.jsx.mustache +1 -1
  46. package/src/tasks/create/templates/Constellation/Field/Text-URL/{text-url.jsx.mustache → text-url.js.mustache} +1 -2
  47. package/src/tasks/create/templates/Constellation/Field/TimeofDay/demo.stories.jsx.mustache +17 -30
  48. package/src/tasks/create/templates/Constellation/Field/TimeofDay/time-of-day.js.mustache +0 -1
  49. package/src/tasks/create/templates/Constellation/Template/DETAILS/index.jsx.mustache +29 -14
  50. package/src/tasks/create/templates/Constellation/Template/DETAILS/utils.js.mustache +77 -3
  51. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/index.jsx.mustache +29 -14
  52. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/utils.js.mustache +74 -3
  53. package/src/tasks/create/templates/Constellation/Template/FORM/index.jsx.mustache +10 -6
  54. package/src/tasks/create/templates/Constellation/Template/FORM-region/index.jsx.mustache +8 -10
  55. package/src/tasks/create/templates/Constellation/Template/PAGE/{GetNextWork.jsx.mustache → GetNextWork.js.mustache} +0 -6
  56. package/src/tasks/create/templates/Constellation/Template/PAGE/index.jsx.mustache +7 -9
  57. package/src/tasks/create/templates/Constellation/Template/PAGE/utils.js.mustache +1 -4
  58. package/src/tasks/create/templates/Constellation/Widget/CASE/index.jsx.mustache +0 -1
  59. package/src/tasks/create/templates/Constellation/Widget/PAGE/index.jsx.mustache +8 -8
  60. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/{Avatar.jsx.mustache → Avatar.js.mustache} +0 -2
  61. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/{Operator.jsx.mustache → Operator.js.mustache} +1 -2
  62. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/index.jsx.mustache +9 -9
  63. package/src/tasks/delete/helper.js +0 -4
  64. package/src/tasks/delete/index.js +0 -4
  65. package/src/tasks/index.js +0 -3
  66. package/src/tasks/init/index.js +3 -3
  67. package/src/tasks/init/template/.eslintrc.json +5 -186
  68. package/src/tasks/init/template/README.md +59 -75
  69. package/src/tasks/init/template/package.json.mustache +6 -21
  70. package/src/tasks/init/template/tasks.config.json +2 -5
  71. package/src/tasks/list/index.js +0 -4
  72. package/src/tasks/{bundle → publish/bundle}/builder/webpack.config.js +2 -0
  73. package/src/tasks/{bundle → publish/bundle}/index.js +2 -2
  74. package/src/tasks/publish/index.js +1 -14
  75. package/src/util.js +6 -11
  76. package/src/auth.js +0 -563
  77. package/src/tasks/build/helper.js +0 -123
  78. package/src/tasks/build/index.js +0 -54
  79. package/src/tasks/create/templates/Constellation/Field/Boolean/mock.stories.js.mustache +0 -21
  80. package/src/tasks/create/templates/Constellation/Field/Date/DateFormatter.js.mustache +0 -61
  81. package/src/tasks/create/templates/Constellation/Field/Date/FormattedText.jsx.mustache +0 -41
  82. package/src/tasks/create/templates/Constellation/Field/Date/mock.stories.js.mustache +0 -23
  83. package/src/tasks/create/templates/Constellation/Field/DateTime/mock.stories.js.mustache +0 -23
  84. package/src/tasks/create/templates/Constellation/Field/Decimal/mock.stories.js.mustache +0 -21
  85. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/mock.stories.js.mustache +0 -23
  86. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/mock.stories.js.mustache +0 -21
  87. package/src/tasks/create/templates/Constellation/Field/Integer/mock.stories.js.mustache +0 -21
  88. package/src/tasks/create/templates/Constellation/Field/Picklist/mock.stories.js.mustache +0 -67
  89. package/src/tasks/create/templates/Constellation/Field/Text/mock.stories.js.mustache +0 -13
  90. package/src/tasks/create/templates/Constellation/Field/Text-Email/mock.stories.js.mustache +0 -22
  91. package/src/tasks/create/templates/Constellation/Field/Text-Input/mock.stories.js.mustache +0 -21
  92. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/mock.stories.js.mustache +0 -20
  93. package/src/tasks/create/templates/Constellation/Field/Text-Phone/mock.stories.js.mustache +0 -37
  94. package/src/tasks/create/templates/Constellation/Field/Text-URL/mock.stories.js.mustache +0 -22
  95. package/src/tasks/create/templates/Constellation/Field/TimeofDay/mock.stories.js.mustache +0 -20
  96. package/src/tasks/create/templates/Constellation/Template/DETAILS/StatusWork.jsx.mustache +0 -26
  97. package/src/tasks/create/templates/Constellation/Template/DETAILS/demo.stories.jsx.mustache +0 -118
  98. package/src/tasks/create/templates/Constellation/Template/DETAILS/mock.stories.js.mustache +0 -179
  99. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/StatusWork.jsx.mustache +0 -26
  100. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/demo.stories.jsx.mustache +0 -123
  101. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/mock.stories.js.mustache +0 -215
  102. package/src/tasks/create/templates/Constellation/Template/FORM/demo.stories.jsx.mustache +0 -93
  103. package/src/tasks/create/templates/Constellation/Template/FORM/mock.stories.js.mustache +0 -125
  104. package/src/tasks/create/templates/Constellation/Template/FORM-region/demo.stories.jsx.mustache +0 -100
  105. package/src/tasks/create/templates/Constellation/Template/FORM-region/mock.stories.js.mustache +0 -131
  106. package/src/tasks/create/templates/Constellation/Template/PAGE/demo.stories.jsx.mustache +0 -101
  107. package/src/tasks/create/templates/Constellation/Template/PAGE/mock.stories.js.mustache +0 -94
  108. package/src/tasks/create/templates/Constellation/Widget/CASE/demo.stories.jsx.mustache +0 -78
  109. package/src/tasks/create/templates/Constellation/Widget/CASE/mock.stories.js.mustache +0 -390
  110. package/src/tasks/create/templates/Constellation/Widget/PAGE/demo.stories.jsx.mustache +0 -30
  111. package/src/tasks/create/templates/Constellation/Widget/PAGE/mock.stories.js.mustache +0 -23
  112. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/demo.stories.jsx.mustache +0 -68
  113. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/mock.stories.js.mustache +0 -51
  114. package/src/tasks/delete-all/helper.js +0 -175
  115. package/src/tasks/delete-all/index.js +0 -49
  116. package/src/tasks/init/template/.eslintignore +0 -8
  117. package/src/tasks/linter/index.js +0 -46
  118. package/src/tasks/publish-all/helper.js +0 -139
  119. package/src/tasks/publish-all/index.js +0 -84
  120. /package/src/tasks/{bundle → publish/bundle}/builder/index.js +0 -0
  121. /package/src/tasks/{bundle → publish/bundle}/builder/modules.js +0 -0
  122. /package/src/tasks/{bundle → publish/bundle}/builder/paths.js +0 -0
@@ -1,5 +1,4 @@
1
- import { useState, useRef, React} from "react";
2
- import { EmailDisplay, PhoneDisplay, URLDisplay, Image, Button, Lightbox } from '@pega/cosmos-react-core';
1
+ import {EmailDisplay, PhoneDisplay, URLDisplay } from "@pega/cosmos-react-core";
3
2
 
4
3
  export const formatExists = (formatterVal) => {
5
4
  const formatterValues = [
@@ -1,5 +1,6 @@
1
- import { withKnobs } from '@storybook/addon-knobs';
2
- import { configProps, stateProps } from './mock.stories';
1
+ import { useState } from 'react';
2
+ import { withKnobs, text, boolean } from '@storybook/addon-knobs';
3
+
3
4
  import {{COMPONENT_CLASS_NAME}} from './index.jsx';
4
5
 
5
6
  export default {
@@ -9,44 +10,30 @@ export default {
9
10
  };
10
11
 
11
12
  export const base{{COMPONENT_CLASS_NAME}} = () => {
13
+ const [value, setValue] = useState('test value');
14
+
12
15
  const props = {
13
16
  getPConnect: () => {
14
17
  return {
15
18
  getActionsApi: () => {
16
19
  return {
17
- updateFieldValue: () => {/* nothing */},
18
- triggerFieldChange: () => {/* nothing */}
19
- };
20
- },
21
- getValidationApi: () => {
22
- return {
23
- validate: () => {/* nothing */}
20
+ updateFieldValue: (propName, value) => {
21
+ setValue(value);
22
+ }
24
23
  };
25
24
  },
26
25
  getStateProps: () => {
27
- return stateProps;
28
- },
29
- getConfigProps: () => {
30
- return configProps;
31
- },
32
- ignoreSuggestion: () => {/* nothing */},
33
- clearErrorMessages: () => {/* nothing */}
26
+ return { value: '.name' };
27
+ }
34
28
  };
35
29
  },
36
- value: configProps.value,
37
- validatemessage: configProps.validatemessage,
38
- label: configProps.label,
39
- hideLabel: configProps.hideLabel,
40
- helperText: configProps.helperText,
41
- withSeconds: configProps.withSeconds,
42
- testId: configProps.testId,
43
- additionalProps: configProps.additionalProps,
44
- displayMode: configProps.displayMode,
45
- variant: configProps.variant,
46
- hasSuggestions: configProps.hasSuggestions,
47
- disabled: configProps.disabled,
48
- readOnly: configProps.readOnly,
49
- required: configProps.required
30
+ value,
31
+ placeholder: text('Placeholder', 'Test placeholder'),
32
+ disabled: boolean('Disabled', false),
33
+ readOnly: boolean('Disabled', false),
34
+ required: boolean('Disabled', false),
35
+ label: text('Label', 'Sample Label'),
36
+ testId: text('Test id', 'text-12344566')
50
37
  };
51
38
 
52
39
  return (
@@ -1,4 +1,3 @@
1
- /* eslint-disable no-undef */
2
1
  import dayjs from "dayjs";
3
2
 
4
3
  const relativeTime = require("dayjs/plugin/relativeTime");
@@ -1,5 +1,5 @@
1
- import { Fragment } from 'react';
2
- import { Grid, Flex, FieldGroup } from '@pega/cosmos-react-core';
1
+ import { useContext, Fragment } from 'react';
2
+ import { Grid , Flex, FieldGroup } from '@pega/cosmos-react-core';
3
3
  import PropTypes from 'prop-types';
4
4
 
5
5
  import Styled{{COMPONENT_CLASS_NAME}}Wrapper from './styles';
@@ -13,19 +13,13 @@ import { getAllFields } from './utils';
13
13
  // any default values in config.pros should be set in defaultProps at bottom of this file
14
14
  export default function {{COMPONENT_CLASS_NAME}}(props) {
15
15
 
16
- const { getPConnect, children, label, showLabel, showHighlightedData } = props;
16
+
17
+ const { getPConnect, children, template, regionsMetadata = [], label, showLabel, showHighlightedData } = props;
18
+
17
19
  const propsToUse = { label, showLabel, ...getPConnect().getInheritedProps() };
18
20
 
19
- const numRegions = getAllFields(getPConnect)?.length;
20
- const gridRepeat = "repeat(".concat(numRegions).concat(", 1fr)");
21
- const gridContainer = { "colGap": 1};
22
- gridContainer.cols = gridRepeat;
23
- gridContainer.alignItems = 'start';
24
21
 
25
- const gridHighlightContainer = { "gap": 2};
26
- gridHighlightContainer.cols = gridRepeat;
27
- gridHighlightContainer.alignItems = 'start';
28
- gridHighlightContainer.pad = [0, 0, 2, 0];
22
+ const numRegions = regionsMetadata.length;
29
23
 
30
24
  // Set up highlighted data to pass in return if is set to show, need raw metadata to pass to createComponent
31
25
  let highlightedDataArr = [];
@@ -50,14 +44,14 @@ export default function {{COMPONENT_CLASS_NAME}}(props) {
50
44
  {{=<% %>=}}
51
45
  <FieldGroup name={propsToUse.showLabel ? propsToUse.label : ''}>
52
46
  {showHighlightedData && highlightedDataArr.length > 0 && (
53
- <Grid container={gridHighlightContainer}
47
+ <Grid container={{ cols:'repeat(${numRegions}, 1fr)', gap: 2, alignItems: 'start', pad: [0, 0, 2, 0] }}
54
48
  data-testid={`highlighted-column-count-${numRegions}`}>
55
49
  {highlightedDataArr.map((child, i) => (
56
50
  <Fragment key={`hf-${i + 1}`}>{child}</Fragment>
57
51
  ))}
58
52
  </Grid>
59
53
  )}
60
- <Grid container={gridContainer} data-testid={`column-count-${numRegions}`} >
54
+ <Grid container={{ cols:'repeat(${numRegions}, 1fr)', alignItems: 'start', colGap: 1 }} data-testid={`column-count-${numRegions}`} >
61
55
  {children.map((child, i) => (
62
56
  <Flex container={{ direction: 'column'}} key={`r-${i + 1}`}>
63
57
  {child}
@@ -77,10 +71,31 @@ export default function {{COMPONENT_CLASS_NAME}}(props) {
77
71
  showHighlightedData: false
78
72
  };
79
73
 
74
+ // Since the fields are not part of the 'config' in Details template metadata, they need to be subscribed with additionalprops
75
+ const mapStateToProps = (_, ownProps) => {
76
+ const { getPConnect, showLabel, label } = ownProps;
77
+ const Allfields = getAllFields(getPConnect);
78
+
79
+ return {
80
+ regionsMetadata: Allfields,
81
+ label,
82
+ showLabel,
83
+ getPConnect
84
+ };
85
+ };
80
86
 
81
87
  {{COMPONENT_CLASS_NAME}}.propTypes = {
88
+ regionsMetadata: PropTypes.arrayOf(
89
+ PropTypes.arrayOf(
90
+ PropTypes.shape({
91
+ value: PropTypes.oneOfType([PropTypes.bool, PropTypes.string, PropTypes.number]),
92
+ label: PropTypes.string
93
+ })
94
+ )
95
+ ).isRequired,
82
96
  showLabel: PropTypes.bool,
83
97
  label: PropTypes.string,
84
98
  getPConnect: PropTypes.func.isRequired,
99
+ template: PropTypes.string.isRequired,
85
100
  showHighlightedData: PropTypes.bool
86
101
  };
@@ -1,4 +1,8 @@
1
- /* eslint-disable no-undef */
1
+ import { createUID } from '@pega/cosmos-react-core';
2
+
3
+ //import { LazyMap as LazyComponentMap } from '../../components_map';
4
+
5
+ const LazyComponentMap = {};
2
6
 
3
7
  /**
4
8
  * Given the PConnect object of a Template component, retrieve the children
@@ -39,7 +43,78 @@ export function getAllFields(pConnect) {
39
43
  return allFields;
40
44
  }
41
45
 
46
+ /**
47
+ * A helper function to create an object consisting react component as per the type.
48
+ * This is used by CaseSummary template.
49
+ * @param {object} configObject Object containing meta information for the particular field authored
50
+ * @param {Function} getPConnect PConnect function passed along to other components.
51
+ * @param {string} displayMode displayMode string contains information about the layout of component in review mode.
52
+ */
53
+ export function prepareComponentInCaseSummary(configObject, getPConnect, displayMode) {
54
+ const { config, children } = configObject;
55
+ let { type } = configObject;
56
+ const caseSummaryComponentObject = {};
57
+ let showAddressLabel = true;
58
+ if (config && config.value === '@P .pyStatusWork') {
59
+ config.displayAsStatus = true;
60
+ type = 'TextInput'; // force the type to be TextInput for status field.
61
+ // As TextInput is loaded forcefully sometimes, TextInput component might not be available in lazy map.
62
+ // Load TextInput if it is not available.
63
+ if (!LazyComponentMap[type]) {
64
+ PCore.getAssetLoader().getLoader('component-loader')([type]);
65
+ }
66
+ }
67
+
68
+ caseSummaryComponentObject.name = getPConnect().resolveConfigProps({
69
+ label: config.label
70
+ }).label;
71
+ if (type === 'CaseOperator') {
72
+ switch (caseSummaryComponentObject.name) {
73
+ case 'Create operator':
74
+ caseSummaryComponentObject.name = getPConnect().resolveConfigProps({
75
+ createLabel: config.createLabel
76
+ }).createLabel;
77
+ break;
78
+ case 'Update operator':
79
+ caseSummaryComponentObject.name = getPConnect().resolveConfigProps({
80
+ updateLabel: config.updateLabel
81
+ }).updateLabel;
82
+ break;
83
+ default:
84
+ caseSummaryComponentObject.name = getPConnect().resolveConfigProps({
85
+ resolveLabel: config.resolveLabel
86
+ }).resolveLabel;
87
+ break;
88
+ }
89
+ } else if (type === 'Checkbox') {
90
+ caseSummaryComponentObject.name = getPConnect().resolveConfigProps({
91
+ label: config.caption
92
+ }).label;
93
+ } else if (type === 'Address') {
94
+ showAddressLabel = false;
95
+ }
96
+ const createdComponent = getPConnect().createComponent({
97
+ type,
98
+ children: children ? [...children] : [],
99
+ showAddressLabel,
100
+ config: {
101
+ ...config,
102
+ hideLabel: true,
103
+ key: createUID() // Need a unique key on render of the summary so that the component is recreated each time
104
+ }
105
+ });
106
+ createdComponent.props.getPConnect().setInheritedProp('displayMode', displayMode);
107
+ if (type === 'Address') {
108
+ createdComponent.props.getPConnect().setInheritedProp('showAddressLabel', showAddressLabel);
109
+ }
110
+ // createdComponent.props.getPConnect().setInheritedProp("hideLabel", true);
111
+ caseSummaryComponentObject.value = createdComponent;
112
+ if (type === 'reference') {
113
+ caseSummaryComponentObject.name = createdComponent.props.getPConnect().getInheritedProps().label;
114
+ }
42
115
 
116
+ return caseSummaryComponentObject;
117
+ }
43
118
 
44
119
  export function getFilteredFields(getPConnect) {
45
120
  let primaryFieldsRaw;
@@ -137,9 +212,8 @@ export function getInstructions(pConnect, instructions = 'casestep') {
137
212
 
138
213
  // If the annotation wasn't processed correctly, don't return any instruction text
139
214
  if (instructions?.startsWith('@PARAGRAPH')) {
140
- /* eslint-disable no-console */
141
215
  console.error('@PARAGRAPH annotation was not processed. Hiding custom instructions.');
142
- /* eslint-enable no-console */ return undefined;
216
+ return undefined;
143
217
  }
144
218
 
145
219
  // Custom instructions from the view
@@ -1,5 +1,5 @@
1
- import { Fragment } from 'react';
2
- import { Grid, Flex, FieldGroup } from '@pega/cosmos-react-core';
1
+ import { useContext, Fragment } from 'react';
2
+ import { Grid , Flex, FieldGroup } from '@pega/cosmos-react-core';
3
3
  import PropTypes from 'prop-types';
4
4
 
5
5
  import Styled{{COMPONENT_CLASS_NAME}}Wrapper from './styles';
@@ -13,19 +13,13 @@ import { getAllFields } from './utils';
13
13
  // any default values in config.pros should be set in defaultProps at bottom of this file
14
14
  export default function {{COMPONENT_CLASS_NAME}}(props) {
15
15
 
16
- const { getPConnect, children, label, showLabel, showHighlightedData } = props;
16
+
17
+ const { getPConnect, children, template, regionsMetadata = [], label, showLabel, showHighlightedData } = props;
18
+
17
19
  const propsToUse = { label, showLabel, ...getPConnect().getInheritedProps() };
18
20
 
19
- const numRegions = getAllFields(getPConnect)?.length;
20
- const gridRepeat = "repeat(".concat(numRegions).concat(", 1fr)");
21
- const gridContainer = { "colGap": 1};
22
- gridContainer.cols = gridRepeat;
23
- gridContainer.alignItems = 'start';
24
21
 
25
- const gridHighlightContainer = { "gap": 2};
26
- gridHighlightContainer.cols = gridRepeat;
27
- gridHighlightContainer.alignItems = 'start';
28
- gridHighlightContainer.pad = [0, 0, 2, 0];
22
+ const numRegions = regionsMetadata.length;
29
23
 
30
24
  // Set up highlighted data to pass in return if is set to show, need raw metadata to pass to createComponent
31
25
  let highlightedDataArr = [];
@@ -50,14 +44,14 @@ export default function {{COMPONENT_CLASS_NAME}}(props) {
50
44
  {{=<% %>=}}
51
45
  <FieldGroup name={propsToUse.showLabel ? propsToUse.label : ''}>
52
46
  {showHighlightedData && highlightedDataArr.length > 0 && (
53
- <Grid container={gridHighlightContainer}
47
+ <Grid container={{ cols:'repeat(${numRegions}, 1fr)', gap: 2, alignItems: 'start', pad: [0, 0, 2, 0] }}
54
48
  data-testid={`highlighted-column-count-${numRegions}`}>
55
49
  {highlightedDataArr.map((child, i) => (
56
50
  <Fragment key={`hf-${i + 1}`}>{child}</Fragment>
57
51
  ))}
58
52
  </Grid>
59
53
  )}
60
- <Grid container={gridContainer} data-testid={`column-count-${numRegions}`} >
54
+ <Grid container={{ cols:'repeat(${numRegions}, 1fr)', alignItems: 'start', colGap: 1 }} data-testid={`column-count-${numRegions}`} >
61
55
  {children.map((child, i) => (
62
56
  <Flex container={{ direction: 'column'}} key={`r-${i + 1}`}>
63
57
  {child}
@@ -77,10 +71,31 @@ export default function {{COMPONENT_CLASS_NAME}}(props) {
77
71
  showHighlightedData: false
78
72
  };
79
73
 
74
+ // Since the fields are not part of the 'config' in Details template metadata, they need to be subscribed with additionalprops
75
+ const mapStateToProps = (_, ownProps) => {
76
+ const { getPConnect, showLabel, label } = ownProps;
77
+ const Allfields = getAllFields(getPConnect);
78
+
79
+ return {
80
+ regionsMetadata: Allfields,
81
+ label,
82
+ showLabel,
83
+ getPConnect
84
+ };
85
+ };
80
86
 
81
87
  {{COMPONENT_CLASS_NAME}}.propTypes = {
88
+ regionsMetadata: PropTypes.arrayOf(
89
+ PropTypes.arrayOf(
90
+ PropTypes.shape({
91
+ value: PropTypes.oneOfType([PropTypes.bool, PropTypes.string, PropTypes.number]),
92
+ label: PropTypes.string
93
+ })
94
+ )
95
+ ).isRequired,
82
96
  showLabel: PropTypes.bool,
83
97
  label: PropTypes.string,
84
98
  getPConnect: PropTypes.func.isRequired,
99
+ template: PropTypes.string.isRequired,
85
100
  showHighlightedData: PropTypes.bool
86
101
  };
@@ -1,6 +1,8 @@
1
- /* eslint-disable no-undef */
1
+ import { createUID } from '@pega/cosmos-react-core';
2
2
 
3
+ //import { LazyMap as LazyComponentMap } from '../../components_map';
3
4
 
5
+ const LazyComponentMap = {};
4
6
 
5
7
  /**
6
8
  * Given the PConnect object of a Template component, retrieve the children
@@ -41,7 +43,78 @@ export function getAllFields(pConnect) {
41
43
  return allFields;
42
44
  }
43
45
 
46
+ /**
47
+ * A helper function to create an object consisting react component as per the type.
48
+ * This is used by CaseSummary template.
49
+ * @param {object} configObject Object containing meta information for the particular field authored
50
+ * @param {Function} getPConnect PConnect function passed along to other components.
51
+ * @param {string} displayMode displayMode string contains information about the layout of component in review mode.
52
+ */
53
+ export function prepareComponentInCaseSummary(configObject, getPConnect, displayMode) {
54
+ const { config, children } = configObject;
55
+ let { type } = configObject;
56
+ const caseSummaryComponentObject = {};
57
+ let showAddressLabel = true;
58
+ if (config && config.value === '@P .pyStatusWork') {
59
+ config.displayAsStatus = true;
60
+ type = 'TextInput'; // force the type to be TextInput for status field.
61
+ // As TextInput is loaded forcefully sometimes, TextInput component might not be available in lazy map.
62
+ // Load TextInput if it is not available.
63
+ if (!LazyComponentMap[type]) {
64
+ PCore.getAssetLoader().getLoader('component-loader')([type]);
65
+ }
66
+ }
44
67
 
68
+ caseSummaryComponentObject.name = getPConnect().resolveConfigProps({
69
+ label: config.label
70
+ }).label;
71
+ if (type === 'CaseOperator') {
72
+ switch (caseSummaryComponentObject.name) {
73
+ case 'Create operator':
74
+ caseSummaryComponentObject.name = getPConnect().resolveConfigProps({
75
+ createLabel: config.createLabel
76
+ }).createLabel;
77
+ break;
78
+ case 'Update operator':
79
+ caseSummaryComponentObject.name = getPConnect().resolveConfigProps({
80
+ updateLabel: config.updateLabel
81
+ }).updateLabel;
82
+ break;
83
+ default:
84
+ caseSummaryComponentObject.name = getPConnect().resolveConfigProps({
85
+ resolveLabel: config.resolveLabel
86
+ }).resolveLabel;
87
+ break;
88
+ }
89
+ } else if (type === 'Checkbox') {
90
+ caseSummaryComponentObject.name = getPConnect().resolveConfigProps({
91
+ label: config.caption
92
+ }).label;
93
+ } else if (type === 'Address') {
94
+ showAddressLabel = false;
95
+ }
96
+ const createdComponent = getPConnect().createComponent({
97
+ type,
98
+ children: children ? [...children] : [],
99
+ showAddressLabel,
100
+ config: {
101
+ ...config,
102
+ hideLabel: true,
103
+ key: createUID() // Need a unique key on render of the summary so that the component is recreated each time
104
+ }
105
+ });
106
+ createdComponent.props.getPConnect().setInheritedProp('displayMode', displayMode);
107
+ if (type === 'Address') {
108
+ createdComponent.props.getPConnect().setInheritedProp('showAddressLabel', showAddressLabel);
109
+ }
110
+ // createdComponent.props.getPConnect().setInheritedProp("hideLabel", true);
111
+ caseSummaryComponentObject.value = createdComponent;
112
+ if (type === 'reference') {
113
+ caseSummaryComponentObject.name = createdComponent.props.getPConnect().getInheritedProps().label;
114
+ }
115
+
116
+ return caseSummaryComponentObject;
117
+ }
45
118
 
46
119
  export function getFilteredFields(getPConnect) {
47
120
  let primaryFieldsRaw;
@@ -139,9 +212,7 @@ export function getInstructions(pConnect, instructions = 'casestep') {
139
212
 
140
213
  // If the annotation wasn't processed correctly, don't return any instruction text
141
214
  if (instructions?.startsWith('@PARAGRAPH')) {
142
- /* eslint-disable no-console */
143
215
  console.error('@PARAGRAPH annotation was not processed. Hiding custom instructions.');
144
- /* eslint-enable no-console */
145
216
  return undefined;
146
217
  }
147
218
 
@@ -1,4 +1,5 @@
1
- import { Grid } from '@pega/cosmos-react-core';
1
+ import { useContext } from 'react';
2
+ import { Grid , Flex } from '@pega/cosmos-react-core';
2
3
  import PropTypes from 'prop-types';
3
4
 
4
5
  import Styled{{COMPONENT_CLASS_NAME}}Wrapper from './styles';
@@ -11,11 +12,11 @@ import Styled{{COMPONENT_CLASS_NAME}}Wrapper from './styles';
11
12
  export default function {{COMPONENT_CLASS_NAME}}(props) {
12
13
 
13
14
 
14
- const { children, NumCols } = props;
15
+ const { getPConnect, children, template, label, NumCols } = props;
15
16
 
16
- const nCols = parseInt(NumCols, 10);
17
+ let nCols = parseInt(NumCols);
17
18
 
18
- // console.log(`Rendering ${getPConnect()?.getComponentName()} with ${template} with ${children?.length} Region(s)`);
19
+ //console.log(`Rendering ${getPConnect()?.getComponentName()} with ${template} with ${children?.length} Region(s)`);
19
20
 
20
21
  return (
21
22
  <Styled{{COMPONENT_CLASS_NAME}}Wrapper>
@@ -36,10 +37,13 @@ export default function {{COMPONENT_CLASS_NAME}}(props) {
36
37
 
37
38
  {{COMPONENT_CLASS_NAME}}.defaultProps = {
38
39
  NumCols: 1,
40
+ templateOverrideMode: 'USE_TEMPLATE',
39
41
  children: []
40
42
  };
41
43
 
42
44
  {{COMPONENT_CLASS_NAME}}.propTypes = {
43
- NumCols: PropTypes.number,
44
- children: PropTypes.arrayOf(PropTypes.node),
45
+ label: PropTypes.string,
46
+ getPConnect: PropTypes.func.isRequired,
47
+ children: PropTypes.arrayOf(PropTypes.node).isRequired,
48
+ template: PropTypes.string.isRequired
45
49
  };
@@ -1,4 +1,5 @@
1
- import { Grid, Flex } from '@pega/cosmos-react-core';
1
+ import { useContext } from 'react';
2
+ import { Grid , Flex } from '@pega/cosmos-react-core';
2
3
  import PropTypes from 'prop-types';
3
4
 
4
5
  import Styled{{COMPONENT_CLASS_NAME}}Wrapper from './styles';
@@ -11,19 +12,13 @@ import Styled{{COMPONENT_CLASS_NAME}}Wrapper from './styles';
11
12
  export default function {{COMPONENT_CLASS_NAME}}(props) {
12
13
 
13
14
 
14
- const { children } = props;
15
-
16
- const numRegions = children?.length;
17
- const gridRepeat = "repeat(".concat(numRegions).concat(", 1fr)");
18
- const gridContainer = {"colGap" : 1};
19
- gridContainer.cols = gridRepeat;
20
- gridContainer.alignItems = 'start';
15
+ const { getPConnect, children, template, label } = props;
21
16
 
22
17
  return (
23
18
  <Styled{{COMPONENT_CLASS_NAME}}Wrapper>
24
19
  {{! pick new delimiteres for mustache }}
25
20
  {{=<% %>=}}
26
- <Grid container={gridContainer}>
21
+ <Grid container={{ cols:'repeat(2, 1fr)', alignItems: 'start', colGap: 1 }}>
27
22
  {children.map((child, i) => (
28
23
  <Flex container={{ direction: 'column'}} key={`r-${i + 1}`}>
29
24
  {child}
@@ -41,5 +36,8 @@ export default function {{COMPONENT_CLASS_NAME}}(props) {
41
36
  };
42
37
 
43
38
  {{COMPONENT_CLASS_NAME}}.propTypes = {
44
- children: PropTypes.arrayOf(PropTypes.node),
39
+ label: PropTypes.string,
40
+ getPConnect: PropTypes.func.isRequired,
41
+ children: PropTypes.arrayOf(PropTypes.node).isRequired,
42
+ template: PropTypes.string.isRequired
45
43
  };
@@ -1,4 +1,3 @@
1
- /* eslint-disable no-undef */
2
1
  import { Button, useToaster } from '@pega/cosmos-react-core';
3
2
 
4
3
  export default function GetNextWork(props) {
@@ -9,16 +8,11 @@ export default function GetNextWork(props) {
9
8
  const localizedVal = PCore.getLocaleUtils().getLocaleValue;
10
9
 
11
10
  const getNextWork = () => {
12
-
13
- // alert('Get next work clicked');
14
-
15
11
  getPConnect()
16
12
  .getActionsApi()
17
13
  .getNextWork()
18
14
  .catch((err) => {
19
- /* eslint-disable no-console */
20
15
  console.log(err);
21
- /* eslint-enable no-console */
22
16
  if (err[0].status === 404) {
23
17
  toasterCtx.push({
24
18
  content: localizedVal('No task currently available')
@@ -1,19 +1,19 @@
1
1
  import { useMemo, Children } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { OneColumnPage as OneColumn } from '@pega/cosmos-react-core';
4
+ import { registerIcon } from '@pega/cosmos-react-core';
4
5
  import { ConfigurableLayout } from '@pega/cosmos-react-work'
5
- // import { registerIcon } from '@pega/cosmos-react-core';
6
6
 
7
7
  // temp
8
- // import * as headlineIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/headline.icon';
8
+ //import * as headlineIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/headline.icon';
9
9
 
10
10
  import Styled{{COMPONENT_CLASS_NAME}}Wrapper from './styles';
11
11
 
12
- import GetNextWork from './GetNextWork.jsx';
12
+ import GetNextWork from './GetNextWork';
13
13
  import { getLayoutDataFromRegion } from './utils';
14
14
 
15
15
  // temp
16
- // registerIcon(headlineIcon);
16
+ //registerIcon(headlineIcon);
17
17
 
18
18
  // currently getting 'icon' from props is not supported with iconRegistry
19
19
  // have to manually get icon, so can't determine a runtime for now
@@ -27,9 +27,7 @@ import { getLayoutDataFromRegion } from './utils';
27
27
  // any default values in config.pros should be set in defaultProps at bottom of this file
28
28
  export default function {{COMPONENT_CLASS_NAME}}(props) {
29
29
 
30
- // add back in icon when working
31
- // const { children, title, icon, useConfigurableLayout, getPConnect, enableGetNextWork } = props;
32
- const { children, title, useConfigurableLayout, getPConnect, enableGetNextWork } = props;
30
+ const { children, title, icon, useConfigurableLayout, getPConnect, enableGetNextWork } = props;
33
31
  const childArray = useMemo(() => {
34
32
  return Children.toArray(children);
35
33
  }, [children]);
@@ -58,13 +56,13 @@ export default function {{COMPONENT_CLASS_NAME}}(props) {
58
56
  }
59
57
 
60
58
  {{COMPONENT_CLASS_NAME}}.defaultProps = {
61
- /* icon: '', */
59
+ icon: '',
62
60
  useConfigurableLayout: false
63
61
  };
64
62
 
65
63
  {{COMPONENT_CLASS_NAME}}.propTypes = {
66
64
  children: PropTypes.arrayOf(PropTypes.node).isRequired,
67
65
  title: PropTypes.string.isRequired,
68
- /* icon: PropTypes.string, */
66
+ icon: PropTypes.string,
69
67
  useConfigurableLayout: PropTypes.bool
70
68
  };
@@ -1,7 +1,6 @@
1
- /* eslint-disable no-undef */
2
1
  import { createUID } from '@pega/cosmos-react-core';
3
2
 
4
- // import { LazyMap as LazyComponentMap } from '../../components_map';
3
+ //import { LazyMap as LazyComponentMap } from '../../components_map';
5
4
 
6
5
  const LazyComponentMap = {};
7
6
 
@@ -213,9 +212,7 @@ export function getInstructions(pConnect, instructions = 'casestep') {
213
212
 
214
213
  // If the annotation wasn't processed correctly, don't return any instruction text
215
214
  if (instructions?.startsWith('@PARAGRAPH')) {
216
- /* eslint-disable no-console */
217
215
  console.error('@PARAGRAPH annotation was not processed. Hiding custom instructions.');
218
- /* eslint-enable no-console */
219
216
  return undefined;
220
217
  }
221
218
 
@@ -1,4 +1,3 @@
1
- /* eslint-disable no-undef */
2
1
  import { useState, useEffect } from 'react';
3
2
  import PropTypes from 'prop-types';
4
3
  import { Table, Text } from '@pega/cosmos-react-core';
@@ -32,17 +32,17 @@ export default function {{COMPONENT_CLASS_NAME}}(props) {
32
32
  }
33
33
 
34
34
  {{COMPONENT_CLASS_NAME}}.defaultProps = {
35
- header: '',
36
- description: '',
37
- image: '',
38
- datasource: [],
39
- whatsnewlink: ''
40
- };
41
-
42
- {{COMPONENT_CLASS_NAME}}.propTypes = {
43
35
  header: PropTypes.string,
44
36
  description: PropTypes.string,
45
37
  datasource: PropTypes.instanceOf(Object),
46
38
  whatsnewlink: PropTypes.string,
47
39
  image: PropTypes.string
48
40
  };
41
+
42
+ {{COMPONENT_CLASS_NAME}}.propTypes = {
43
+ header: '',
44
+ description: '',
45
+ image: '',
46
+ datasource: [],
47
+ whatsnewlink: ''
48
+ };
@@ -1,5 +1,3 @@
1
- /* eslint-disable no-undef */
2
- /* eslint-disable react-hooks/rules-of-hooks */
3
1
  import { useEffect, useState } from 'react';
4
2
  import PropTypes from 'prop-types';
5
3
  import { Avatar as CosmosAvatar } from '@pega/cosmos-react-core';
@@ -1,4 +1,3 @@
1
- /* eslint-disable no-undef */
2
1
  import { useState, useEffect, Fragment } from 'react';
3
2
  import {
4
3
  Link,
@@ -14,7 +13,7 @@ import {
14
13
  import { Glimpse } from '@pega/cosmos-react-work';
15
14
  import PropTypes from 'prop-types';
16
15
 
17
- import Avatar from './Avatar.jsx';
16
+ import Avatar from './Avatar';
18
17
 
19
18
  const Operator = (props) => {
20
19
  const { id, name, label, testId, helperText, externalUser, metaObj } = props;