@pega/custom-dx-components 2.0.17 → 2.0.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/README.md +1 -1
  2. package/package.json +1 -1
  3. package/src/tasks/create/templates/Constellation/Field/Boolean/demo.stories.jsx.mustache +8 -2
  4. package/src/tasks/create/templates/Constellation/Field/Date/demo.stories.jsx.mustache +11 -6
  5. package/src/tasks/create/templates/Constellation/Field/DateTime/demo.stories.jsx.mustache +11 -7
  6. package/src/tasks/create/templates/Constellation/Field/DateTime/mock.stories.js.mustache +2 -2
  7. package/src/tasks/create/templates/Constellation/Field/Decimal/demo.stories.jsx.mustache +7 -7
  8. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/demo.stories.jsx.mustache +9 -8
  9. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/demo.stories.jsx.mustache +7 -7
  10. package/src/tasks/create/templates/Constellation/Field/Integer/demo.stories.jsx.mustache +7 -7
  11. package/src/tasks/create/templates/Constellation/Field/Picklist/demo.stories.jsx.mustache +16 -10
  12. package/src/tasks/create/templates/Constellation/Field/Text/demo.stories.jsx.mustache +9 -7
  13. package/src/tasks/create/templates/Constellation/Field/Text-Email/demo.stories.jsx.mustache +8 -8
  14. package/src/tasks/create/templates/Constellation/Field/Text-Input/demo.stories.jsx.mustache +7 -7
  15. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/demo.stories.jsx.mustache +7 -7
  16. package/src/tasks/create/templates/Constellation/Field/Text-Phone/demo.stories.jsx.mustache +6 -6
  17. package/src/tasks/create/templates/Constellation/Field/Text-Phone/index.jsx.mustache +1 -1
  18. package/src/tasks/create/templates/Constellation/Field/Text-URL/demo.stories.jsx.mustache +6 -6
  19. package/src/tasks/create/templates/Constellation/Field/Text-URL/index.jsx.mustache +3 -174
  20. package/src/tasks/create/templates/Constellation/Field/Text-URL/text-url.js.mustache +172 -0
  21. package/src/tasks/create/templates/Constellation/Field/TimeofDay/demo.stories.jsx.mustache +10 -5
  22. package/src/tasks/create/templates/Constellation/Template/DETAILS/demo.stories.jsx.mustache +59 -51
  23. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/demo.stories.jsx.mustache +64 -59
  24. package/src/tasks/create/templates/Constellation/Template/FORM/demo.stories.jsx.mustache +43 -39
  25. package/src/tasks/create/templates/Constellation/Template/FORM-region/demo.stories.jsx.mustache +46 -46
  26. package/src/tasks/create/templates/Constellation/Template/PAGE/demo.stories.jsx.mustache +24 -25
  27. package/src/tasks/create/templates/Constellation/Widget/CASE/demo.stories.jsx.mustache +7 -7
  28. package/src/tasks/create/templates/Constellation/Widget/CASE/mock.stories.js.mustache +2 -1
  29. package/src/tasks/create/templates/Constellation/Widget/PAGE/demo.stories.jsx.mustache +1 -1
  30. package/src/tasks/create/templates/Constellation/Widget/PAGE/mock.stories.js.mustache +2 -1
  31. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/demo.stories.jsx.mustache +6 -6
  32. package/src/tasks/init/template/README.md +75 -59
  33. package/src/tasks/init/template/package.json.mustache +2 -2
@@ -1,185 +1,14 @@
1
- import { useState, useEffect, useRef, React} from "react";
2
- import { Input, FieldValueList, Text, EmailDisplay, PhoneDisplay, URLDisplay, Button, Lightbox, Image } from "@pega/cosmos-react-core";
1
+ import { useState, useEffect, useRef} from "react";
2
+ import { Input, FieldValueList, Text } from "@pega/cosmos-react-core";
3
3
  import PropTypes from "prop-types";
4
4
 
5
5
  // includes in bundle
6
+ import {formatExists,textFormatter, urlFormatter, suggestionHandler} from "./text-url";
6
7
  import handleEvent from "./event-utils";
7
8
  import { suggestionsHandler } from './suggestions-handler';
8
9
 
9
10
  import Styled{{COMPONENT_CLASS_NAME}}Wrapper from './styles';
10
11
 
11
- export const formatExists = (formatterVal) => {
12
- const formatterValues = [
13
- "TextInput",
14
- "WorkStatus",
15
- "RichText",
16
- "Email",
17
- "Phone",
18
- "URL",
19
- "Operator"
20
- ];
21
- let isformatter = false;
22
- if (formatterValues.includes(formatterVal)) {
23
- isformatter = true;
24
- }
25
- return isformatter;
26
- };
27
-
28
- const urlLabelVal = (urlLabelSelection, btnVal, urlLabel, propUrlLabel) => {
29
- if ((urlLabel !== '' || propUrlLabel !== '') && btnVal !== null) {
30
- switch (urlLabelSelection) {
31
- case 'constant': {
32
- btnVal = urlLabel;
33
- break;
34
- }
35
- case 'propertyRef': {
36
- btnVal = propUrlLabel;
37
- break;
38
- }
39
- // no default
40
- }
41
- }
42
- return btnVal;
43
- };
44
-
45
- const isImage = (url) => /\.(jpg|jpeg|png|webp|avif|gif|svg)$/.test(url);
46
-
47
- const TableImage = (imageProps) => {
48
- const { value, altText, altTextOfImage, propaltTextOfImage, urlLabelSelection, urlLabel, propUrlLabel } = imageProps;
49
- const demoButtonRef = useRef(null);
50
- let imageDisplayComp = null;
51
- const [images, setImages] = useState(null);
52
- const imgDescription = {
53
- id: 'url',
54
- name: urlLabelSelection === 'constant' ? urlLabel : propUrlLabel,
55
- description: altText === 'constant' ? altTextOfImage : propaltTextOfImage,
56
- src: value
57
- };
58
- const onClick = () => {
59
- setImages([imgDescription]);
60
- };
61
- const onItemDownload = async (id) => {
62
- const a = document.createElement('a');
63
- a.href = await fetch(images[0].src)
64
- .then((response) => {
65
- return response.blob();
66
- })
67
- .then((blob) => {
68
- return URL.createObjectURL(blob);
69
- });
70
- a.download = images?.find((image) => image.id === id)?.name ?? id;
71
- document.body.appendChild(a);
72
- a.click();
73
- document.body.removeChild(a);
74
- };
75
- let btnVal = value;
76
- btnVal = urlLabelVal(urlLabelSelection, btnVal, urlLabel, propUrlLabel);
77
- imageDisplayComp = (
78
- <React.Fragment>
79
- {btnVal !== null && (
80
- <Button ref={demoButtonRef} variant='link' compact={false} onClick={onClick} autoFocus>
81
- {btnVal}
82
- </Button>
83
- )}
84
- {images && (
85
- <Lightbox
86
- items={images}
87
- cycle={false}
88
- onAfterClose={() => {
89
- setImages(null);
90
- demoButtonRef.current?.focus();
91
- }}
92
- onItemDownload={isImage(images[0].src) ? onItemDownload : undefined}
93
- />
94
- )}
95
- </React.Fragment>
96
- );
97
- return imageDisplayComp;
98
- };
99
-
100
- export const textFormatter = (formatter,value) => {
101
- let displayComponent = null;
102
- switch(formatter){
103
- case "TextInput" : {
104
- displayComponent = value;
105
- break;
106
- }
107
- case "Email" : {
108
- displayComponent = (<EmailDisplay value={value} displayText={value} variant="link" />);
109
- break;
110
- }
111
- case "Phone" : {
112
- displayComponent = (<PhoneDisplay value={value} variant="link" />);
113
- break;
114
- }
115
- case "URL" : {
116
- displayComponent = (<URLDisplay target="_blank" value={value} displayText={value} variant="link" />);
117
- break;
118
- }
119
- // no default
120
- }
121
- return displayComponent;
122
- };
123
-
124
- /**
125
- * Returns a URL display component based on the options
126
- * @function urlFormatter
127
- * @param {string} value value
128
- * @param {object} options options for formatting
129
- * { displayAs,tableDisplayAs,isTableFormatter,altText,altTextOfImage,propaltTextOfImage,urlLabelSelection, urlLabel,propUrlLabel, widthSel, customWidth}
130
- */
131
- export const urlFormatter = (value, options) => {
132
- const {
133
- displayAs,
134
- tableDisplayAs,
135
- isTableFormatter,
136
- altText,
137
- altTextOfImage,
138
- propaltTextOfImage,
139
- urlLabelSelection,
140
- urlLabel,
141
- propUrlLabel,
142
- widthSel,
143
- customWidth
144
- } = options;
145
-
146
- let urlFormatComp = null;
147
- if (
148
- (displayAs === 'labelText' || (isTableFormatter && tableDisplayAs === 'link')) &&
149
- (urlLabel !== '' || propUrlLabel !== '')
150
- ) {
151
- urlFormatComp = (
152
- <URLDisplay
153
- target='_blank'
154
- value={value}
155
- displayText={urlLabelSelection === 'constant' ? urlLabel : propUrlLabel}
156
- variant='link'
157
- />
158
- );
159
- } else if ((displayAs === 'Image' || tableDisplayAs === 'Image') && !!value) {
160
- if (isTableFormatter) {
161
- urlFormatComp = TableImage({
162
- value,
163
- altText,
164
- altTextOfImage,
165
- propaltTextOfImage,
166
- urlLabelSelection,
167
- urlLabel,
168
- propUrlLabel
169
- });
170
- } else {
171
- const width = widthSel === 'widthpx' ? customWidth : null;
172
- urlFormatComp = (
173
- <Image src={value} width={width} alt={altText === 'constant' ? altTextOfImage : propaltTextOfImage} />
174
- );
175
- }
176
- } else {
177
- urlFormatComp = <URLDisplay target='_blank' value={value} displayText={value} variant='link' />;
178
- }
179
- return urlFormatComp;
180
- };
181
-
182
-
183
12
 
184
13
  // Duplicated runtime code from Constellation Design System Component
185
14
 
@@ -0,0 +1,172 @@
1
+ import {EmailDisplay, PhoneDisplay, URLDisplay } from "@pega/cosmos-react-core";
2
+
3
+ export const formatExists = (formatterVal) => {
4
+ const formatterValues = [
5
+ "TextInput",
6
+ "WorkStatus",
7
+ "RichText",
8
+ "Email",
9
+ "Phone",
10
+ "URL",
11
+ "Operator"
12
+ ];
13
+ let isformatter = false;
14
+ if (formatterValues.includes(formatterVal)) {
15
+ isformatter = true;
16
+ }
17
+ return isformatter;
18
+ };
19
+
20
+ const urlLabelVal = (urlLabelSelection, btnVal, urlLabel, propUrlLabel) => {
21
+ if ((urlLabel !== '' || propUrlLabel !== '') && btnVal !== null) {
22
+ switch (urlLabelSelection) {
23
+ case 'constant': {
24
+ btnVal = urlLabel;
25
+ break;
26
+ }
27
+ case 'propertyRef': {
28
+ btnVal = propUrlLabel;
29
+ break;
30
+ }
31
+ // no default
32
+ }
33
+ }
34
+ return btnVal;
35
+ };
36
+
37
+ const isImage = (url) => /\.(jpg|jpeg|png|webp|avif|gif|svg)$/.test(url);
38
+
39
+ const TableImage = (imageProps) => {
40
+ const { value, altText, altTextOfImage, propaltTextOfImage, urlLabelSelection, urlLabel, propUrlLabel } = imageProps;
41
+ const demoButtonRef = useRef(null);
42
+ let imageDisplayComp = null;
43
+ const [images, setImages] = useState(null);
44
+ const imgDescription = {
45
+ id: 'url',
46
+ name: urlLabelSelection === 'constant' ? urlLabel : propUrlLabel,
47
+ description: altText === 'constant' ? altTextOfImage : propaltTextOfImage,
48
+ src: value
49
+ };
50
+ const onClick = () => {
51
+ setImages([imgDescription]);
52
+ };
53
+ const onItemDownload = async (id) => {
54
+ const a = document.createElement('a');
55
+ a.href = await fetch(images[0].src)
56
+ .then((response) => {
57
+ return response.blob();
58
+ })
59
+ .then((blob) => {
60
+ return URL.createObjectURL(blob);
61
+ });
62
+ a.download = images?.find((image) => image.id === id)?.name ?? id;
63
+ document.body.appendChild(a);
64
+ a.click();
65
+ document.body.removeChild(a);
66
+ };
67
+ let btnVal = value;
68
+ btnVal = urlLabelVal(urlLabelSelection, btnVal, urlLabel, propUrlLabel);
69
+ imageDisplayComp = (
70
+ <React.Fragment>
71
+ {btnVal !== null && (
72
+ <Button ref={demoButtonRef} variant='link' compact={false} onClick={onClick} autoFocus>
73
+ {btnVal}
74
+ </Button>
75
+ )}
76
+ {images && (
77
+ <Lightbox
78
+ items={images}
79
+ cycle={false}
80
+ onAfterClose={() => {
81
+ setImages(null);
82
+ demoButtonRef.current?.focus();
83
+ }}
84
+ onItemDownload={isImage(images[0].src) ? onItemDownload : undefined}
85
+ />
86
+ )}
87
+ </React.Fragment>
88
+ );
89
+ return imageDisplayComp;
90
+ };
91
+
92
+ export const textFormatter = (formatter,value) => {
93
+ let displayComponent = null;
94
+ switch(formatter){
95
+ case "TextInput" : {
96
+ displayComponent = value;
97
+ break;
98
+ }
99
+ case "Email" : {
100
+ displayComponent = (<EmailDisplay value={value} displayText={value} variant="link" />);
101
+ break;
102
+ }
103
+ case "Phone" : {
104
+ displayComponent = (<PhoneDisplay value={value} variant="link" />);
105
+ break;
106
+ }
107
+ case "URL" : {
108
+ displayComponent = (<URLDisplay target="_blank" value={value} displayText={value} variant="link" />);
109
+ break;
110
+ }
111
+ // no default
112
+ }
113
+ return displayComponent;
114
+ };
115
+
116
+ /**
117
+ * Returns a URL display component based on the options
118
+ * @function urlFormatter
119
+ * @param {string} value value
120
+ * @param {object} options options for formatting
121
+ * { displayAs,tableDisplayAs,isTableFormatter,altText,altTextOfImage,propaltTextOfImage,urlLabelSelection, urlLabel,propUrlLabel, widthSel, customWidth}
122
+ */
123
+ export const urlFormatter = (value, options) => {
124
+ const {
125
+ displayAs,
126
+ tableDisplayAs,
127
+ isTableFormatter,
128
+ altText,
129
+ altTextOfImage,
130
+ propaltTextOfImage,
131
+ urlLabelSelection,
132
+ urlLabel,
133
+ propUrlLabel,
134
+ widthSel,
135
+ customWidth
136
+ } = options;
137
+
138
+ let urlFormatComp = null;
139
+ if (
140
+ (displayAs === 'labelText' || (isTableFormatter && tableDisplayAs === 'link')) &&
141
+ (urlLabel !== '' || propUrlLabel !== '')
142
+ ) {
143
+ urlFormatComp = (
144
+ <URLDisplay
145
+ target='_blank'
146
+ value={value}
147
+ displayText={urlLabelSelection === 'constant' ? urlLabel : propUrlLabel}
148
+ variant='link'
149
+ />
150
+ );
151
+ } else if ((displayAs === 'Image' || tableDisplayAs === 'Image') && !!value) {
152
+ if (isTableFormatter) {
153
+ urlFormatComp = TableImage({
154
+ value,
155
+ altText,
156
+ altTextOfImage,
157
+ propaltTextOfImage,
158
+ urlLabelSelection,
159
+ urlLabel,
160
+ propUrlLabel
161
+ });
162
+ } else {
163
+ const width = widthSel === 'widthpx' ? customWidth : null;
164
+ urlFormatComp = (
165
+ <Image src={value} width={width} alt={altText === 'constant' ? altTextOfImage : propaltTextOfImage} />
166
+ );
167
+ }
168
+ } else {
169
+ urlFormatComp = <URLDisplay target='_blank' value={value} displayText={value} variant='link' />;
170
+ }
171
+ return urlFormatComp;
172
+ };
@@ -1,4 +1,4 @@
1
- import { withKnobs, text, boolean } from '@storybook/addon-knobs';
1
+ import { withKnobs } from '@storybook/addon-knobs';
2
2
  import { configProps, stateProps } from './mock.stories';
3
3
  import {{COMPONENT_CLASS_NAME}} from './index.jsx';
4
4
 
@@ -14,8 +14,13 @@ export const base{{COMPONENT_CLASS_NAME}} = () => {
14
14
  return {
15
15
  getActionsApi: () => {
16
16
  return {
17
- updateFieldValue: () => {},
18
- triggerFieldChange: () => {}
17
+ updateFieldValue: () => {/* nothing */},
18
+ triggerFieldChange: () => {/* nothing */}
19
+ };
20
+ },
21
+ getValidationApi: () => {
22
+ return {
23
+ validate: () => {/* nothing */}
19
24
  };
20
25
  },
21
26
  getStateProps: () => {
@@ -24,8 +29,8 @@ export const base{{COMPONENT_CLASS_NAME}} = () => {
24
29
  getConfigProps: () => {
25
30
  return configProps;
26
31
  },
27
- ignoreSuggestion: () => {},
28
- clearErrorMessages: () => {}
32
+ ignoreSuggestion: () => {/* nothing */},
33
+ clearErrorMessages: () => {/* nothing */}
29
34
  };
30
35
  },
31
36
  value: configProps.value,
@@ -8,69 +8,20 @@ export default {
8
8
  component: {{COMPONENT_CLASS_NAME}}
9
9
  };
10
10
 
11
- const Template = args => {
12
- const regionAChildren = pyReviewRaw.children[0].children.map(child => {
13
- return Primary.args.getPConnect().createComponent(child);
14
- });
15
-
16
- return <{{COMPONENT_CLASS_NAME}} {...args}>{regionAChildren}</{{COMPONENT_CLASS_NAME}}>;
17
- };
18
-
19
- export const Primary = Template.bind({});
20
-
21
- Primary.args = {
22
- template: 'MyCo_MyComponents_NewDetailsTemplate',
23
- showHighlightedData: true,
24
- label: 'Test Details',
25
- showLabel: true,
26
- getPConnect: () => {
27
- return {
28
- getChildren: () => {
29
- return pyReviewRaw.children;
30
- },
31
- getRawMetadata: () => {
32
- return pyReviewRaw;
33
- },
34
- getInheritedProps: () => {
35
- return pyReviewRaw.config.inheritedProps;
36
- },
37
- createComponent: config => {
38
- switch (config.config.value) {
39
- case '@P .pyStatusWork':
40
- return renderField(pyReviewResolved.highlightedData[0].config);
41
- case '@P .pyID':
42
- return renderField(pyReviewResolved.highlightedData[1].config);
43
- case '@P .pxCreateDateTime':
44
- return renderField(pyReviewResolved.highlightedData[2].config);
45
- case '@USER .pxCreateOperator':
46
- return renderField(pyReviewResolved.highlightedData[3].config);
47
- case '@P .pySLADeadline':
48
- return renderField(regionChildrenResolved[0]);
49
- case '@P .pySLAGoal':
50
- return renderField(regionChildrenResolved[1]);
51
- case '@P .pySLAStartTime':
52
- return renderField(regionChildrenResolved[2]);
53
- }
54
- },
55
- setInheritedProp: () => {},
56
- resolveConfigProps: () => {}
57
- };
58
- }
59
- };
60
-
61
11
  const renderField = resolvedProps => {
62
12
  const {
63
13
  displayAsStatus = false,
64
14
  displayMode,
65
15
  value = '',
66
16
  label = '',
17
+ // eslint-disable-next-line react-hooks/rules-of-hooks
67
18
  theme = useTheme()
68
19
  } = resolvedProps;
69
20
 
70
21
  const variant = displayMode === 'LABELS_LEFT' ? 'inline' : 'stacked';
71
22
 
72
23
  let val =
73
- value != '' ? (
24
+ value !== '' ? (
74
25
  <Text variant='h1' as='span'>
75
26
  {value}
76
27
  </Text>
@@ -108,3 +59,60 @@ const renderField = resolvedProps => {
108
59
  }
109
60
  return <FieldValueList variant={variant} fields={[{ name: label, value: val }]} />;
110
61
  };
62
+
63
+ export const base{{COMPONENT_CLASS_NAME}} = () => {
64
+ const props = {
65
+ template: 'MyCo_MyComponents_NewDetailsTemplate',
66
+ showHighlightedData: true,
67
+ label: 'Test Details',
68
+ showLabel: true,
69
+ getPConnect: () => {
70
+ return {
71
+ getChildren: () => {
72
+ return pyReviewRaw.children;
73
+ },
74
+ getRawMetadata: () => {
75
+ return pyReviewRaw;
76
+ },
77
+ getInheritedProps: () => {
78
+ return pyReviewRaw.config.inheritedProps;
79
+ },
80
+ createComponent: config => {
81
+ // eslint-disable-next-line default-case
82
+ switch (config.config.value) {
83
+ case '@P .pyStatusWork':
84
+ return renderField(pyReviewResolved.highlightedData[0].config);
85
+ case '@P .pyID':
86
+ return renderField(pyReviewResolved.highlightedData[1].config);
87
+ case '@P .pxCreateDateTime':
88
+ return renderField(pyReviewResolved.highlightedData[2].config);
89
+ case '@USER .pxCreateOperator':
90
+ return renderField(pyReviewResolved.highlightedData[3].config);
91
+ case '@P .pySLADeadline':
92
+ return renderField(regionChildrenResolved[0]);
93
+ case '@P .pySLAGoal':
94
+ return renderField(regionChildrenResolved[1]);
95
+ case '@P .pySLAStartTime':
96
+ return renderField(regionChildrenResolved[2]);
97
+ }
98
+ },
99
+ setInheritedProp: () => {
100
+ /* nothing */
101
+ },
102
+ resolveConfigProps: () => {
103
+ /* nothing */
104
+ }
105
+ };
106
+ }
107
+ };
108
+
109
+ const regionAChildren = pyReviewRaw.children[0].children.map(child => {
110
+ return props.getPConnect().createComponent(child);
111
+ });
112
+
113
+ return (
114
+ <>
115
+ <{{COMPONENT_CLASS_NAME}} {...props}>{regionAChildren}</{{COMPONENT_CLASS_NAME}}>
116
+ </>
117
+ );
118
+ };
@@ -8,77 +8,20 @@ export default {
8
8
  component: {{COMPONENT_CLASS_NAME}}
9
9
  };
10
10
 
11
- const Template = args => {
12
- const regionAChildren = pyReviewRaw.children[0].children.map(child => {
13
- return Primary.args.getPConnect().createComponent(child);
14
- });
15
- const regionBChildren = pyReviewRaw.children[1].children.map(child => {
16
- return Primary.args.getPConnect().createComponent(child);
17
- });
18
-
19
- return (
20
- <{{COMPONENT_CLASS_NAME}} {...args}>
21
- {regionAChildren}
22
- {regionBChildren}
23
- </{{COMPONENT_CLASS_NAME}}>
24
- );
25
- };
26
-
27
- export const Primary = Template.bind({});
28
-
29
- Primary.args = {
30
- template: 'MyCo_MyComponents_NewDetailsTemplate',
31
- showHighlightedData: true,
32
- label: 'Test Details',
33
- showLabel: true,
34
- getPConnect: () => {
35
- return {
36
- getChildren: () => {
37
- return pyReviewRaw.children;
38
- },
39
- getRawMetadata: () => {
40
- return pyReviewRaw;
41
- },
42
- getInheritedProps: () => {
43
- return pyReviewRaw.config.inheritedProps;
44
- },
45
- createComponent: config => {
46
- switch (config.config.value) {
47
- case '@P .pyStatusWork':
48
- return renderField(pyReviewResolved.highlightedData[0].config);
49
- case '@P .pyID':
50
- return renderField(pyReviewResolved.highlightedData[1].config);
51
- case '@P .pxCreateDateTime':
52
- return renderField(pyReviewResolved.highlightedData[2].config);
53
- case '@USER .pxCreateOperator':
54
- return renderField(pyReviewResolved.highlightedData[3].config);
55
- case '@P .pySLADeadline':
56
- return renderField(regionChildrenResolved[0]);
57
- case '@P .pySLAGoal':
58
- return renderField(regionChildrenResolved[1]);
59
- case '@P .pySLAStartTime':
60
- return renderField(regionChildrenResolved[2]);
61
- }
62
- },
63
- setInheritedProp: () => {},
64
- resolveConfigProps: () => {}
65
- };
66
- }
67
- };
68
-
69
11
  const renderField = resolvedProps => {
70
12
  const {
71
13
  displayAsStatus = false,
72
14
  displayMode,
73
15
  value = '',
74
16
  label = '',
17
+ // eslint-disable-next-line react-hooks/rules-of-hooks
75
18
  theme = useTheme()
76
19
  } = resolvedProps;
77
20
 
78
21
  const variant = displayMode === 'LABELS_LEFT' ? 'inline' : 'stacked';
79
22
 
80
23
  let val =
81
- value != '' ? (
24
+ value !== '' ? (
82
25
  <Text variant='h1' as='span'>
83
26
  {value}
84
27
  </Text>
@@ -116,3 +59,65 @@ const renderField = resolvedProps => {
116
59
  }
117
60
  return <FieldValueList variant={variant} fields={[{ name: label, value: val }]} />;
118
61
  };
62
+
63
+
64
+ export const base{{COMPONENT_CLASS_NAME}} = () => {
65
+ const props = {
66
+ template: 'MyCo_MyComponents_NewDetailsTemplate',
67
+ showHighlightedData: true,
68
+ label: 'Test Details',
69
+ showLabel: true,
70
+ getPConnect: () => {
71
+ return {
72
+ getChildren: () => {
73
+ return pyReviewRaw.children;
74
+ },
75
+ getRawMetadata: () => {
76
+ return pyReviewRaw;
77
+ },
78
+ getInheritedProps: () => {
79
+ return pyReviewRaw.config.inheritedProps;
80
+ },
81
+ createComponent: config => {
82
+ // eslint-disable-next-line default-case
83
+ switch (config.config.value) {
84
+ case '@P .pyStatusWork':
85
+ return renderField(pyReviewResolved.highlightedData[0].config);
86
+ case '@P .pyID':
87
+ return renderField(pyReviewResolved.highlightedData[1].config);
88
+ case '@P .pxCreateDateTime':
89
+ return renderField(pyReviewResolved.highlightedData[2].config);
90
+ case '@USER .pxCreateOperator':
91
+ return renderField(pyReviewResolved.highlightedData[3].config);
92
+ case '@P .pySLADeadline':
93
+ return renderField(regionChildrenResolved[0]);
94
+ case '@P .pySLAGoal':
95
+ return renderField(regionChildrenResolved[1]);
96
+ case '@P .pySLAStartTime':
97
+ return renderField(regionChildrenResolved[2]);
98
+ }
99
+ },
100
+ setInheritedProp: () => {
101
+ /* nothing */
102
+ },
103
+ resolveConfigProps: () => {
104
+ /* nothing */
105
+ }
106
+ };
107
+ }
108
+ };
109
+
110
+ const regionAChildren = pyReviewRaw.children[0].children.map(child => {
111
+ return props.getPConnect().createComponent(child);
112
+ });
113
+ const regionBChildren = pyReviewRaw.children[1].children.map(child => {
114
+ return props.getPConnect().createComponent(child);
115
+ });
116
+
117
+ return (
118
+ <{{COMPONENT_CLASS_NAME}} {...props}>
119
+ {regionAChildren}
120
+ {regionBChildren}
121
+ </{{COMPONENT_CLASS_NAME}}>
122
+ );
123
+ };