@pega/dx-component-builder-sdk 0.1.6 → 0.1.8
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.
- package/package.json +1 -1
- package/src/constants.js +8 -4
- package/src/tasks/build/helper.js +5 -23
- package/src/tasks/build/index.js +54 -7
- package/src/tasks/bundle/index.js +2 -2
- package/src/tasks/create/index.js +13 -5
- package/src/tasks/create/templates/Constellation/Field/Boolean/boolean-format.js.mustache +1 -1
- package/src/tasks/create/templates/Constellation/Field/Boolean/demo.stories.jsx.mustache +60 -0
- package/src/tasks/create/templates/Constellation/Field/Boolean/index.jsx.mustache +1 -2
- package/src/tasks/create/templates/Constellation/Field/Boolean/mock.stories.js.mustache +21 -0
- package/src/tasks/create/templates/Constellation/Field/Date/DateFormatter.js.mustache +61 -0
- package/src/tasks/create/templates/Constellation/Field/Date/FormattedText.jsx.mustache +41 -0
- package/src/tasks/create/templates/Constellation/Field/Date/date.js.mustache +179 -67
- package/src/tasks/create/templates/Constellation/Field/Date/demo.stories.jsx.mustache +40 -16
- package/src/tasks/create/templates/Constellation/Field/Date/index.jsx.mustache +3 -1
- package/src/tasks/create/templates/Constellation/Field/Date/mock.stories.js.mustache +23 -0
- package/src/tasks/create/templates/Constellation/Field/DateTime/date-time.js.mustache +0 -1
- package/src/tasks/create/templates/Constellation/Field/DateTime/{date-utils.js → date-utils.js.mustache} +1 -0
- package/src/tasks/create/templates/Constellation/Field/DateTime/date.js.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Field/DateTime/demo.stories.jsx.mustache +40 -15
- package/src/tasks/create/templates/Constellation/Field/DateTime/index.jsx.mustache +2 -0
- package/src/tasks/create/templates/Constellation/Field/DateTime/mock.stories.js.mustache +23 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal/demo.stories.jsx.mustache +22 -17
- package/src/tasks/create/templates/Constellation/Field/Decimal/index.jsx.mustache +2 -1
- package/src/tasks/create/templates/Constellation/Field/Decimal/mock.stories.js.mustache +21 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/demo.stories.jsx.mustache +25 -17
- package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/index.jsx.mustache +3 -4
- package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/mock.stories.js.mustache +23 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/demo.stories.jsx.mustache +22 -17
- package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/index.jsx.mustache +8 -2
- package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/mock.stories.js.mustache +21 -0
- package/src/tasks/create/templates/Constellation/Field/Integer/demo.stories.jsx.mustache +22 -17
- package/src/tasks/create/templates/Constellation/Field/Integer/index.jsx.mustache +2 -1
- package/src/tasks/create/templates/Constellation/Field/Integer/mock.stories.js.mustache +21 -0
- package/src/tasks/create/templates/Constellation/Field/Picklist/demo.stories.jsx.mustache +42 -14
- package/src/tasks/create/templates/Constellation/Field/Picklist/index.jsx.mustache +44 -1
- package/src/tasks/create/templates/Constellation/Field/Picklist/mock.stories.js.mustache +67 -0
- package/src/tasks/create/templates/Constellation/Field/Text/demo.stories.jsx.mustache +21 -16
- package/src/tasks/create/templates/Constellation/Field/Text/mock.stories.js.mustache +13 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Email/demo.stories.jsx.mustache +20 -16
- package/src/tasks/create/templates/Constellation/Field/Text-Email/index.jsx.mustache +44 -2
- package/src/tasks/create/templates/Constellation/Field/Text-Email/mock.stories.js.mustache +22 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Input/{StatusWork.js → StatusWork.jsx} +0 -1
- package/src/tasks/create/templates/Constellation/Field/Text-Input/demo.stories.jsx.mustache +21 -17
- package/src/tasks/create/templates/Constellation/Field/Text-Input/index.jsx.mustache +46 -3
- package/src/tasks/create/templates/Constellation/Field/Text-Input/mock.stories.js.mustache +21 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/demo.stories.jsx.mustache +21 -17
- package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/index.jsx.mustache +44 -2
- package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/mock.stories.js.mustache +20 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Phone/demo.stories.jsx.mustache +19 -17
- package/src/tasks/create/templates/Constellation/Field/Text-Phone/index.jsx.mustache +46 -2
- package/src/tasks/create/templates/Constellation/Field/Text-Phone/mock.stories.js.mustache +37 -0
- package/src/tasks/create/templates/Constellation/Field/Text-URL/demo.stories.jsx.mustache +19 -17
- package/src/tasks/create/templates/Constellation/Field/Text-URL/index.jsx.mustache +174 -3
- package/src/tasks/create/templates/Constellation/Field/Text-URL/mock.stories.js.mustache +22 -0
- package/src/tasks/create/templates/Constellation/Field/TimeofDay/demo.stories.jsx.mustache +24 -16
- package/src/tasks/create/templates/Constellation/Field/TimeofDay/mock.stories.js.mustache +20 -0
- package/src/tasks/create/templates/Constellation/Field/TimeofDay/time-of-day.js.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/StatusWork.jsx.mustache +26 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/demo.stories.jsx.mustache +110 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/index.jsx.mustache +3 -5
- package/src/tasks/create/templates/Constellation/Template/DETAILS/mock.stories.js.mustache +179 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/utils.js.mustache +3 -6
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/StatusWork.jsx.mustache +26 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/demo.stories.jsx.mustache +118 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/index.jsx.mustache +3 -5
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/mock.stories.js.mustache +215 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/utils.js.mustache +3 -3
- package/src/tasks/create/templates/Constellation/Template/FORM/demo.stories.jsx.mustache +89 -0
- package/src/tasks/create/templates/Constellation/Template/FORM/index.jsx.mustache +6 -10
- package/src/tasks/create/templates/Constellation/Template/FORM/mock.stories.js.mustache +125 -0
- package/src/tasks/create/templates/Constellation/Template/FORM-region/demo.stories.jsx.mustache +100 -0
- package/src/tasks/create/templates/Constellation/Template/FORM-region/index.jsx.mustache +5 -11
- package/src/tasks/create/templates/Constellation/Template/FORM-region/mock.stories.js.mustache +131 -0
- package/src/tasks/create/templates/Constellation/Template/PAGE/{GetNextWork.js.mustache → GetNextWork.jsx.mustache} +6 -0
- package/src/tasks/create/templates/Constellation/Template/PAGE/demo.stories.jsx.mustache +102 -0
- package/src/tasks/create/templates/Constellation/Template/PAGE/index.jsx.mustache +9 -7
- package/src/tasks/create/templates/Constellation/Template/PAGE/mock.stories.js.mustache +94 -0
- package/src/tasks/create/templates/Constellation/Template/PAGE/utils.js.mustache +4 -1
- package/src/tasks/create/templates/Constellation/Widget/CASE/demo.stories.jsx.mustache +78 -0
- package/src/tasks/create/templates/Constellation/Widget/CASE/index.jsx.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Widget/CASE/mock.stories.js.mustache +389 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE/demo.stories.jsx.mustache +30 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE/mock.stories.js.mustache +22 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/{Avatar.js.mustache → Avatar.jsx.mustache} +2 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/{Operator.js.mustache → Operator.jsx.mustache} +2 -1
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/demo.stories.jsx.mustache +68 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/index.jsx.mustache +9 -9
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/mock.stories.js.mustache +51 -0
- package/src/tasks/create/templates/SDK-React/Template/PAGE/demo.stories.jsx.mustache +79 -0
- package/src/tasks/create/templates/SDK-React/Template/PAGE/mock.stories.js.mustache +115 -0
- package/src/tasks/delete/helper.js +7 -25
- package/src/tasks/delete/index.js +2 -3
- package/src/tasks/delete-all/helper.js +7 -24
- package/src/tasks/delete-all/index.js +2 -3
- package/src/tasks/list/helper.js +3 -21
- package/src/tasks/list/index.js +2 -3
- package/src/tasks/map/map.js +4 -10
- package/src/tasks/override/index.js +50 -21
- package/src/tasks/publish/helper.js +77 -15
- package/src/tasks/publish/index.js +103 -15
- package/src/tasks/publish-all/helper.js +77 -13
- package/src/tasks/publish-all/index.js +109 -25
- package/src/tasks/validator/index.js +7 -5
- package/src/util.js +56 -10
- package/src/tasks/create/templates/Constellation/Field/Picklist/picklist.js.mustache +0 -43
- package/src/tasks/create/templates/Constellation/Field/Text-Email/text-email.js.mustache +0 -43
- package/src/tasks/create/templates/Constellation/Field/Text-Input/text-input.js.mustache +0 -43
- package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/text-paragraph.js.mustache +0 -43
- package/src/tasks/create/templates/Constellation/Field/Text-Phone/text-phone.js.mustache +0 -43
- package/src/tasks/create/templates/Constellation/Field/Text-URL/text-url.js.mustache +0 -172
|
@@ -1,14 +1,185 @@
|
|
|
1
|
-
import { useState, useEffect, useRef} from "react";
|
|
2
|
-
import { Input, FieldValueList, Text } from "@pega/cosmos-react-core";
|
|
1
|
+
import { useState, useEffect, useRef, React} from "react";
|
|
2
|
+
import { Input, FieldValueList, Text, EmailDisplay, PhoneDisplay, URLDisplay, Button, Lightbox, Image } 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";
|
|
7
6
|
import handleEvent from "./event-utils";
|
|
8
7
|
import { suggestionsHandler } from './suggestions-handler';
|
|
9
8
|
|
|
10
9
|
import Styled{{COMPONENT_CLASS_NAME}}Wrapper from './styles';
|
|
11
10
|
|
|
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
|
+
|
|
12
183
|
|
|
13
184
|
// Duplicated runtime code from Constellation Design System Component
|
|
14
185
|
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export const configProps = {
|
|
2
|
+
value: '',
|
|
3
|
+
label: 'URL Sample',
|
|
4
|
+
placeholder: 'URL Placeholder',
|
|
5
|
+
helperText: 'URL Helper Text',
|
|
6
|
+
testId: 'url-12345678',
|
|
7
|
+
hasSuggestions: false
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const fieldMetadata = {
|
|
11
|
+
classID: 'DIXL-MediaCo-Work-NewService',
|
|
12
|
+
type: 'Text',
|
|
13
|
+
maxLength: 256,
|
|
14
|
+
displayAs: 'pxURL',
|
|
15
|
+
label: 'URL sample',
|
|
16
|
+
validateAs: 'pxIsValidURL'
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const stateProps = {
|
|
20
|
+
value: '.URLSample',
|
|
21
|
+
hasSuggestions: false
|
|
22
|
+
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
1
|
import { withKnobs, text, boolean } from '@storybook/addon-knobs';
|
|
3
|
-
|
|
2
|
+
import { configProps, stateProps } from './mock.stories';
|
|
4
3
|
import {{COMPONENT_CLASS_NAME}} from './index.jsx';
|
|
5
4
|
|
|
6
5
|
export default {
|
|
@@ -10,30 +9,39 @@ export default {
|
|
|
10
9
|
};
|
|
11
10
|
|
|
12
11
|
export const base{{COMPONENT_CLASS_NAME}} = () => {
|
|
13
|
-
const [value, setValue] = useState('test value');
|
|
14
|
-
|
|
15
12
|
const props = {
|
|
16
13
|
getPConnect: () => {
|
|
17
14
|
return {
|
|
18
15
|
getActionsApi: () => {
|
|
19
16
|
return {
|
|
20
|
-
updateFieldValue: (
|
|
21
|
-
|
|
22
|
-
}
|
|
17
|
+
updateFieldValue: () => {},
|
|
18
|
+
triggerFieldChange: () => {}
|
|
23
19
|
};
|
|
24
20
|
},
|
|
25
21
|
getStateProps: () => {
|
|
26
|
-
return
|
|
27
|
-
}
|
|
22
|
+
return stateProps;
|
|
23
|
+
},
|
|
24
|
+
getConfigProps: () => {
|
|
25
|
+
return configProps;
|
|
26
|
+
},
|
|
27
|
+
ignoreSuggestion: () => {},
|
|
28
|
+
clearErrorMessages: () => {}
|
|
28
29
|
};
|
|
29
30
|
},
|
|
30
|
-
value,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
testId:
|
|
31
|
+
value: configProps.value,
|
|
32
|
+
validatemessage: configProps.validatemessage,
|
|
33
|
+
label: configProps.label,
|
|
34
|
+
hideLabel: configProps.hideLabel,
|
|
35
|
+
helperText: configProps.helperText,
|
|
36
|
+
withSeconds: configProps.withSeconds,
|
|
37
|
+
testId: configProps.testId,
|
|
38
|
+
additionalProps: configProps.additionalProps,
|
|
39
|
+
displayMode: configProps.displayMode,
|
|
40
|
+
variant: configProps.variant,
|
|
41
|
+
hasSuggestions: configProps.hasSuggestions,
|
|
42
|
+
disabled: configProps.disabled,
|
|
43
|
+
readOnly: configProps.readOnly,
|
|
44
|
+
required: configProps.required
|
|
37
45
|
};
|
|
38
46
|
|
|
39
47
|
return (
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const configProps = {
|
|
2
|
+
value: '13:30',
|
|
3
|
+
validatemessage: '',
|
|
4
|
+
label: 'TimeOfDay Label',
|
|
5
|
+
hideLabel: false,
|
|
6
|
+
helperText: 'TimeOfDay helper text',
|
|
7
|
+
withSeconds: false,
|
|
8
|
+
testId: '12345678',
|
|
9
|
+
additionalProps: {},
|
|
10
|
+
displayMode: '',
|
|
11
|
+
variant: '',
|
|
12
|
+
hasSuggestions: false,
|
|
13
|
+
readOnly: false,
|
|
14
|
+
required: false,
|
|
15
|
+
disabled: false
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const stateProps = {
|
|
19
|
+
value: '.TimeOfDayLabel'
|
|
20
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Status } from "@pega/cosmos-react-core";
|
|
2
|
+
|
|
3
|
+
export default function StatusWorkRenderer({ value }) {
|
|
4
|
+
let variant = "info";
|
|
5
|
+
|
|
6
|
+
const warnStrings = ["fail", "cancel", "reject", "revoke", "stopped", "warn"];
|
|
7
|
+
const infoStrings = ["open", "hold", "info", "new"];
|
|
8
|
+
const successStrings = ["resolved", "completed", "success"];
|
|
9
|
+
const pendingStrings = ["pending"];
|
|
10
|
+
|
|
11
|
+
if (new RegExp(warnStrings.join("|"), "i").test(value)) {
|
|
12
|
+
variant = "warn";
|
|
13
|
+
} else if (new RegExp(infoStrings.join("|"), "i").test(value)) {
|
|
14
|
+
variant = "info";
|
|
15
|
+
} else if (new RegExp(successStrings.join("|"), "i").test(value)) {
|
|
16
|
+
variant = "success";
|
|
17
|
+
} else if (new RegExp(pendingStrings.join("|"), "i").test(value)) {
|
|
18
|
+
variant = "pending";
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<Status type="rectangle" variant={variant}>
|
|
23
|
+
{value}
|
|
24
|
+
</Status>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { Text, FieldValueList, Button, DateTimeDisplay, useTheme } from '@pega/cosmos-react-core';
|
|
2
|
+
import {{COMPONENT_CLASS_NAME}} from './index';
|
|
3
|
+
import { pyReviewRaw, pyReviewResolved, regionChildrenResolved } from './mock.stories';
|
|
4
|
+
import StatusWorkRenderer from './StatusWork.jsx';
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title: '{{COMPONENT_CLASS_NAME}}',
|
|
8
|
+
component: {{COMPONENT_CLASS_NAME}}
|
|
9
|
+
};
|
|
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
|
+
const renderField = resolvedProps => {
|
|
62
|
+
const {
|
|
63
|
+
displayAsStatus = false,
|
|
64
|
+
displayMode,
|
|
65
|
+
value = '',
|
|
66
|
+
label = '',
|
|
67
|
+
theme = useTheme()
|
|
68
|
+
} = resolvedProps;
|
|
69
|
+
|
|
70
|
+
const variant = displayMode === 'LABELS_LEFT' ? 'inline' : 'stacked';
|
|
71
|
+
|
|
72
|
+
let val =
|
|
73
|
+
value != '' ? (
|
|
74
|
+
<Text variant='h1' as='span'>
|
|
75
|
+
{value}
|
|
76
|
+
</Text>
|
|
77
|
+
) : (
|
|
78
|
+
''
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
if (label === 'Create date/time')
|
|
82
|
+
val = <DateTimeDisplay value={value} variant='datetime' format='long' clockFormat={null} />;
|
|
83
|
+
|
|
84
|
+
if (displayAsStatus === true) val = <StatusWorkRenderer value={value} />;
|
|
85
|
+
|
|
86
|
+
if (label === 'Create Operator')
|
|
87
|
+
val = (
|
|
88
|
+
<Button
|
|
89
|
+
variant='link'
|
|
90
|
+
style={
|
|
91
|
+
label !== null
|
|
92
|
+
? { width: 'max-content', height: theme.components.input.height }
|
|
93
|
+
: undefined
|
|
94
|
+
}
|
|
95
|
+
>
|
|
96
|
+
{value.userName}
|
|
97
|
+
</Button>
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
if (variant === 'inline') {
|
|
101
|
+
val = value || <span aria-hidden='true'>––</span>;
|
|
102
|
+
} else {
|
|
103
|
+
val = (
|
|
104
|
+
<Text variant='h1' as='span'>
|
|
105
|
+
{val}
|
|
106
|
+
</Text>
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
return <FieldValueList variant={variant} fields={[{ name: label, value: val }]} />;
|
|
110
|
+
};
|
|
@@ -17,16 +17,14 @@ export default function {{COMPONENT_CLASS_NAME}}(props) {
|
|
|
17
17
|
const propsToUse = { label, showLabel, ...getPConnect().getInheritedProps() };
|
|
18
18
|
|
|
19
19
|
const numRegions = getAllFields(getPConnect)?.length;
|
|
20
|
-
const gridRepeat =
|
|
21
|
-
|
|
20
|
+
const gridRepeat = "repeat(".concat(numRegions).concat(", 1fr)");
|
|
21
|
+
const gridContainer = { "colGap": 1};
|
|
22
22
|
gridContainer.cols = gridRepeat;
|
|
23
23
|
gridContainer.alignItems = 'start';
|
|
24
|
-
gridContainer.colGap = 1;
|
|
25
24
|
|
|
26
|
-
|
|
25
|
+
const gridHighlightContainer = { "gap": 2};
|
|
27
26
|
gridHighlightContainer.cols = gridRepeat;
|
|
28
27
|
gridHighlightContainer.alignItems = 'start';
|
|
29
|
-
gridHighlightContainer.gap = 2;
|
|
30
28
|
gridHighlightContainer.pad = [0, 0, 2, 0];
|
|
31
29
|
|
|
32
30
|
// Set up highlighted data to pass in return if is set to show, need raw metadata to pass to createComponent
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
export const pyReviewRaw = {
|
|
2
|
+
name: 'pyReview',
|
|
3
|
+
type: 'View',
|
|
4
|
+
config: {
|
|
5
|
+
template: 'Details',
|
|
6
|
+
ruleClass: 'MyCo-MyCompon-Work-MyComponents',
|
|
7
|
+
showLabel: true,
|
|
8
|
+
label: '@L Details',
|
|
9
|
+
localeReference: '@LR MYCO-MYCOMPON-WORK-MYCOMPONENTS!VIEW!PYREVIEW',
|
|
10
|
+
showHighlightedData: true,
|
|
11
|
+
highlightedData: [
|
|
12
|
+
{
|
|
13
|
+
type: 'TextInput',
|
|
14
|
+
config: {
|
|
15
|
+
value: '@P .pyStatusWork',
|
|
16
|
+
label: '@L Work Status',
|
|
17
|
+
displayMode: 'STACKED_LARGE_VAL',
|
|
18
|
+
displayAsStatus: true
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
type: 'TextInput',
|
|
23
|
+
config: {
|
|
24
|
+
value: '@P .pyID',
|
|
25
|
+
label: '@L Case ID',
|
|
26
|
+
displayMode: 'STACKED_LARGE_VAL'
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
type: 'DateTime',
|
|
31
|
+
config: {
|
|
32
|
+
value: '@P .pxCreateDateTime',
|
|
33
|
+
label: '@L Create date/time',
|
|
34
|
+
displayMode: 'STACKED_LARGE_VAL'
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
type: 'UserReference',
|
|
39
|
+
config: {
|
|
40
|
+
label: '@L Create Operator',
|
|
41
|
+
value: '@USER .pxCreateOperator',
|
|
42
|
+
placeholder: 'Select...',
|
|
43
|
+
displayMode: 'STACKED_LARGE_VAL'
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
inheritedProps: [
|
|
48
|
+
{
|
|
49
|
+
prop: 'label',
|
|
50
|
+
value: '@L Details'
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
prop: 'showLabel',
|
|
54
|
+
value: true
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
},
|
|
58
|
+
children: [
|
|
59
|
+
{
|
|
60
|
+
name: 'A',
|
|
61
|
+
type: 'Region',
|
|
62
|
+
getPConnect: () => {
|
|
63
|
+
return {
|
|
64
|
+
getRawMetadata: () => {
|
|
65
|
+
return pyReviewRaw.children[0];
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
},
|
|
69
|
+
children: [
|
|
70
|
+
{
|
|
71
|
+
type: 'DateTime',
|
|
72
|
+
config: {
|
|
73
|
+
value: '@P .pySLADeadline',
|
|
74
|
+
label: '@L SLA Deadline'
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
type: 'DateTime',
|
|
79
|
+
config: {
|
|
80
|
+
value: '@P .pySLAGoal',
|
|
81
|
+
label: '@L SLA Goal'
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
type: 'RadioButtons',
|
|
86
|
+
config: {
|
|
87
|
+
value: '@P .pySLAStartTime',
|
|
88
|
+
label: '@L SLA Start Time',
|
|
89
|
+
listType: 'associated',
|
|
90
|
+
datasource: '@ASSOCIATED .pySLAStartTime'
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
]
|
|
94
|
+
}
|
|
95
|
+
],
|
|
96
|
+
classID: 'MyCo-MyCompon-Work-MyComponents'
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export const pyReviewResolved = {
|
|
100
|
+
readOnly: true,
|
|
101
|
+
template: 'Details',
|
|
102
|
+
ruleClass: 'MyCo-MyCompon-Work-MyComponents',
|
|
103
|
+
showLabel: true,
|
|
104
|
+
label: 'Details',
|
|
105
|
+
localeReference: 'MYCO-MYCOMPON-WORK-MYCOMPONENTS!VIEW!PYREVIEW',
|
|
106
|
+
showHighlightedData: true,
|
|
107
|
+
highlightedData: [
|
|
108
|
+
{
|
|
109
|
+
type: 'TextInput',
|
|
110
|
+
config: {
|
|
111
|
+
value: 'New',
|
|
112
|
+
label: 'Work Status',
|
|
113
|
+
displayMode: 'STACKED_LARGE_VAL',
|
|
114
|
+
displayAsStatus: true
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
type: 'TextInput',
|
|
119
|
+
config: {
|
|
120
|
+
value: 'M-1002',
|
|
121
|
+
label: 'Case ID',
|
|
122
|
+
displayMode: 'STACKED_LARGE_VAL'
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
type: 'DateTime',
|
|
127
|
+
config: {
|
|
128
|
+
value: '2022-12-11T20:06:27.232Z',
|
|
129
|
+
label: 'Create date/time',
|
|
130
|
+
displayMode: 'STACKED_LARGE_VAL'
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
type: 'UserReference',
|
|
135
|
+
config: {
|
|
136
|
+
label: 'Create Operator',
|
|
137
|
+
value: {
|
|
138
|
+
userId: 'conns',
|
|
139
|
+
userName: 'Sara Connor'
|
|
140
|
+
},
|
|
141
|
+
placeholder: 'Select...',
|
|
142
|
+
displayMode: 'STACKED_LARGE_VAL'
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
],
|
|
146
|
+
displayMode: 'LABELS_LEFT'
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
export const regionChildrenResolved = [
|
|
150
|
+
{
|
|
151
|
+
readOnly: true,
|
|
152
|
+
value: '',
|
|
153
|
+
label: 'SLA Deadline',
|
|
154
|
+
displayMode: 'LABELS_LEFT'
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
readOnly: true,
|
|
158
|
+
value: '',
|
|
159
|
+
label: 'SLA Goal',
|
|
160
|
+
displayMode: 'LABELS_LEFT'
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
readOnly: true,
|
|
164
|
+
value: '',
|
|
165
|
+
label: 'SLA Start Time',
|
|
166
|
+
listType: 'associated',
|
|
167
|
+
datasource: [
|
|
168
|
+
{
|
|
169
|
+
key: 'AssignmentCreation',
|
|
170
|
+
value: 'The creation time of the Assignment'
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
key: 'CurrentTime',
|
|
174
|
+
value: 'Current Date Time'
|
|
175
|
+
}
|
|
176
|
+
],
|
|
177
|
+
displayMode: 'LABELS_LEFT'
|
|
178
|
+
}
|
|
179
|
+
];
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { connect, Provider, shallowEqual } from 'react-redux';
|
|
3
|
-
import { createUID } from '@pega/cosmos-react-core';
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
/* eslint-disable no-undef */
|
|
6
2
|
|
|
7
3
|
/**
|
|
8
4
|
* Given the PConnect object of a Template component, retrieve the children
|
|
@@ -141,8 +137,9 @@ export function getInstructions(pConnect, instructions = 'casestep') {
|
|
|
141
137
|
|
|
142
138
|
// If the annotation wasn't processed correctly, don't return any instruction text
|
|
143
139
|
if (instructions?.startsWith('@PARAGRAPH')) {
|
|
140
|
+
/* eslint-disable no-console */
|
|
144
141
|
console.error('@PARAGRAPH annotation was not processed. Hiding custom instructions.');
|
|
145
|
-
return undefined;
|
|
142
|
+
/* eslint-enable no-console */ return undefined;
|
|
146
143
|
}
|
|
147
144
|
|
|
148
145
|
// Custom instructions from the view
|
package/src/tasks/create/templates/Constellation/Template/DETAILS-region/StatusWork.jsx.mustache
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Status } from "@pega/cosmos-react-core";
|
|
2
|
+
|
|
3
|
+
export default function StatusWorkRenderer({ value }) {
|
|
4
|
+
let variant = "info";
|
|
5
|
+
|
|
6
|
+
const warnStrings = ["fail", "cancel", "reject", "revoke", "stopped", "warn"];
|
|
7
|
+
const infoStrings = ["open", "hold", "info", "new"];
|
|
8
|
+
const successStrings = ["resolved", "completed", "success"];
|
|
9
|
+
const pendingStrings = ["pending"];
|
|
10
|
+
|
|
11
|
+
if (new RegExp(warnStrings.join("|"), "i").test(value)) {
|
|
12
|
+
variant = "warn";
|
|
13
|
+
} else if (new RegExp(infoStrings.join("|"), "i").test(value)) {
|
|
14
|
+
variant = "info";
|
|
15
|
+
} else if (new RegExp(successStrings.join("|"), "i").test(value)) {
|
|
16
|
+
variant = "success";
|
|
17
|
+
} else if (new RegExp(pendingStrings.join("|"), "i").test(value)) {
|
|
18
|
+
variant = "pending";
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<Status type="rectangle" variant={variant}>
|
|
23
|
+
{value}
|
|
24
|
+
</Status>
|
|
25
|
+
);
|
|
26
|
+
}
|