@pega/custom-dx-components 0.24.10 → 0.24.12
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/tasks/create/templates/Constellation/Field/Icon-Button-URL/index.tsx.mustache +35 -12
- package/src/tasks/create/templates/Constellation/Template/DETAILS/index.tsx.mustache +7 -3
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/index.tsx.mustache +6 -3
- package/src/tasks/create/templates/Constellation/Template/FORM/DetailsRender.tsx +2 -1
- package/src/tasks/create/templates/Constellation/Template/FORM/index.tsx.mustache +1 -1
- package/src/tasks/create/templates/Constellation/Template/FORM-region/DetailsRender.tsx +2 -1
- package/src/tasks/create/templates/Launchpad/Field/Icon-Button-URL/PConnProps.d.ts.mustache +46 -0
- package/src/tasks/create/templates/Launchpad/Field/Icon-Button-URL/config.json.mustache +32 -0
- package/src/tasks/create/templates/Launchpad/Field/Icon-Button-URL/demo.stories.tsx.mustache +98 -0
- package/src/tasks/create/templates/Launchpad/Field/Icon-Button-URL/index.tsx.mustache +203 -0
- package/src/tasks/create/templates/Launchpad/Field/Icon-Button-URL/mock.ts.mustache +5 -0
- package/src/tasks/create/templates/Launchpad/Field/Icon-Button-URL/styles.ts.mustache +8 -0
- package/src/tasks/create/templates/Launchpad/Widget/PAGE/OneColumnPage.svg +36 -0
- package/src/tasks/create/templates/Launchpad/Widget/PAGE/PConnProps.d.ts.mustache +46 -0
- package/src/tasks/create/templates/Launchpad/Widget/PAGE/config.json.mustache +59 -0
- package/src/tasks/create/templates/Launchpad/Widget/PAGE/demo.stories.tsx.mustache +112 -0
- package/src/tasks/create/templates/Launchpad/Widget/PAGE/index.tsx.mustache +95 -0
- package/src/tasks/create/templates/Launchpad/Widget/PAGE/mock.ts.mustache +25 -0
- package/src/tasks/create/templates/Launchpad/Widget/PAGE/styles.ts.mustache +8 -0
- package/src/tasks/init/template/package.json.mustache +1 -1
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDetails/index.tsx +7 -3
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyForm/DetailsRender.tsx +2 -1
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyForm/index.tsx +1 -1
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyIconButtonURL/index.tsx +35 -12
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTwoColumnDetails/index.tsx +6 -3
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTwoColumnForm/DetailsRender.tsx +2 -1
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDetails/index.tsx +7 -3
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyForm/DetailsRender.tsx +2 -1
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyForm/index.tsx +1 -1
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyIconButtonURL/config.json +0 -32
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyIconButtonURL/demo.stories.tsx +9 -10
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyIconButtonURL/index.tsx +42 -23
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyIconButtonURL/mock.ts +1 -1
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPageWidget/demo.stories.tsx +12 -12
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPageWidget/index.tsx +5 -5
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnDetails/index.tsx +6 -3
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnForm/DetailsRender.tsx +2 -1
|
@@ -6,7 +6,8 @@ import {
|
|
|
6
6
|
registerIcon,
|
|
7
7
|
Table,
|
|
8
8
|
Label,
|
|
9
|
-
Link
|
|
9
|
+
Link,
|
|
10
|
+
URLDisplay
|
|
10
11
|
} from '@pega/cosmos-react-core';
|
|
11
12
|
import type { PConnFieldProps } from './PConnProps';
|
|
12
13
|
|
|
@@ -23,23 +24,32 @@ import StyledPegaDxilMyIconButtonUrlWrapper from './styles';
|
|
|
23
24
|
// interface for props
|
|
24
25
|
interface PegaDxilMyIconButtonUrlProps extends PConnFieldProps {
|
|
25
26
|
// If any, enter additional props that only exist on TextInput here
|
|
26
|
-
countryCode: string;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
export const textFormatter = (value: string) => {
|
|
30
|
+
const displayComponent = (
|
|
31
|
+
<URLDisplay target='_blank' value={value} displayText={value} variant='link' />
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
return displayComponent;
|
|
35
|
+
};
|
|
36
|
+
|
|
29
37
|
// *************
|
|
30
|
-
// This component is meant to be an example of usage (Icon, Button, etc.) and NOT meant to be
|
|
38
|
+
// This component is meant to be an example of usage (Icon, Button, Link, etc.) and NOT meant to be
|
|
31
39
|
// used "as is"
|
|
32
40
|
//
|
|
33
41
|
// In this example, Icon is shown on its own and inside a Button
|
|
34
42
|
// Though an Icon can have an "onClick" event is it recommended if you want to click on it,
|
|
35
|
-
// to put it in a Button (shown below), so you can have a tooltip and hover style
|
|
43
|
+
// to put it in a Button (shown below), so you can have a tooltip and hover style or put it
|
|
44
|
+
// in a Link (shown below) as a URL.
|
|
36
45
|
//
|
|
37
|
-
//
|
|
38
|
-
// table below. The table dispaly will toggle with the click of the button icon.
|
|
46
|
+
// For the button, the click will get a list of countries and display in a table
|
|
39
47
|
//
|
|
40
|
-
// Globe icon is an icon placed in a
|
|
41
|
-
// the
|
|
42
|
-
// another icon, so with "icon" specified in the
|
|
48
|
+
// Globe icon is an icon placed in a Link element. The Link element to use an icon internally. (NOTE: In general
|
|
49
|
+
// the Link element shows the open icon to the left of the link text, but here we are using
|
|
50
|
+
// another icon, so with "icon" specified in the Link element, the open icon doesn't show)
|
|
51
|
+
// Link elements do not handle bad urls well, so we have a simple validator to prevent the Link element
|
|
52
|
+
// from getting most bad urls.
|
|
43
53
|
//
|
|
44
54
|
// NOTE: because icons have to be imported and registered, you can NOT put the icon name
|
|
45
55
|
// inside the config.json and let the user pick it, if it is not already part of your
|
|
@@ -49,10 +59,10 @@ interface PegaDxilMyIconButtonUrlProps extends PConnFieldProps {
|
|
|
49
59
|
// props passed in combination of props from property panel (config.json) and run time props from Constellation
|
|
50
60
|
// any default values in config.pros should be set in defaultProps at bottom of this file
|
|
51
61
|
function PegaDxilMyIconButtonUrl(props: PegaDxilMyIconButtonUrlProps) {
|
|
52
|
-
const { value,
|
|
62
|
+
const { value, displayMode, getPConnect, testId } = props;
|
|
53
63
|
const [statelist, setStatelist] = useState([]);
|
|
54
64
|
const [showTable, setShowTable] = useState(false);
|
|
55
|
-
const [validUrl, setValidUrl] = useState('');
|
|
65
|
+
const [validUrl, setValidUrl] = useState('about:blank');
|
|
56
66
|
const PConnect = getPConnect();
|
|
57
67
|
|
|
58
68
|
// IMPORTANT: need to register icons used in camel case
|
|
@@ -61,8 +71,8 @@ function PegaDxilMyIconButtonUrl(props: PegaDxilMyIconButtonUrlProps) {
|
|
|
61
71
|
|
|
62
72
|
// setting up columns for the work list table
|
|
63
73
|
const columns = [
|
|
64
|
-
{ renderer: '
|
|
65
|
-
{ renderer: '
|
|
74
|
+
{ renderer: 'countryName', label: PConnect.getLocalizedValue('Country Name', '', '') },
|
|
75
|
+
{ renderer: 'shortName', label: PConnect.getLocalizedValue('Abbreviation', '', '') }
|
|
66
76
|
];
|
|
67
77
|
|
|
68
78
|
// toggle showing table and getting table data
|
|
@@ -70,7 +80,7 @@ function PegaDxilMyIconButtonUrl(props: PegaDxilMyIconButtonUrlProps) {
|
|
|
70
80
|
setShowTable(prevShowTable => !prevShowTable);
|
|
71
81
|
}
|
|
72
82
|
|
|
73
|
-
// check if url is valid
|
|
83
|
+
// check if url is valid (simple)
|
|
74
84
|
function validateUrl(href: string) {
|
|
75
85
|
return /^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:[/?#]\S*)?$/i.test(
|
|
76
86
|
href
|
|
@@ -83,11 +93,13 @@ function PegaDxilMyIconButtonUrl(props: PegaDxilMyIconButtonUrlProps) {
|
|
|
83
93
|
// For example: Since the value is the property field,
|
|
84
94
|
// it could be entered from another component and thus as it is
|
|
85
95
|
// entered (typed in), it won't be valid until it is all entered.
|
|
96
|
+
// NOTE: can't have a blank value for the url as the Link element will error out
|
|
97
|
+
// in App studio preview
|
|
86
98
|
useEffect(() => {
|
|
87
99
|
if (validateUrl(value)) {
|
|
88
100
|
setValidUrl(value);
|
|
89
101
|
} else {
|
|
90
|
-
setValidUrl('');
|
|
102
|
+
setValidUrl('about:blank');
|
|
91
103
|
}
|
|
92
104
|
}, [value]);
|
|
93
105
|
|
|
@@ -96,9 +108,9 @@ function PegaDxilMyIconButtonUrl(props: PegaDxilMyIconButtonUrlProps) {
|
|
|
96
108
|
// get data from a data page and a PConnect function
|
|
97
109
|
// to get getContextName
|
|
98
110
|
useEffect(() => {
|
|
99
|
-
const dataViewName = '
|
|
111
|
+
const dataViewName = 'CountryList';
|
|
100
112
|
const context = PConnect.getContextName();
|
|
101
|
-
const params = {
|
|
113
|
+
const params = { };
|
|
102
114
|
|
|
103
115
|
// only retrieve table data if table is shown
|
|
104
116
|
if (showTable) {
|
|
@@ -113,8 +125,8 @@ function PegaDxilMyIconButtonUrl(props: PegaDxilMyIconButtonUrlProps) {
|
|
|
113
125
|
// MUST have an id/index or will get a setExtraStackFrame error
|
|
114
126
|
// put a key in the table
|
|
115
127
|
return {
|
|
116
|
-
|
|
117
|
-
|
|
128
|
+
countryName: entry.Name,
|
|
129
|
+
shortName: entry.ShortName,
|
|
118
130
|
id: index
|
|
119
131
|
};
|
|
120
132
|
})
|
|
@@ -124,7 +136,15 @@ function PegaDxilMyIconButtonUrl(props: PegaDxilMyIconButtonUrlProps) {
|
|
|
124
136
|
console.log(error);
|
|
125
137
|
});
|
|
126
138
|
}
|
|
127
|
-
}, [PConnect,
|
|
139
|
+
}, [PConnect, showTable]);
|
|
140
|
+
|
|
141
|
+
// when DISPLAY_ONLY, in this example we will just show the URL.
|
|
142
|
+
if (displayMode === 'DISPLAY_ONLY') {
|
|
143
|
+
const displayComp = textFormatter(validUrl);
|
|
144
|
+
return (
|
|
145
|
+
<StyledPegaDxilMyIconButtonUrlWrapper> {displayComp} </StyledPegaDxilMyIconButtonUrlWrapper>
|
|
146
|
+
);
|
|
147
|
+
}
|
|
128
148
|
|
|
129
149
|
return (
|
|
130
150
|
<StyledPegaDxilMyIconButtonUrlWrapper>
|
|
@@ -138,12 +158,11 @@ function PegaDxilMyIconButtonUrl(props: PegaDxilMyIconButtonUrlProps) {
|
|
|
138
158
|
/>
|
|
139
159
|
<Label style={{ margin: '0.1rem' }}>
|
|
140
160
|
{' '}
|
|
141
|
-
{PConnect.getLocalizedValue('
|
|
142
|
-
{PConnect.getLocalizedValue(`${countryCode}`, '', '')}{' '}
|
|
161
|
+
{PConnect.getLocalizedValue('List of countries', '', '')}{' '}
|
|
143
162
|
</Label>
|
|
144
163
|
<Button
|
|
145
164
|
icon
|
|
146
|
-
label={PConnect.getLocalizedValue('Click to show/hide
|
|
165
|
+
label={PConnect.getLocalizedValue('Click to show/hide country list', '', '')}
|
|
147
166
|
variant='link'
|
|
148
167
|
compact={false}
|
|
149
168
|
onClick={showHideTable}
|
|
@@ -24,22 +24,22 @@ if (!window.PCore) {
|
|
|
24
24
|
const worklistData = {
|
|
25
25
|
data: [
|
|
26
26
|
{
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
CaseName: 'Loan',
|
|
28
|
+
BusinessID: ' A-8002',
|
|
29
|
+
ProcessName: 'New',
|
|
30
|
+
TaskName: 'Details'
|
|
31
31
|
},
|
|
32
32
|
{
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
CaseName: 'Loan',
|
|
34
|
+
BusinessID: ' A-7001',
|
|
35
|
+
ProcessName: 'Open',
|
|
36
|
+
TaskName: 'Info'
|
|
37
37
|
},
|
|
38
38
|
{
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
CaseName: 'Loan',
|
|
40
|
+
BusinessID: ' A-9000',
|
|
41
|
+
ProcessName: 'Open',
|
|
42
|
+
TaskName: 'Amount'
|
|
43
43
|
}
|
|
44
44
|
]
|
|
45
45
|
};
|
|
@@ -44,7 +44,7 @@ function PegaDxilMyPageWidget(props: PegaDxilMyPageWidgetProps) {
|
|
|
44
44
|
// get data from a data page and a PConnect function
|
|
45
45
|
// to get getContextName
|
|
46
46
|
useEffect(() => {
|
|
47
|
-
const dataViewName = '
|
|
47
|
+
const dataViewName = 'MyWorkList';
|
|
48
48
|
const context = PConnect.getContextName();
|
|
49
49
|
|
|
50
50
|
PCore.getDataPageUtils()
|
|
@@ -58,10 +58,10 @@ function PegaDxilMyPageWidget(props: PegaDxilMyPageWidgetProps) {
|
|
|
58
58
|
// MUST have an id/index or will get a setExtraStackFrame error
|
|
59
59
|
// put a key in the table
|
|
60
60
|
return {
|
|
61
|
-
caseType: entry.
|
|
62
|
-
insKey: entry.
|
|
63
|
-
status: entry.
|
|
64
|
-
stage: entry.
|
|
61
|
+
caseType: entry.CaseName,
|
|
62
|
+
insKey: entry.BusinessID,
|
|
63
|
+
status: entry.ProcessName,
|
|
64
|
+
stage: entry.TaskName,
|
|
65
65
|
id: index
|
|
66
66
|
};
|
|
67
67
|
})
|
|
@@ -34,7 +34,7 @@ function PegaDxilMyTwoColumnDetails(props: PegaDxilMyTwoColumnDetailsProps) {
|
|
|
34
34
|
|
|
35
35
|
const numRegions = getAllFields(getPConnect)?.length;
|
|
36
36
|
const gridRepeat = "repeat(".concat(numRegions).concat(", 1fr)");
|
|
37
|
-
const gridContainer = {
|
|
37
|
+
const gridContainer = { colGap: 0, 'margin-line-start': 0 };
|
|
38
38
|
// @ts-ignore
|
|
39
39
|
gridContainer.cols = gridRepeat;
|
|
40
40
|
// @ts-ignore
|
|
@@ -93,8 +93,11 @@ function PegaDxilMyTwoColumnDetails(props: PegaDxilMyTwoColumnDetailsProps) {
|
|
|
93
93
|
)}
|
|
94
94
|
<Grid container={gridContainer} data-testid={`column-count-${numRegions}`} >
|
|
95
95
|
{children.map((child: any, i: number) => (
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
<Flex
|
|
97
|
+
// @ts-ignore
|
|
98
|
+
container={{ direction: 'column', alignItems: 'normal', colGap: 0, rowGap: 1.5 }}
|
|
99
|
+
key={`r-${i + 1}`}
|
|
100
|
+
>
|
|
98
101
|
<DetailsRender child={child} />
|
|
99
102
|
</Flex>
|
|
100
103
|
))}
|