@pega/custom-dx-components 0.24.11 → 0.24.13
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/build-all/helper.js +6 -0
- package/src/tasks/build-comp/helper.js +8 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/{DetailsRender.tsx → DetailsRender.tsx.mustache} +7 -10
- package/src/tasks/create/templates/Constellation/Template/DETAILS/{HighlightRender.tsx → HighlightRender.tsx.mustache} +12 -13
- package/src/tasks/create/templates/Constellation/Template/DETAILS/demo.stories.tsx.mustache +27 -7
- package/src/tasks/create/templates/Constellation/Template/DETAILS/index.tsx.mustache +26 -33
- package/src/tasks/create/templates/Constellation/Template/DETAILS/mock.ts.mustache +4 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/styles.ts.mustache +16 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/{DetailsRender.tsx → DetailsRender.tsx.mustache} +7 -10
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/{HighlightRender.tsx → HighlightRender.tsx.mustache} +12 -13
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/demo.stories.tsx.mustache +45 -10
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/index.tsx.mustache +19 -41
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/mock.ts.mustache +4 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/styles.ts.mustache +15 -0
- package/src/tasks/create/templates/Constellation/Template/PAGE/localizations.json.mustache +4 -2
- package/src/tasks/create/templates/Constellation/Widget/PAGE/demo.stories.tsx.mustache +5 -5
- package/src/tasks/create/templates/Constellation/Widget/PAGE/index.tsx.mustache +1 -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/src/tasks/publish/helper.js +6 -0
- package/src/tasks/publish-all/helper.js +6 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDetails/DetailsRender.tsx +4 -10
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDetails/HighlightRender.tsx +9 -13
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDetails/demo.stories.tsx +27 -7
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDetails/index.tsx +26 -33
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDetails/mock.ts +4 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDetails/styles.ts +16 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPage/localizations.json +4 -2
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPageWidget/demo.stories.tsx +5 -5
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPageWidget/index.tsx +1 -1
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTwoColumnDetails/DetailsRender.tsx +4 -10
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTwoColumnDetails/HighlightRender.tsx +9 -13
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTwoColumnDetails/demo.stories.tsx +45 -10
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTwoColumnDetails/index.tsx +19 -41
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTwoColumnDetails/mock.ts +4 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTwoColumnDetails/styles.ts +15 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDetails/DetailsRender.tsx +4 -10
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDetails/HighlightRender.tsx +9 -13
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDetails/demo.stories.tsx +27 -7
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDetails/index.tsx +26 -33
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDetails/mock.ts +4 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDetails/styles.ts +16 -0
- 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 +11 -15
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyIconButtonURL/mock.ts +1 -1
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPage/localizations.json +4 -2
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPageWidget/demo.stories.tsx +13 -13
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPageWidget/index.tsx +6 -6
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnDetails/DetailsRender.tsx +4 -10
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnDetails/HighlightRender.tsx +9 -13
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnDetails/demo.stories.tsx +45 -10
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnDetails/index.tsx +19 -41
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnDetails/mock.ts +4 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnDetails/styles.ts +15 -0
|
@@ -6,3 +6,18 @@ export default styled.div(() => {
|
|
|
6
6
|
margin: 0px 0;
|
|
7
7
|
`;
|
|
8
8
|
});
|
|
9
|
+
|
|
10
|
+
export const StyledDetailsGridContainer = styled.div(() => {
|
|
11
|
+
return css`
|
|
12
|
+
margin-line-start: 1;
|
|
13
|
+
`;
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export const StyledHighlightedFieldsHrLine = styled.hr(() => {
|
|
17
|
+
return css`
|
|
18
|
+
line: {
|
|
19
|
+
margin: '0.75rem 0';
|
|
20
|
+
opacity: '50%'
|
|
21
|
+
}
|
|
22
|
+
`;
|
|
23
|
+
});
|
|
@@ -97,11 +97,11 @@ export const Base{{COMPONENT_CLASS_NAME}}: Story = args => {
|
|
|
97
97
|
}
|
|
98
98
|
};
|
|
99
99
|
|
|
100
|
-
return (
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
100
|
+
return (
|
|
101
|
+
<>
|
|
102
|
+
<{{COMPONENT_CLASS_NAME}} {...props} {...args} />
|
|
103
|
+
</>
|
|
104
|
+
);
|
|
105
105
|
};
|
|
106
106
|
|
|
107
107
|
Base{{COMPONENT_CLASS_NAME}}.args = {
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import {PConnect } from '@pega/pcore-pconnect-typedefs';
|
|
2
|
+
|
|
3
|
+
// PConnProps.d.ts
|
|
4
|
+
// This gives us a place to have each component (which is most DX Components) that is
|
|
5
|
+
// expected to have a getPConnect extend its props (from BaseProps)
|
|
6
|
+
// such that every component will be expected to have a getPConnect() function
|
|
7
|
+
// that returns a PConnect object. (new/better way of doing .propTypes).
|
|
8
|
+
// This PConnProps can be extended to include other props that we know are in every component
|
|
9
|
+
export interface PConnProps {
|
|
10
|
+
// getPConnect should exist for every C11n component. (add @ts-ignore in special cases where it isn't)
|
|
11
|
+
getPConnect: () => typeof PConnect;
|
|
12
|
+
|
|
13
|
+
// Allow any/all other key/value pairs in the BaseProps for now
|
|
14
|
+
// TODO: refine which other props are always expected for various component
|
|
15
|
+
// types and consider further interface "subclassing". For example, we may
|
|
16
|
+
// want to create a "BasePropsForm" that gives guidance on required, readonly, etc.
|
|
17
|
+
// and any other props that every Form component expects.
|
|
18
|
+
// For example, see the PConnFieldProps below.
|
|
19
|
+
// NOTE: if you uncomment the line below, the PConnProps type will allow
|
|
20
|
+
// otherwise undefined types to appear. This can be helpful for debugging
|
|
21
|
+
// or when adding new components whose types aren't yet known.
|
|
22
|
+
// [key: string]: any;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
// PConnFieldProps extends PConnProps to bring in the common properties that are
|
|
27
|
+
// associated with most field components (ex: Dropdown, TextInput, etc.) in the
|
|
28
|
+
// components/field directory
|
|
29
|
+
export interface PConnFieldProps extends PConnProps {
|
|
30
|
+
label: string,
|
|
31
|
+
required: boolean,
|
|
32
|
+
disabled: boolean,
|
|
33
|
+
value: any,
|
|
34
|
+
validatemessage: string,
|
|
35
|
+
status?: string,
|
|
36
|
+
onChange?: any,
|
|
37
|
+
onBlur?: any,
|
|
38
|
+
readOnly: boolean,
|
|
39
|
+
testId: string,
|
|
40
|
+
helperText: string,
|
|
41
|
+
displayMode?: string,
|
|
42
|
+
hideLabel: boolean,
|
|
43
|
+
placeholder?: string,
|
|
44
|
+
fieldMetadata?: any,
|
|
45
|
+
additionalProps?: any
|
|
46
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
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": "images/pz-url-active.svg",
|
|
13
|
+
"properties": [
|
|
14
|
+
{
|
|
15
|
+
"label": "Advanced",
|
|
16
|
+
"format": "GROUP",
|
|
17
|
+
"collapsible": true,
|
|
18
|
+
"properties": [
|
|
19
|
+
{
|
|
20
|
+
"name": "testId",
|
|
21
|
+
"label": "Test ID",
|
|
22
|
+
"format": "TEXT",
|
|
23
|
+
"ignorePattern": "[^-_\\p{N}\\p{L}]",
|
|
24
|
+
"includeAnnotations": false
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
"defaultConfig": {
|
|
30
|
+
"label": "@L $this.label"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
|
|
2
|
+
/* eslint-disable react/jsx-no-useless-fragment */
|
|
3
|
+
// @ts-nocheck
|
|
4
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
5
|
+
|
|
6
|
+
import {{COMPONENT_CLASS_NAME}} from './index';
|
|
7
|
+
import { stateProps, configProps } from './mock';
|
|
8
|
+
|
|
9
|
+
const meta: Meta<typeof {{COMPONENT_CLASS_NAME}}> = {
|
|
10
|
+
title: '{{COMPONENT_CLASS_NAME}}',
|
|
11
|
+
component: {{COMPONENT_CLASS_NAME}},
|
|
12
|
+
excludeStories: /.*Data$/
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default meta;
|
|
16
|
+
type Story = StoryObj<typeof {{COMPONENT_CLASS_NAME}}>;
|
|
17
|
+
|
|
18
|
+
if (!window.PCore) {
|
|
19
|
+
window.PCore = {};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const countrylistData = {
|
|
23
|
+
data: [
|
|
24
|
+
{
|
|
25
|
+
Name: 'United States of America',
|
|
26
|
+
ShortName: 'USA'
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
Name: 'Canada',
|
|
30
|
+
ShortName: 'CAN'
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
Name: 'Mexico',
|
|
34
|
+
ShortName: 'MEX'
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
window.PCore.getDataPageUtils = () => {
|
|
40
|
+
return {
|
|
41
|
+
getDataAsync: () => {
|
|
42
|
+
return new Promise(resolve => {
|
|
43
|
+
resolve(countrylistData);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const Base{{COMPONENT_CLASS_NAME}}: Story = args => {
|
|
50
|
+
|
|
51
|
+
const props = {
|
|
52
|
+
getPConnect: () => {
|
|
53
|
+
return {
|
|
54
|
+
getValue: value => {
|
|
55
|
+
return value;
|
|
56
|
+
},
|
|
57
|
+
getContextName: () => {
|
|
58
|
+
return 'app/primary_1';
|
|
59
|
+
},
|
|
60
|
+
getLocalizedValue: value => {
|
|
61
|
+
return value;
|
|
62
|
+
},
|
|
63
|
+
getActionsApi: () => {
|
|
64
|
+
return {
|
|
65
|
+
updateFieldValue: () => {
|
|
66
|
+
/* nothing */
|
|
67
|
+
},
|
|
68
|
+
triggerFieldChange: () => {
|
|
69
|
+
/* nothing */
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
},
|
|
73
|
+
ignoreSuggestion: () => {
|
|
74
|
+
/* nothing */
|
|
75
|
+
},
|
|
76
|
+
acceptSuggestion: () => {
|
|
77
|
+
/* nothing */
|
|
78
|
+
},
|
|
79
|
+
setInheritedProps: () => {
|
|
80
|
+
/* nothing */
|
|
81
|
+
},
|
|
82
|
+
resolveConfigProps: () => {
|
|
83
|
+
/* nothing */
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
return (
|
|
90
|
+
<>
|
|
91
|
+
<{{COMPONENT_CLASS_NAME}} {...props} {...args} />
|
|
92
|
+
</>
|
|
93
|
+
);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
Base{{COMPONENT_CLASS_NAME}}.args = {
|
|
97
|
+
|
|
98
|
+
};
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Icon,
|
|
4
|
+
Button,
|
|
5
|
+
withConfiguration,
|
|
6
|
+
registerIcon,
|
|
7
|
+
Table,
|
|
8
|
+
Label,
|
|
9
|
+
Link,
|
|
10
|
+
URLDisplay
|
|
11
|
+
} from '@pega/cosmos-react-core';
|
|
12
|
+
import type { PConnFieldProps } from './PConnProps';
|
|
13
|
+
|
|
14
|
+
// IMPORTANT
|
|
15
|
+
// To use Icons, need to individually import the icon file form @pega/cosmos-react-core (see path below)
|
|
16
|
+
// Icons filename is kabab case (file-name), where as the icon you import is camel case (fileName)
|
|
17
|
+
// Icons need to be registered (camel case), and then used (kabab case)
|
|
18
|
+
import * as listNumber from '@pega/cosmos-react-core/lib/components/Icon/icons/list-number.icon';
|
|
19
|
+
import * as arrowRight from '@pega/cosmos-react-core/lib/components/Icon/icons/arrow-right.icon';
|
|
20
|
+
import * as globe from '@pega/cosmos-react-core/lib/components/Icon/icons/globe.icon';
|
|
21
|
+
|
|
22
|
+
import Styled{{COMPONENT_CLASS_NAME}}Wrapper from './styles';
|
|
23
|
+
|
|
24
|
+
// interface for props
|
|
25
|
+
interface {{COMPONENT_CLASS_NAME}}Props extends PConnFieldProps {
|
|
26
|
+
// If any, enter additional props that only exist on TextInput here
|
|
27
|
+
}
|
|
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
|
+
|
|
37
|
+
// *************
|
|
38
|
+
// This component is meant to be an example of usage (Icon, Button, Link, etc.) and NOT meant to be
|
|
39
|
+
// used "as is"
|
|
40
|
+
//
|
|
41
|
+
// In this example, Icon is shown on its own and inside a Button
|
|
42
|
+
// Though an Icon can have an "onClick" event is it recommended if you want to click on it,
|
|
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.
|
|
45
|
+
//
|
|
46
|
+
// For the button, the click will get a list of countries and display in a table
|
|
47
|
+
//
|
|
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.
|
|
53
|
+
//
|
|
54
|
+
// NOTE: because icons have to be imported and registered, you can NOT put the icon name
|
|
55
|
+
// inside the config.json and let the user pick it, if it is not already part of your
|
|
56
|
+
// import and registration (can't be done on the fly)
|
|
57
|
+
// **************
|
|
58
|
+
|
|
59
|
+
// props passed in combination of props from property panel (config.json) and run time props from Constellation
|
|
60
|
+
// any default values in config.pros should be set in defaultProps at bottom of this file
|
|
61
|
+
function {{COMPONENT_CLASS_NAME}}(props: {{COMPONENT_CLASS_NAME}}Props) {
|
|
62
|
+
const { value, displayMode, getPConnect, testId } = props;
|
|
63
|
+
const [statelist, setStatelist] = useState([]);
|
|
64
|
+
const [showTable, setShowTable] = useState(false);
|
|
65
|
+
const [validUrl, setValidUrl] = useState('about:blank');
|
|
66
|
+
const PConnect = getPConnect();
|
|
67
|
+
|
|
68
|
+
// IMPORTANT: need to register icons used in camel case
|
|
69
|
+
registerIcon(listNumber, arrowRight, globe);
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
// setting up columns for the work list table
|
|
73
|
+
const columns = [
|
|
74
|
+
{ renderer: 'countryName', label: PConnect.getLocalizedValue('Country Name', '', '') },
|
|
75
|
+
{ renderer: 'shortName', label: PConnect.getLocalizedValue('Abbreviation', '', '') }
|
|
76
|
+
];
|
|
77
|
+
|
|
78
|
+
// toggle showing table and getting table data
|
|
79
|
+
function showHideTable() {
|
|
80
|
+
setShowTable(prevShowTable => !prevShowTable);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// check if url is valid (simple)
|
|
84
|
+
function validateUrl(href: string) {
|
|
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(
|
|
86
|
+
href
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Testing to see if value entered is valid url, if not can't use it.
|
|
91
|
+
// Reason for this code is that you can NOT pass to Link component
|
|
92
|
+
// a bad url, or it will error out.
|
|
93
|
+
// For example: Since the value is the property field,
|
|
94
|
+
// it could be entered from another component and thus as it is
|
|
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
|
|
98
|
+
useEffect(() => {
|
|
99
|
+
if (validateUrl(value)) {
|
|
100
|
+
setValidUrl(value);
|
|
101
|
+
} else {
|
|
102
|
+
setValidUrl('about:blank');
|
|
103
|
+
}
|
|
104
|
+
}, [value]);
|
|
105
|
+
|
|
106
|
+
// going to get data for worklist to put into a table
|
|
107
|
+
// data comes from calling a PCore function to get
|
|
108
|
+
// get data from a data page and a PConnect function
|
|
109
|
+
// to get getContextName
|
|
110
|
+
useEffect(() => {
|
|
111
|
+
const dataViewName = 'CountryList';
|
|
112
|
+
const context = PConnect.getContextName();
|
|
113
|
+
const params = { };
|
|
114
|
+
|
|
115
|
+
// only retrieve table data if table is shown
|
|
116
|
+
if (showTable) {
|
|
117
|
+
PCore.getDataPageUtils()
|
|
118
|
+
.getDataAsync(dataViewName, context, params, null, null)
|
|
119
|
+
// @ts-ignore
|
|
120
|
+
.then((response: any) => {
|
|
121
|
+
// table requires an index or will get setExtraStackFrame error
|
|
122
|
+
setStatelist(
|
|
123
|
+
response.data.map((entry: any, index: number) => {
|
|
124
|
+
// mapping the data into the column names
|
|
125
|
+
// MUST have an id/index or will get a setExtraStackFrame error
|
|
126
|
+
// put a key in the table
|
|
127
|
+
return {
|
|
128
|
+
countryName: entry.Name,
|
|
129
|
+
shortName: entry.ShortName,
|
|
130
|
+
id: index
|
|
131
|
+
};
|
|
132
|
+
})
|
|
133
|
+
);
|
|
134
|
+
})
|
|
135
|
+
.catch((error: any) => {
|
|
136
|
+
console.log(error);
|
|
137
|
+
});
|
|
138
|
+
}
|
|
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
|
+
<Styled{{COMPONENT_CLASS_NAME}}Wrapper> {displayComp} </Styled{{COMPONENT_CLASS_NAME}}Wrapper>
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return (
|
|
150
|
+
<Styled{{COMPONENT_CLASS_NAME}}Wrapper>
|
|
151
|
+
{{! pick new delimiters for mustache }}
|
|
152
|
+
{{=<% %>=}}
|
|
153
|
+
<div style={{ display: 'flex' }} data-testid={testId}>
|
|
154
|
+
<Icon
|
|
155
|
+
style={{ height: '1.5rem', width: '1.5rem' }}
|
|
156
|
+
// icon name is kabab case
|
|
157
|
+
name='arrow-right'
|
|
158
|
+
role='img'
|
|
159
|
+
aria-label='arrow right'
|
|
160
|
+
/>
|
|
161
|
+
<Label style={{ margin: '0.1rem' }}>
|
|
162
|
+
{' '}
|
|
163
|
+
{PConnect.getLocalizedValue('List of countries', '', '')}{' '}
|
|
164
|
+
</Label>
|
|
165
|
+
<Button
|
|
166
|
+
icon
|
|
167
|
+
label={PConnect.getLocalizedValue('Click to show/hide country list', '', '')}
|
|
168
|
+
variant='link'
|
|
169
|
+
compact={false}
|
|
170
|
+
onClick={showHideTable}
|
|
171
|
+
>
|
|
172
|
+
<Icon
|
|
173
|
+
style={{ height: '1.5rem', width: '1.5rem' }}
|
|
174
|
+
// icon name is kabab case
|
|
175
|
+
name='list-number'
|
|
176
|
+
role='img'
|
|
177
|
+
aria-label='numbered list'
|
|
178
|
+
/>
|
|
179
|
+
</Button>
|
|
180
|
+
<Link href={validUrl} variant='link' label={validUrl} icon>
|
|
181
|
+
<Icon
|
|
182
|
+
style={{ height: '1.5rem', width: '1.5rem' }}
|
|
183
|
+
// icon name is kabab case
|
|
184
|
+
name='globe'
|
|
185
|
+
role='img'
|
|
186
|
+
aria-label='open link'
|
|
187
|
+
/>
|
|
188
|
+
</Link>
|
|
189
|
+
</div>
|
|
190
|
+
{showTable && (
|
|
191
|
+
<Table
|
|
192
|
+
title={PConnect.getLocalizedValue('State list', '', '')}
|
|
193
|
+
columns={columns}
|
|
194
|
+
data={statelist}
|
|
195
|
+
/>
|
|
196
|
+
)}
|
|
197
|
+
<%={{ }}=%> {{! revert delimiters for mustache }}
|
|
198
|
+
</Styled{{COMPONENT_CLASS_NAME}}Wrapper>
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
export default withConfiguration({{COMPONENT_CLASS_NAME}});
|
|
@@ -0,0 +1,36 @@
|
|
|
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>1 col </title>
|
|
4
|
+
<defs>
|
|
5
|
+
<rect id="path-1" x="0" y="0" width="100" height="70"></rect>
|
|
6
|
+
</defs>
|
|
7
|
+
<g id="Concepts" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
|
8
|
+
<g id="Templates" transform="translate(-98.000000, -108.000000)">
|
|
9
|
+
<g id="Change-template" transform="translate(42.000000, 36.000000)">
|
|
10
|
+
<g id="1-col-" transform="translate(56.000000, 72.000000)">
|
|
11
|
+
<mask id="mask-2" fill="white">
|
|
12
|
+
<use xlink:href="#path-1"></use>
|
|
13
|
+
</mask>
|
|
14
|
+
<rect stroke="#A5A8BC" stroke-width="0.5" x="0.25" y="0.25" width="99.5" height="69.5"></rect>
|
|
15
|
+
<g id="white" mask="url(#mask-2)" fill="#FFFFFF">
|
|
16
|
+
<g transform="translate(3.000000, 3.000000)" id="Rectangle">
|
|
17
|
+
<rect x="0" y="0" width="94" height="66.5"></rect>
|
|
18
|
+
</g>
|
|
19
|
+
</g>
|
|
20
|
+
<g id="gray" mask="url(#mask-2)" fill="#8084A7">
|
|
21
|
+
<g transform="translate(6.000000, 6.000000)" id="Rectangle">
|
|
22
|
+
<rect x="0" y="-2.84217094e-14" width="88" height="77.8"></rect>
|
|
23
|
+
</g>
|
|
24
|
+
</g>
|
|
25
|
+
<g id="labels" mask="url(#mask-2)" font-family="OpenSans-Semibold, Open Sans" font-size="11" font-weight="500">
|
|
26
|
+
<g transform="translate(44.000000, 17.000000)" id="A">
|
|
27
|
+
<text>
|
|
28
|
+
<tspan x="0.75" y="12" fill="#FFFFFF">A</tspan>
|
|
29
|
+
</text>
|
|
30
|
+
</g>
|
|
31
|
+
</g>
|
|
32
|
+
</g>
|
|
33
|
+
</g>
|
|
34
|
+
</g>
|
|
35
|
+
</g>
|
|
36
|
+
</svg>
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import {PConnect } from '@pega/pcore-pconnect-typedefs';
|
|
2
|
+
|
|
3
|
+
// PConnProps.d.ts
|
|
4
|
+
// This gives us a place to have each component (which is most DX Components) that is
|
|
5
|
+
// expected to have a getPConnect extend its props (from BaseProps)
|
|
6
|
+
// such that every component will be expected to have a getPConnect() function
|
|
7
|
+
// that returns a PConnect object. (new/better way of doing .propTypes).
|
|
8
|
+
// This PConnProps can be extended to include other props that we know are in every component
|
|
9
|
+
export interface PConnProps {
|
|
10
|
+
// getPConnect should exist for every C11n component. (add @ts-ignore in special cases where it isn't)
|
|
11
|
+
getPConnect: () => typeof PConnect;
|
|
12
|
+
|
|
13
|
+
// Allow any/all other key/value pairs in the BaseProps for now
|
|
14
|
+
// TODO: refine which other props are always expected for various component
|
|
15
|
+
// types and consider further interface "subclassing". For example, we may
|
|
16
|
+
// want to create a "BasePropsForm" that gives guidance on required, readonly, etc.
|
|
17
|
+
// and any other props that every Form component expects.
|
|
18
|
+
// For example, see the PConnFieldProps below.
|
|
19
|
+
// NOTE: if you uncomment the line below, the PConnProps type will allow
|
|
20
|
+
// otherwise undefined types to appear. This can be helpful for debugging
|
|
21
|
+
// or when adding new components whose types aren't yet known.
|
|
22
|
+
// [key: string]: any;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
// PConnFieldProps extends PConnProps to bring in the common properties that are
|
|
27
|
+
// associated with most field components (ex: Dropdown, TextInput, etc.) in the
|
|
28
|
+
// components/field directory
|
|
29
|
+
export interface PConnFieldProps extends PConnProps {
|
|
30
|
+
label: string,
|
|
31
|
+
required: boolean,
|
|
32
|
+
disabled: boolean,
|
|
33
|
+
value: any,
|
|
34
|
+
validatemessage: string,
|
|
35
|
+
status?: string,
|
|
36
|
+
onChange?: any,
|
|
37
|
+
onBlur?: any,
|
|
38
|
+
readOnly: boolean,
|
|
39
|
+
testId: string,
|
|
40
|
+
helperText: string,
|
|
41
|
+
displayMode?: string,
|
|
42
|
+
hideLabel: boolean,
|
|
43
|
+
placeholder?: string,
|
|
44
|
+
fieldMetadata?: any,
|
|
45
|
+
additionalProps?: any
|
|
46
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
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": "OneColumnPage.svg",
|
|
13
|
+
"properties": [
|
|
14
|
+
{
|
|
15
|
+
"name": "description",
|
|
16
|
+
"label": "Description",
|
|
17
|
+
"format": "TEXT",
|
|
18
|
+
"defaultValue": "We've launched a brand new experience to accelerate your workflow. Check out the guides to help you get the most of Cosmos."
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"name": "whatsnewlink",
|
|
22
|
+
"label": "What's new link",
|
|
23
|
+
"format": "TEXT",
|
|
24
|
+
"defaultValue": "https://design.pega.com"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"name": "image",
|
|
28
|
+
"label": "Image link",
|
|
29
|
+
"format": "TEXT",
|
|
30
|
+
"defaultValue": "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzOSAxMSI+PHRpdGxlPlBlZ2EgdGV4dC1vbmx5IGxvZ288L3RpdGxlPjxwYXRoIHN0eWxlPSJmaWxsLW9wYWNpdHk6IC4yNTsiIGZpbGw9IiNmZmYiIGQ9Ik03LjcyIDMuODJjMCAyLjI1LTEuNzggMy40MS00IDMuNDFoLTEuNnYzSDBWLjQyaDMuOTRjMi4zNiAwIDMuNzggMS4zOSAzLjc4IDMuNHptLTQtMS40N2gtMS42djNoMS43QTEuNDcgMS40NyAwIDAgMCA1LjUgMy44MmMwLS45MS0uNjUtMS40Ny0xLjc1LTEuNDd6bTcuNjggNS45MWg1LjN2Mkg5LjI5Vi40Mmg3LjM4djEuOTNoLTUuMjR2Mmg0LjI0djEuOWgtNC4yNHpNMjMuMTggMGE1IDUgMCAwIDEgMy41NyAxLjI4TDI1LjYzIDIuOGEzLjc4IDMuNzggMCAwIDAtMS4wNS0uNjNBNC4zMiA0LjMyIDAgMCAwIDIzLjMxIDIgMy4xNyAzLjE3IDAgMCAwIDIwIDUuMjdhMy4xNiAzLjE2IDAgMCAwIDEgMi4zOSAzLjA3IDMuMDcgMCAwIDAgMi4xNy44NCA0LjYgNC42IDAgMCAwIDIuMDktLjVWNi4xOWgtMi4yVjQuMzhoNC4yNXY0LjU2YTUuNDEgNS40MSAwIDAgMS00LjA4IDEuNTdBNS4zNSA1LjM1IDAgMCAxIDE5LjQzIDlhNS4wNSA1LjA1IDAgMCAxLTEuNTYtMy43NCA1LjIxIDUuMjEgMCAwIDEgMS41Ni0zLjc2QTUuMzEgNS4zMSAwIDAgMSAyMy4xOCAwem0xMS4yOS40Mmw0LjEzIDkuNzloLTIuMjVMMzUuNDggOGgtNC4wNmwtLjkgMi4xOGgtMi4yTDMyLjUxLjQyem0uMjUgNS43MkwzMy40NCAzbC0xLjI5IDMuMTR6bTMtNWEuNzEuNzEgMCAwIDEtLjc0Ljc1LjcxLjcxIDAgMCAxLS43My0uNzUuNzMuNzMgMCAwIDEgLjc1LS43Mi43Mi43MiAwIDAgMSAuNzUuNzF6TTM3IC41M2EuNTkuNTkgMCAwIDAtLjYuNi42MS42MSAwIDEgMCAxLjIxIDAgLjYuNiAwIDAgMC0uNjEtLjZ6bS0uMjQgMVYuNzFIMzdjLjEyIDAgLjE4LjA2LjI1LjA2YS4yMS4yMSAwIDAgMSAuMDcuMTguMTkuMTkgMCAwIDEtLjA3LjE4cy0uMDcuMDgtLjEzLjA4bC4yNi4zNmgtLjJMMzcgMS4yOGgtLjF2LjI5em0uMTMtLjQ0aC4yM2EuMjYuMjYgMCAwIDAgLjA3LS4wOWgtLjA2Yy0uMDUtLjE3LS4wNS0uMTctLjEzLS4xN2gtLjF6Ii8+PC9zdmc+"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"name": "datasource",
|
|
34
|
+
"label": "Data source for details",
|
|
35
|
+
"defaultValue": "@DATASOURCE D_pyAnnouncements.pxResults",
|
|
36
|
+
"format": "DATASOURCE",
|
|
37
|
+
"required": true,
|
|
38
|
+
"properties": [
|
|
39
|
+
{
|
|
40
|
+
"name": "name",
|
|
41
|
+
"label": "Label",
|
|
42
|
+
"defaultValue": "@P .pyLabel"
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"label": "Conditions",
|
|
48
|
+
"format": "GROUP",
|
|
49
|
+
"properties": [
|
|
50
|
+
{
|
|
51
|
+
"name": "visibility",
|
|
52
|
+
"label": "Visibility",
|
|
53
|
+
"format": "VISIBILITY"
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
],
|
|
58
|
+
"defaultConfig": {}
|
|
59
|
+
}
|