@pega/custom-dx-components 2.0.8 → 2.0.10

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 (144) hide show
  1. package/package.json +1 -1
  2. package/src/constants.js +29 -7
  3. package/src/tasks/create/index.js +46 -6
  4. package/src/tasks/create/templates/Constellation/Field/Boolean/Boolean.js.mustache +38 -0
  5. package/src/tasks/create/templates/Constellation/Field/Boolean/boolean-format.js.mustache +26 -0
  6. package/src/tasks/create/templates/Constellation/Field/Boolean/config.json.mustache +145 -0
  7. package/src/tasks/create/templates/Constellation/Field/Boolean/demo.stories.jsx.mustache +44 -0
  8. package/src/tasks/create/templates/Constellation/Field/Boolean/event-utils.js.mustache +18 -0
  9. package/src/tasks/create/templates/Constellation/Field/Boolean/index.jsx.mustache +171 -0
  10. package/src/tasks/create/templates/Constellation/Field/Boolean/styles.js.mustache +7 -0
  11. package/src/tasks/create/templates/Constellation/Field/Date/config.json.mustache +195 -0
  12. package/src/tasks/create/templates/Constellation/Field/Date/date.js.mustache +327 -0
  13. package/src/tasks/create/templates/Constellation/Field/Date/demo.stories.jsx.mustache +44 -0
  14. package/src/tasks/create/templates/Constellation/Field/Date/index.jsx.mustache +254 -0
  15. package/src/tasks/create/templates/Constellation/Field/Date/styles.js.mustache +7 -0
  16. package/src/tasks/create/templates/Constellation/Field/Date/suggestions-handler.js +10 -0
  17. package/src/tasks/create/templates/Constellation/Field/DateTime/config.json.mustache +256 -0
  18. package/src/tasks/create/templates/Constellation/Field/DateTime/date-time.js.mustache +93 -0
  19. package/src/tasks/create/templates/Constellation/Field/DateTime/date-utils.js +286 -0
  20. package/src/tasks/create/templates/Constellation/Field/DateTime/date.js.mustache +327 -0
  21. package/src/tasks/create/templates/Constellation/Field/DateTime/demo.stories.jsx.mustache +44 -0
  22. package/src/tasks/create/templates/Constellation/Field/DateTime/index.jsx.mustache +252 -0
  23. package/src/tasks/create/templates/Constellation/Field/DateTime/styles.js.mustache +7 -0
  24. package/src/tasks/create/templates/Constellation/Field/DateTime/suggestions-handler.js +10 -0
  25. package/src/tasks/create/templates/Constellation/Field/Decimal/config.json.mustache +278 -0
  26. package/src/tasks/create/templates/Constellation/Field/Decimal/demo.stories.jsx.mustache +44 -0
  27. package/src/tasks/create/templates/Constellation/Field/Decimal/event-utils.js.mustache +18 -0
  28. package/src/tasks/create/templates/Constellation/Field/Decimal/index.jsx.mustache +272 -0
  29. package/src/tasks/create/templates/Constellation/Field/Decimal/styles.js.mustache +7 -0
  30. package/src/tasks/create/templates/Constellation/Field/Decimal/suggestions-handler.js +10 -0
  31. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/config.json.mustache +291 -0
  32. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/demo.stories.jsx.mustache +44 -0
  33. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/event-utils.js.mustache +18 -0
  34. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/index.jsx.mustache +300 -0
  35. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/styles.js.mustache +7 -0
  36. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/suggestions-handler.js +10 -0
  37. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/config.json.mustache +93 -0
  38. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/demo.stories.jsx.mustache +44 -0
  39. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/event-utils.js.mustache +18 -0
  40. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/index.jsx.mustache +275 -0
  41. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/styles.js.mustache +7 -0
  42. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/suggestions-handler.js +10 -0
  43. package/src/tasks/create/templates/Constellation/Field/Integer/config.json.mustache +347 -0
  44. package/src/tasks/create/templates/Constellation/Field/Integer/demo.stories.jsx.mustache +44 -0
  45. package/src/tasks/create/templates/Constellation/Field/Integer/event-utils.js.mustache +18 -0
  46. package/src/tasks/create/templates/Constellation/Field/Integer/index.jsx.mustache +335 -0
  47. package/src/tasks/create/templates/Constellation/Field/Integer/styles.js.mustache +7 -0
  48. package/src/tasks/create/templates/Constellation/Field/Integer/suggestions-handler.js +10 -0
  49. package/src/tasks/create/templates/Constellation/Field/Picklist/config.json.mustache +114 -0
  50. package/src/tasks/create/templates/Constellation/Field/Picklist/demo.stories.jsx.mustache +44 -0
  51. package/src/tasks/create/templates/Constellation/Field/Picklist/event-utils.js.mustache +18 -0
  52. package/src/tasks/create/templates/Constellation/Field/Picklist/index.jsx.mustache +308 -0
  53. package/src/tasks/create/templates/Constellation/Field/Picklist/picklist.js.mustache +43 -0
  54. package/src/tasks/create/templates/Constellation/Field/Picklist/styles.js.mustache +7 -0
  55. package/src/tasks/create/templates/Constellation/Field/Picklist/suggestions-handler.js +10 -0
  56. package/src/tasks/create/templates/Constellation/Field/Text/config.json.mustache +62 -0
  57. package/src/tasks/create/templates/Constellation/Field/Text/demo.stories.jsx.mustache +44 -0
  58. package/src/tasks/create/templates/Constellation/Field/Text/index.jsx.mustache +60 -0
  59. package/src/tasks/create/templates/Constellation/Field/Text/styles.js.mustache +7 -0
  60. package/src/tasks/create/templates/Constellation/Field/Text-Email/config.json.mustache +111 -0
  61. package/src/tasks/create/templates/Constellation/Field/Text-Email/demo.stories.jsx.mustache +44 -0
  62. package/src/tasks/create/templates/Constellation/Field/Text-Email/event-utils.js.mustache +18 -0
  63. package/src/tasks/create/templates/Constellation/Field/Text-Email/index.jsx.mustache +189 -0
  64. package/src/tasks/create/templates/Constellation/Field/Text-Email/styles.js.mustache +7 -0
  65. package/src/tasks/create/templates/Constellation/Field/Text-Email/suggestions-handler.js +10 -0
  66. package/src/tasks/create/templates/Constellation/Field/Text-Email/text-email.js.mustache +43 -0
  67. package/src/tasks/create/templates/Constellation/Field/Text-Input/StatusWork.js +27 -0
  68. package/src/tasks/create/templates/Constellation/Field/Text-Input/config.json.mustache +111 -0
  69. package/src/tasks/create/templates/Constellation/Field/Text-Input/demo.stories.jsx.mustache +44 -0
  70. package/src/tasks/create/templates/Constellation/Field/Text-Input/event-utils.js.mustache +18 -0
  71. package/src/tasks/create/templates/Constellation/Field/Text-Input/index.jsx.mustache +196 -0
  72. package/src/tasks/create/templates/Constellation/Field/Text-Input/styles.js.mustache +7 -0
  73. package/src/tasks/create/templates/Constellation/Field/Text-Input/suggestions-handler.js +10 -0
  74. package/src/tasks/create/templates/Constellation/Field/Text-Input/text-input.js.mustache +43 -0
  75. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/config.json.mustache +111 -0
  76. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/demo.stories.jsx.mustache +44 -0
  77. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/event-utils.js.mustache +18 -0
  78. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/index.jsx.mustache +189 -0
  79. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/styles.js.mustache +7 -0
  80. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/suggestions-handler.js +10 -0
  81. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/text-paragraph.js.mustache +43 -0
  82. package/src/tasks/create/templates/Constellation/Field/Text-Phone/config.json.mustache +123 -0
  83. package/src/tasks/create/templates/Constellation/Field/Text-Phone/demo.stories.jsx.mustache +44 -0
  84. package/src/tasks/create/templates/Constellation/Field/Text-Phone/event-utils.js.mustache +18 -0
  85. package/src/tasks/create/templates/Constellation/Field/Text-Phone/index.jsx.mustache +223 -0
  86. package/src/tasks/create/templates/Constellation/Field/Text-Phone/styles.js.mustache +7 -0
  87. package/src/tasks/create/templates/Constellation/Field/Text-Phone/suggestions-handler.js +10 -0
  88. package/src/tasks/create/templates/Constellation/Field/Text-Phone/text-phone.js.mustache +43 -0
  89. package/src/tasks/create/templates/Constellation/Field/Text-URL/config.json.mustache +237 -0
  90. package/src/tasks/create/templates/Constellation/Field/Text-URL/demo.stories.jsx.mustache +44 -0
  91. package/src/tasks/create/templates/Constellation/Field/Text-URL/event-utils.js.mustache +18 -0
  92. package/src/tasks/create/templates/Constellation/Field/Text-URL/index.jsx.mustache +232 -0
  93. package/src/tasks/create/templates/Constellation/Field/Text-URL/styles.js.mustache +7 -0
  94. package/src/tasks/create/templates/Constellation/Field/Text-URL/suggestions-handler.js +10 -0
  95. package/src/tasks/create/templates/Constellation/Field/Text-URL/text-url.js.mustache +172 -0
  96. package/src/tasks/create/templates/Constellation/Field/TimeofDay/config.json.mustache +185 -0
  97. package/src/tasks/create/templates/Constellation/Field/TimeofDay/demo.stories.jsx.mustache +44 -0
  98. package/src/tasks/create/templates/Constellation/Field/TimeofDay/index.jsx.mustache +213 -0
  99. package/src/tasks/create/templates/Constellation/Field/TimeofDay/styles.js.mustache +7 -0
  100. package/src/tasks/create/templates/Constellation/Field/TimeofDay/suggestions-handler.js +10 -0
  101. package/src/tasks/create/templates/Constellation/Field/TimeofDay/time-of-day.js.mustache +286 -0
  102. package/src/tasks/create/templates/Constellation/Template/DETAILS/OneColumnDetails.svg +22 -0
  103. package/src/tasks/create/templates/Constellation/Template/DETAILS/config.json.mustache +35 -0
  104. package/src/tasks/create/templates/Constellation/Template/DETAILS/index.jsx.mustache +101 -0
  105. package/src/tasks/create/templates/Constellation/Template/DETAILS/styles.js.mustache +7 -0
  106. package/src/tasks/create/templates/Constellation/Template/DETAILS/utils.js.mustache +226 -0
  107. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/TwoColumnDetails.svg +28 -0
  108. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/config.json.mustache +42 -0
  109. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/index.jsx.mustache +101 -0
  110. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/styles.js.mustache +7 -0
  111. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/utils.js.mustache +226 -0
  112. package/src/tasks/create/templates/Constellation/Template/FORM/DefaultForm.svg +29 -0
  113. package/src/tasks/create/templates/Constellation/Template/FORM/config.json.mustache +45 -0
  114. package/src/tasks/create/templates/Constellation/Template/FORM/index.jsx.mustache +49 -0
  115. package/src/tasks/create/templates/Constellation/Template/FORM/styles.js.mustache +7 -0
  116. package/src/tasks/create/templates/Constellation/Template/FORM-region/TwoColumn.svg +38 -0
  117. package/src/tasks/create/templates/Constellation/Template/FORM-region/config.json.mustache +27 -0
  118. package/src/tasks/create/templates/Constellation/Template/FORM-region/index.jsx.mustache +43 -0
  119. package/src/tasks/create/templates/Constellation/Template/FORM-region/styles.js.mustache +7 -0
  120. package/src/tasks/create/templates/Constellation/Template/PAGE/GetNextWork.js.mustache +29 -0
  121. package/src/tasks/create/templates/Constellation/Template/PAGE/OneColumnPage.svg +36 -0
  122. package/src/tasks/create/templates/Constellation/Template/PAGE/config.json.mustache +32 -0
  123. package/src/tasks/create/templates/Constellation/Template/PAGE/index.jsx.mustache +68 -0
  124. package/src/tasks/create/templates/Constellation/Template/PAGE/localizations.json.mustache +4 -0
  125. package/src/tasks/create/templates/Constellation/Template/PAGE/styles.js.mustache +7 -0
  126. package/src/tasks/create/templates/Constellation/Template/PAGE/utils.js.mustache +226 -0
  127. package/src/tasks/create/templates/Constellation/Widget/CASE/OneColumnPage.svg +36 -0
  128. package/src/tasks/create/templates/Constellation/Widget/CASE/config.json.mustache +23 -0
  129. package/src/tasks/create/templates/Constellation/Widget/CASE/index.jsx.mustache +75 -0
  130. package/src/tasks/create/templates/Constellation/Widget/CASE/styles.js.mustache +7 -0
  131. package/src/tasks/create/templates/Constellation/Widget/PAGE/OneColumnPage.svg +36 -0
  132. package/src/tasks/create/templates/Constellation/Widget/PAGE/config.json.mustache +59 -0
  133. package/src/tasks/create/templates/Constellation/Widget/PAGE/index.jsx.mustache +48 -0
  134. package/src/tasks/create/templates/Constellation/Widget/PAGE/styles.js.mustache +7 -0
  135. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/Avatar.js.mustache +73 -0
  136. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/OneColumnPage.svg +36 -0
  137. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/Operator.js.mustache +239 -0
  138. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/config.json.mustache +66 -0
  139. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/index.jsx.mustache +110 -0
  140. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/styles.js.mustache +7 -0
  141. package/src/tasks/init/template/package.json.mustache +6 -1
  142. package/src/tasks/publish/bundle/builder/index.js +49 -5
  143. package/src/tasks/publish/bundle/builder/webpack.config.js +7 -3
  144. package/src/tasks/validator/index.js +107 -8
@@ -0,0 +1,28 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <svg width="100px" height="70px" viewBox="0 0 100 70" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
3
+ <title>2 col </title>
4
+ <g id="Page-Config" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
5
+ <g id="Page-layouts" transform="translate(-847.000000, -84.000000)">
6
+ <g id="2-col-" transform="translate(847.000000, 84.000000)">
7
+ <rect id="bg" stroke="#A5A8BC" stroke-width="0.5" fill="#E7E9EB" x="0.25" y="0.25" width="99.5" height="69.5"></rect>
8
+ <g id="white" transform="translate(3.000000, 3.000000)" fill="#FFFFFF">
9
+ <rect id="Rectangle" x="0" y="0" width="94" height="66.5"></rect>
10
+ </g>
11
+ <g id="gray-copy-2" transform="translate(6.000000, 6.000000)" fill="#8084A7">
12
+ <rect id="Rectangle" x="0" y="-2.84217094e-14" width="42" height="63.8"></rect>
13
+ <rect id="Rectangle" x="46" y="-2.84217094e-14" width="42" height="63.8"></rect>
14
+ </g>
15
+ <g id="labels-copy" transform="translate(22.000000, 17.000000)" fill="#FFFFFF" font-family="OpenSans-Semibold, Open Sans" font-size="11" font-weight="500">
16
+ <text id="B">
17
+ <tspan x="45.75" y="12">B</tspan>
18
+ </text>
19
+ <g id="labels">
20
+ <text id="A">
21
+ <tspan x="0.75" y="12">A</tspan>
22
+ </text>
23
+ </g>
24
+ </g>
25
+ </g>
26
+ </g>
27
+ </g>
28
+ </svg>
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "{{COMPONENT_KEY}}",
3
+ "label": "{{COMPONENT_LABEL}}",
4
+ "description": "{{DESCRIPTION}}",
5
+ "organization": "{{ORGANIZATION}}",
6
+ "version": "{{VERSION}}",
7
+ "library": "{{LIBRARY}}",
8
+ "allowedApplications": {{{ALLOWEDAPPS}}},
9
+ "componentKey": "{{COMPONENT_KEY}}",
10
+ "type": "{{TYPE}}",
11
+ "subtype": {{{SUB_TYPE}}},
12
+ "icon": "TwoColumnDetails.svg",
13
+ "properties": [
14
+ {
15
+ "name": "showHighlightedData",
16
+ "label": "Enable highlighted fields",
17
+ "format": "BOOLEAN"
18
+ },
19
+ {
20
+ "name": "highlightedData",
21
+ "label": "Highlighted fields",
22
+ "format": "CONTENTPICKER",
23
+ "addTypeList": ["Fields"],
24
+ "visibility": "$this.showHighlightedData = true",
25
+ "saveToConfig": true
26
+ },
27
+ {
28
+ "name": "A",
29
+ "label": "Region A",
30
+ "format": "CONTENTPICKER",
31
+ "addTypeList": ["Fields", "Views"],
32
+ "allowCreatingGroup": true
33
+ },
34
+ {
35
+ "name": "B",
36
+ "label": "Region B",
37
+ "format": "CONTENTPICKER",
38
+ "addTypeList": ["Fields", "Views"],
39
+ "allowCreatingGroup": true
40
+ }
41
+ ]
42
+ }
@@ -0,0 +1,101 @@
1
+ import { useContext, Fragment } from 'react';
2
+ import { Grid , Flex, FieldGroup } from '@pega/cosmos-react-core';
3
+ import PropTypes from 'prop-types';
4
+
5
+ import Styled{{COMPONENT_CLASS_NAME}}Wrapper from './styles';
6
+
7
+ // includes in bundle
8
+ import { getAllFields } from './utils';
9
+
10
+ // Duplicated runtime code from Constellation Design System Component
11
+
12
+ // props passed in combination of props from property panel (config.json) and run time props from Constellation
13
+ // any default values in config.pros should be set in defaultProps at bottom of this file
14
+ export default function {{COMPONENT_CLASS_NAME}}(props) {
15
+
16
+
17
+ const { getPConnect, children, template, regionsMetadata = [], label, showLabel, showHighlightedData } = props;
18
+
19
+ const propsToUse = { label, showLabel, ...getPConnect().getInheritedProps() };
20
+
21
+
22
+ const numRegions = regionsMetadata.length;
23
+
24
+ // Set up highlighted data to pass in return if is set to show, need raw metadata to pass to createComponent
25
+ let highlightedDataArr = [];
26
+ if (showHighlightedData) {
27
+ const { highlightedData = [] } = getPConnect().getRawMetadata().config;
28
+ highlightedDataArr = highlightedData.map((field) => {
29
+ field.config.displayMode = 'STACKED_LARGE_VAL';
30
+
31
+ // Mark as status display when using pyStatusWork
32
+ if (field.config.value === '@P .pyStatusWork') {
33
+ field.type = 'TextInput';
34
+ field.config.displayAsStatus = true;
35
+ }
36
+
37
+ return getPConnect().createComponent(field);
38
+ });
39
+ }
40
+
41
+ return (
42
+ <Styled{{COMPONENT_CLASS_NAME}}Wrapper>
43
+ {{! pick new delimiteres for mustache }}
44
+ {{=<% %>=}}
45
+ <FieldGroup name={propsToUse.showLabel ? propsToUse.label : ''}>
46
+ {showHighlightedData && highlightedDataArr.length > 0 && (
47
+ <Grid container={{ cols:'repeat(${numRegions}, 1fr)', gap: 2, alignItems: 'start', pad: [0, 0, 2, 0] }}
48
+ data-testid={`highlighted-column-count-${numRegions}`}>
49
+ {highlightedDataArr.map((child, i) => (
50
+ <Fragment key={`hf-${i + 1}`}>{child}</Fragment>
51
+ ))}
52
+ </Grid>
53
+ )}
54
+ <Grid container={{ cols:'repeat(${numRegions}, 1fr)', alignItems: 'start', colGap: 1 }} data-testid={`column-count-${numRegions}`} >
55
+ {children.map((child, i) => (
56
+ <Flex container={{ direction: 'column'}} key={`r-${i + 1}`}>
57
+ {child}
58
+ </Flex>
59
+ ))}
60
+ </Grid>
61
+ </FieldGroup>
62
+ <%={{ }}=%> {{! revert delimiteres for mustache }}
63
+ </Styled{{COMPONENT_CLASS_NAME}}Wrapper>
64
+ );
65
+
66
+ }
67
+
68
+ {{COMPONENT_CLASS_NAME}}.defaultProps = {
69
+ label: undefined,
70
+ showLabel: true,
71
+ showHighlightedData: false
72
+ };
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
+ };
86
+
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,
96
+ showLabel: PropTypes.bool,
97
+ label: PropTypes.string,
98
+ getPConnect: PropTypes.func.isRequired,
99
+ template: PropTypes.string.isRequired,
100
+ showHighlightedData: PropTypes.bool
101
+ };
@@ -0,0 +1,7 @@
1
+ import styled, { css } from 'styled-components';
2
+
3
+ export default styled.div(() => {
4
+ return css`
5
+ margin: 8px 0;
6
+ `;
7
+ });
@@ -0,0 +1,226 @@
1
+ import { createUID } from '@pega/cosmos-react-core';
2
+
3
+ //import { LazyMap as LazyComponentMap } from '../../components_map';
4
+
5
+ const LazyComponentMap = {};
6
+
7
+ /**
8
+ * Given the PConnect object of a Template component, retrieve the children
9
+ * metadata of all regions.
10
+ * @param {Function} pConnect PConnect of a Template component.
11
+ */
12
+ export function getAllFields(pConnect) {
13
+ const metadata = pConnect().getRawMetadata();
14
+ if (!metadata.children) {
15
+ return [];
16
+ }
17
+
18
+ let allFields = [];
19
+
20
+ const makeField = (f) => ({
21
+ ...pConnect().resolveConfigProps(f.config),
22
+ type: f.type
23
+ });
24
+
25
+ const hasRegions = !!metadata.children[0]?.children;
26
+ if (hasRegions) {
27
+ allFields = metadata.children.map((region) =>
28
+ region.children.map((field) => {
29
+ // Do not resolve the config props if is status work, instead create component here as status badge and mark as status display
30
+ if (field.config?.value === '@P .pyStatusWork') {
31
+ field.type = 'TextInput';
32
+ field.config.displayAsStatus = true;
33
+ return pConnect().createComponent(field);
34
+ }
35
+
36
+ return makeField(field);
37
+ })
38
+ );
39
+ } else {
40
+ allFields = metadata.children.map(makeField);
41
+ }
42
+
43
+ return allFields;
44
+ }
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
+ }
115
+
116
+ return caseSummaryComponentObject;
117
+ }
118
+
119
+ export function getFilteredFields(getPConnect) {
120
+ let primaryFieldsRaw;
121
+ let secondaryFieldsRaw;
122
+ const metadata = getPConnect().getRawMetadata();
123
+ const hasRegions = !!metadata.children[0]?.children;
124
+ if (hasRegions) {
125
+ primaryFieldsRaw = metadata.children[0].children;
126
+ secondaryFieldsRaw = metadata.children[1].children;
127
+ } else {
128
+ [primaryFieldsRaw, secondaryFieldsRaw] = metadata.children;
129
+ }
130
+
131
+ // Filter out fields that are not visible and unsupported types for primary fields (for CaseSummary)
132
+ primaryFieldsRaw = primaryFieldsRaw.filter((item) => {
133
+ const resolvedItem = getPConnect().resolveConfigProps(item.config);
134
+ return resolvedItem.visibility !== false && item.type !== 'TextContent';
135
+ });
136
+
137
+ secondaryFieldsRaw = secondaryFieldsRaw.filter((item) => {
138
+ const resolvedItem = getPConnect().resolveConfigProps(item.config);
139
+ return resolvedItem.visibility !== false && item.type !== 'TextContent';
140
+ });
141
+
142
+ return [primaryFieldsRaw, secondaryFieldsRaw];
143
+ }
144
+
145
+ /**
146
+ * Returns ConfigurableLayout mapped content. With pre-populated default layout configs.
147
+ * @param {object[]} regionData template children item.
148
+ * @returns {object[]} ConfigurableLayout content.
149
+ */
150
+ export function getLayoutDataFromRegion(regionData) {
151
+ const defaultLayoutConfig = {
152
+ width: 'full',
153
+ fillAvailable: true,
154
+ minWidth: [300, 'px']
155
+ };
156
+
157
+ return regionData.props
158
+ ?.getPConnect()
159
+ ?.getChildren()
160
+ ?.map((item, index) => {
161
+ const itemPConnect = item?.getPConnect();
162
+
163
+ return {
164
+ id: itemPConnect?.getComponentName() ? `${itemPConnect.getComponentName()}--${index}` : `item--${index}`,
165
+ content: itemPConnect?.getComponent(),
166
+ layoutConfig: {
167
+ ...defaultLayoutConfig,
168
+ ...itemPConnect?.getConfigProps().layoutConfig
169
+ }
170
+ };
171
+ });
172
+ }
173
+
174
+ /**
175
+ * Determine if the current view is the view of the case step/assignment.
176
+ * @param {Function} pConnect PConnect object for the component
177
+ */
178
+ export function getIsAssignmentView(pConnect) {
179
+ // Get caseInfo content from the store which contains the view info about the current assignment/step
180
+ // TODO To be replaced with pConnect.getCaseInfo().getCurrentAssignmentView when it's available
181
+ const assignmentViewClass = pConnect.getValue(PCore.getConstants().CASE_INFO.CASE_INFO_CLASSID);
182
+ const assignmentViewName = pConnect.getValue(PCore.getConstants().CASE_INFO.ASSIGNMENTACTION_ID);
183
+
184
+ const assignmentViewId = `${assignmentViewName}!${assignmentViewClass}`;
185
+
186
+ // Get the info about the current view from pConnect
187
+ const currentViewId = `${pConnect.getCurrentView()}!${pConnect.getCurrentClassID()}`;
188
+
189
+ return assignmentViewId === currentViewId;
190
+ }
191
+
192
+ /**
193
+ * A hook that gets the instructions content for a view.
194
+ * @param {Function} pConnect PConnect object for the component
195
+ * @param {string} [instructions="casestep"] 'casestep', 'none', or the html content of a Rule-UI-Paragraph rule (processed via core's paragraph annotation handler)
196
+ */
197
+ export function getInstructions(pConnect, instructions = 'casestep') {
198
+ const caseStepInstructions = pConnect.getValue(PCore.getConstants().CASE_INFO.INSTRUCTIONS);
199
+
200
+ // Determine if this view is the current assignment/step view
201
+ const isCurrentAssignmentView = getIsAssignmentView(pConnect);
202
+
203
+ // Case step instructions
204
+ if (instructions === 'casestep' && isCurrentAssignmentView && caseStepInstructions?.length) {
205
+ return caseStepInstructions;
206
+ }
207
+
208
+ // No instructions
209
+ if (instructions === 'none') {
210
+ return undefined;
211
+ }
212
+
213
+ // If the annotation wasn't processed correctly, don't return any instruction text
214
+ if (instructions?.startsWith('@PARAGRAPH')) {
215
+ console.error('@PARAGRAPH annotation was not processed. Hiding custom instructions.');
216
+ return undefined;
217
+ }
218
+
219
+ // Custom instructions from the view
220
+ // The raw metadata for `instructions` will be something like '@PARAGRAPH .SomeParagraphRule' but
221
+ // it is evaluated by core logic to the content
222
+ if (instructions !== 'casestep' && instructions !== 'none') {
223
+ return instructions;
224
+ }
225
+ return undefined;
226
+ }
@@ -0,0 +1,29 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <svg width="100px" height="70px" viewBox="0 0 100 70" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
3
+ <title>2 col copy</title>
4
+ <g id="Views" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
5
+ <g id="Template-icons" transform="translate(-320.000000, -925.000000)">
6
+ <g id="2-col--copy" transform="translate(320.000000, 925.000000)">
7
+ <rect id="bg" stroke="#A5A8BC" stroke-width="0.5" fill="#E7E9EB" x="0.25" y="0.25" width="99.5" height="69.5"></rect>
8
+ <g id="white" transform="translate(3.000000, 3.000000)" fill="#FFFFFF">
9
+ <rect id="Rectangle" x="0" y="0" width="94" height="66.5"></rect>
10
+ </g>
11
+ <g id="gray-copy-2" transform="translate(6.000000, 6.000000)" fill="#8084A7">
12
+ <rect id="Rectangle" x="0" y="-2.84217094e-14" width="42" height="11.8"></rect>
13
+ <rect id="Rectangle" x="46" y="-2.84217094e-14" width="42" height="11.8"></rect>
14
+ <rect id="Rectangle-Copy-5" x="0" y="16" width="42" height="11.8"></rect>
15
+ <rect id="Rectangle-Copy-3" x="46" y="16" width="42" height="11.8"></rect>
16
+ <rect id="Rectangle-Copy-15" x="0" y="32" width="42" height="11.8"></rect>
17
+ <rect id="Rectangle-Copy-14" x="46" y="32" width="42" height="11.8"></rect>
18
+ <rect id="Rectangle-Copy-17" x="0" y="48" width="42" height="11.8"></rect>
19
+ <rect id="Rectangle-Copy-16" x="46" y="48" width="42" height="11.8"></rect>
20
+ </g>
21
+ <g id="Group-7" transform="translate(28.000000, 11.000000)">
22
+ <path id="Line-12-Copy" d="M35.1666667,42.75 L47.1666667,48.5 L35.1666667,54.25 L35.166,49.25 L-0.25,49.25 L-0.25,47.75 L35.166,47.75 L35.1666667,42.75 Z" fill="#1E1F27" fill-rule="nonzero"></path>
23
+ <line x1="0.5" y1="48.5" x2="43.5" y2="32.5" id="Line" stroke="#1E1F27" stroke-width="1.5" stroke-linecap="square"></line>
24
+ <line x1="43.5" y1="32.5" x2="1.5" y2="32.5" id="Line-2" stroke="#1E1F27" stroke-width="1.5" stroke-linecap="square"></line>
25
+ </g>
26
+ </g>
27
+ </g>
28
+ </g>
29
+ </svg>
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "{{COMPONENT_KEY}}",
3
+ "label": "{{COMPONENT_LABEL}}",
4
+ "description": "{{DESCRIPTION}}",
5
+ "organization": "{{ORGANIZATION}}",
6
+ "version": "{{VERSION}}",
7
+ "library": "{{LIBRARY}}",
8
+ "allowedApplications": {{{ALLOWEDAPPS}}},
9
+ "componentKey": "{{COMPONENT_KEY}}",
10
+ "type": "{{TYPE}}",
11
+ "subtype": {{{SUB_TYPE}}},
12
+ "icon": "DefaultForm.svg",
13
+ "properties": [
14
+ {
15
+ "format": "SELECT",
16
+ "name": "NumCols",
17
+ "label": "Number of columns",
18
+ "defaultValue": "1",
19
+ "source": [
20
+ { "key": "1", "value": "One" },
21
+ { "key": "2", "value": "Two" },
22
+ { "key": "3", "value": "Three" }
23
+ ]
24
+ },
25
+ {
26
+ "format": "SELECT",
27
+ "name": "templateOverrideMode",
28
+ "label": "Template for embedded views",
29
+ "defaultValue": "USE_TEMPLATE",
30
+ "source": [
31
+ { "key": "USE_TEMPLATE", "value": "Use template" },
32
+ { "key": "IGNORE_TEMPLATE", "value": "Ignore template" }
33
+ ]
34
+ },
35
+ {
36
+ "format": "INSTRUCTIONS"
37
+ },
38
+ {
39
+ "name": "Fields",
40
+ "label": "Fields",
41
+ "format": "CONTENTPICKER",
42
+ "allowCreatingGroup": true
43
+ }
44
+ ]
45
+ }
@@ -0,0 +1,49 @@
1
+ import { useContext } from 'react';
2
+ import { Grid , Flex } from '@pega/cosmos-react-core';
3
+ import PropTypes from 'prop-types';
4
+
5
+ import Styled{{COMPONENT_CLASS_NAME}}Wrapper from './styles';
6
+
7
+
8
+ // Duplicated runtime code from Constellation Design System Component
9
+
10
+ // props passed in combination of props from property panel (config.json) and run time props from Constellation
11
+ // any default values in config.pros should be set in defaultProps at bottom of this file
12
+ export default function {{COMPONENT_CLASS_NAME}}(props) {
13
+
14
+
15
+ const { getPConnect, children, template, label, NumCols } = props;
16
+
17
+ let nCols = parseInt(NumCols);
18
+
19
+ //console.log(`Rendering ${getPConnect()?.getComponentName()} with ${template} with ${children?.length} Region(s)`);
20
+
21
+ return (
22
+ <Styled{{COMPONENT_CLASS_NAME}}Wrapper>
23
+ {{! pick new delimiteres for mustache }}
24
+ {{=<% %>=}}
25
+ <Grid container={{
26
+ cols: `repeat(${nCols}, minmax(0, 1fr))`,
27
+ gap: 2,
28
+ wrap: `wrap`
29
+ }}>
30
+ {children}
31
+ </Grid>
32
+ <%={{ }}=%> {{! revert delimiteres for mustache }}
33
+ </Styled{{COMPONENT_CLASS_NAME}}Wrapper>
34
+ );
35
+
36
+ }
37
+
38
+ {{COMPONENT_CLASS_NAME}}.defaultProps = {
39
+ NumCols: 1,
40
+ templateOverrideMode: 'USE_TEMPLATE',
41
+ children: []
42
+ };
43
+
44
+ {{COMPONENT_CLASS_NAME}}.propTypes = {
45
+ label: PropTypes.string,
46
+ getPConnect: PropTypes.func.isRequired,
47
+ children: PropTypes.arrayOf(PropTypes.node).isRequired,
48
+ template: PropTypes.string.isRequired
49
+ };
@@ -0,0 +1,7 @@
1
+ import styled, { css } from 'styled-components';
2
+
3
+ export default styled.div(() => {
4
+ return css`
5
+ margin: 8px 0;
6
+ `;
7
+ });
@@ -0,0 +1,38 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <svg width="100px" height="70px" viewBox="0 0 100 70" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
3
+ <title>2-col icon</title>
4
+ <g id="Views" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
5
+ <g id="Artboard-Copy-2" transform="translate(-198.000000, -207.000000)">
6
+ <g id="2-col--icon" transform="translate(198.000000, 207.000000)">
7
+ <rect id="bg" stroke="#A5A8BC" stroke-width="0.5" fill="#E7E9EB" x="0.25" y="0.25" width="99.5" height="69.5"></rect>
8
+ <g id="white" transform="translate(3.000000, 3.000000)" fill="#FFFFFF">
9
+ <rect id="Rectangle" x="0" y="0" width="94" height="66.5"></rect>
10
+ </g>
11
+ <g id="gray" transform="translate(6.000000, 6.000000)" fill="#8084A7">
12
+ <rect id="Rectangle" x="0" y="0" width="42" height="7.8"></rect>
13
+ <rect id="Rectangle-Copy-18" x="0" y="11.7" width="42" height="7.8"></rect>
14
+ <rect id="Rectangle-Copy-19" x="0" y="23.4" width="42" height="7.8"></rect>
15
+ <rect id="Rectangle-Copy-20" x="0" y="35.1" width="42" height="7.8"></rect>
16
+ <rect id="Rectangle-Copy-21" x="0" y="46.8" width="42" height="7.8"></rect>
17
+ <rect id="Rectangle-Copy-22" x="0" y="58.5" width="42" height="5"></rect>
18
+ <rect id="Rectangle-Copy" x="46" y="2.66453526e-15" width="42" height="7.8"></rect>
19
+ <rect id="Rectangle-Copy-27" x="46" y="11.7" width="42" height="7.8"></rect>
20
+ <rect id="Rectangle-Copy-26" x="46" y="23.4" width="42" height="7.8"></rect>
21
+ <rect id="Rectangle-Copy-25" x="46" y="35.1" width="42" height="7.8"></rect>
22
+ <rect id="Rectangle-Copy-24" x="46" y="46.8" width="42" height="7.8"></rect>
23
+ <rect id="Rectangle-Copy-23" x="46" y="58.5" width="42" height="5"></rect>
24
+ </g>
25
+ <g id="labels" transform="translate(16.000000, 11.000000)">
26
+ <circle id="Oval-Copy-3" fill="#FFFFFF" cx="10.5" cy="10.8076923" r="10.5"></circle>
27
+ <text id="A" font-family="OpenSans-Semibold, Open Sans" font-size="11" font-weight="500" fill="#56566F">
28
+ <tspan x="6.75" y="14">A</tspan>
29
+ </text>
30
+ <circle id="Oval-Copy-4" fill="#FFFFFF" cx="56.5" cy="10.8076923" r="10.5"></circle>
31
+ <text id="B" font-family="OpenSans-Semibold, Open Sans" font-size="11" font-weight="500" fill="#56566F">
32
+ <tspan x="52.75" y="14">B</tspan>
33
+ </text>
34
+ </g>
35
+ </g>
36
+ </g>
37
+ </g>
38
+ </svg>
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "{{COMPONENT_KEY}}",
3
+ "label": "{{COMPONENT_LABEL}}",
4
+ "description": "{{DESCRIPTION}}",
5
+ "organization": "{{ORGANIZATION}}",
6
+ "version": "{{VERSION}}",
7
+ "library": "{{LIBRARY}}",
8
+ "allowedApplications": {{{ALLOWEDAPPS}}},
9
+ "componentKey": "{{COMPONENT_KEY}}",
10
+ "type": "{{TYPE}}",
11
+ "subtype": {{{SUB_TYPE}}},
12
+ "icon": "TwoColumn.svg",
13
+ "properties": [
14
+ {
15
+ "name": "A",
16
+ "label": "Region A",
17
+ "format": "CONTENTPICKER",
18
+ "allowCreatingGroup": true
19
+ },
20
+ {
21
+ "name": "B",
22
+ "label": "Region B",
23
+ "format": "CONTENTPICKER",
24
+ "allowCreatingGroup": true
25
+ }
26
+ ]
27
+ }
@@ -0,0 +1,43 @@
1
+ import { useContext } from 'react';
2
+ import { Grid , Flex } from '@pega/cosmos-react-core';
3
+ import PropTypes from 'prop-types';
4
+
5
+ import Styled{{COMPONENT_CLASS_NAME}}Wrapper from './styles';
6
+
7
+
8
+ // Duplicated runtime code from Constellation Design System Component
9
+
10
+ // props passed in combination of props from property panel (config.json) and run time props from Constellation
11
+ // any default values in config.pros should be set in defaultProps at bottom of this file
12
+ export default function {{COMPONENT_CLASS_NAME}}(props) {
13
+
14
+
15
+ const { getPConnect, children, template, label } = props;
16
+
17
+ return (
18
+ <Styled{{COMPONENT_CLASS_NAME}}Wrapper>
19
+ {{! pick new delimiteres for mustache }}
20
+ {{=<% %>=}}
21
+ <Grid container={{ cols:'repeat(2, 1fr)', alignItems: 'start', colGap: 1 }}>
22
+ {children.map((child, i) => (
23
+ <Flex container={{ direction: 'column'}} key={`r-${i + 1}`}>
24
+ {child}
25
+ </Flex>
26
+ ))}
27
+ </Grid>
28
+ <%={{ }}=%> {{! revert delimiteres for mustache }}
29
+ </Styled{{COMPONENT_CLASS_NAME}}Wrapper>
30
+ );
31
+
32
+ }
33
+
34
+ {{COMPONENT_CLASS_NAME}}.defaultProps = {
35
+ children: []
36
+ };
37
+
38
+ {{COMPONENT_CLASS_NAME}}.propTypes = {
39
+ label: PropTypes.string,
40
+ getPConnect: PropTypes.func.isRequired,
41
+ children: PropTypes.arrayOf(PropTypes.node).isRequired,
42
+ template: PropTypes.string.isRequired
43
+ };
@@ -0,0 +1,7 @@
1
+ import styled, { css } from 'styled-components';
2
+
3
+ export default styled.div(() => {
4
+ return css`
5
+ margin: 8px 0;
6
+ `;
7
+ });