@pega/custom-dx-components 8.8.9 → 8.8.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/custom-dx-components",
3
- "version": "8.8.9",
3
+ "version": "8.8.10",
4
4
  "description": "Utility for building custom UI components",
5
5
  "bin": "./bin/index.js",
6
6
  "scripts": {
@@ -14,7 +14,6 @@ import handleEvent from "./event-utils";
14
14
  import { suggestionsHandler } from './suggestions-handler';
15
15
 
16
16
  import Styled{{COMPONENT_CLASS_NAME}}Wrapper from './styles';
17
- import { } from "@pega/cosmos-react-core";
18
17
 
19
18
  export const formatExists = (formatterVal) => {
20
19
  const formatterValues = [
@@ -16,208 +16,6 @@ Ensure you have access to the following in your system:
16
16
 
17
17
  - System npm version 8
18
18
 
19
- ## Initialize a project
19
+ ## Latest Documentation
20
20
 
21
- Initialize the project by performing the following procedure in a terminal:
22
-
23
- 1. Enter the following command to initialize the project.
24
-
25
- Pega 8.7 - `npx @pega/custom-dx-components@1 init`
26
-
27
- Pega 8.8 - `npx @pega/custom-dx-components@2 init`
28
-
29
- 2. If prompted, enter `y` to install the Custom UI Components package.
30
- You will then be asked to set up the project by entering the required details.
31
-
32
- 3. Enter the following details:
33
- - Name of the project (required)
34
- Example - `mycustomcomponents`
35
- - Name of the organization (required)
36
- Example - `customorg`
37
- - Version (required)
38
- Example - `1.0.0`
39
- - Description of the project (optional)
40
- Example - `This project is intended to create and publish a custom component.`
41
- - Git repository URL (optional)
42
- Example - `https://git.custom-components.io/custom-cc.git`
43
- - Author (optional)
44
- Example - `Michelle`
45
-
46
- The workspace is now set up to create custom components and publish them to the server.
47
-
48
- ## Create custom components
49
-
50
- Create custom components using the following procedure:
51
-
52
- 1. Enter the following command to create a component:
53
- `npm run create`
54
- You will then be asked to enter or review the following details of the component:
55
- - Name of the component (required)
56
- Example - `customcomp0`
57
- - Name of component label (required)
58
- Example - `custom component`
59
- - Name of the library (required)
60
- Example - `basic`
61
- - Component version (required)
62
- Example - `0.0.1`
63
- - Type of component (required)
64
- Example - `Field`
65
- - Sub-type of component (required)
66
- Example - `Text`
67
- - Description of the component (optional)
68
- Example - `This is a customized searchbox that filters data.`
69
- The component is created in the following path: _/Users/your_user_name/project_name/src/components/component_name_
70
- You can also pre-configure the values for the above options in a tasks.config.json file as shown below.
71
-
72
- ```json
73
- {
74
- "component": {
75
- "library": "basic",
76
- "version": "0.0.1",
77
- "type": "field",
78
- "subtype": "text",
79
- "description": "basic field for capturing textual data",
80
- "icon": "basic-field-text.svg"
81
- }
82
- }
83
- ```
84
- >**Note**:
85
- Alternatively, you can enter the following command to skip entering the details of the component now and can manually enter the details in the config.json file after the component is created:
86
- `npm run create <enter_component_name>`
87
-
88
- A _src/components_ folder is created and the necessary files required to build the component are initialized as seen below.
89
-
90
- ```sh
91
- ├── src
92
- ├── components
93
- ├── <component_name>
94
- ├── index.js
95
- ├── demo.stories.js
96
- ├── config.json
97
- ```
98
-
99
-
100
- The *index.js* file contains the actual component rendering logic.
101
- The *demo.stories.js* file contains the demo that can be viewed in the storybook.
102
- The *config.json* file contains the mapping of properties for configuring the auto generated property panel. This property panel appears in AppStudio when an application is being authored to use the custom component.
103
-
104
-
105
- 2. Enter the following command to start the storybook to view the demo.
106
- `npm start`
107
-
108
- 3. Modify the source files to build your own component. You can also install and import third-party libraries if required for your component.
109
-
110
- The custom component is now created. We use the information provided to create uniquely namespaced components in this convention - `<organization>_<library>_<component name>`.
111
-
112
- 4. local build, you can build the component locally to check for config validation and component validation. Enter
113
- `npm buildComponent`
114
-
115
- buildComponent will do the same first 2 steps as publish, but will not publish to the server. This allows you to compile your component locally and fix errors before publish.
116
-
117
- ## Authenticate the user
118
-
119
- Before we publish the custom component to the Pega Infinity Server, authenticate the user to access the resources in the Pega Infinity Server.
120
-
121
- >**Note**:
122
- It is required that you configure a value for clientId, clientSecret, and accessTokenUri.
123
- 1. Login to Pega Infinity Server, navigate to Records / Security / OAuth 2.0 Client Registration landing page and open the *DX-CustomComponents* record.
124
- 2. Click **Regenerate Client Secret**, download the Client Credentials (as the Client ID, Client Secret, and Access token endpoint will be needed), and save the record.
125
- 3. Update the the task.config.json file with these downloaded values:
126
- ```json
127
- "server-config": {
128
- "server": "https://127.0.0.1:8080/prweb",
129
- "user": "customcomponentoperator",
130
- "password": "pwd",
131
- "clientId": "<mention client ID here>",
132
- "clientSecret": "<mention client secret here>",
133
- "accessTokenUri": "https://127.0.0.1:8080/prweb/PRRestService/oauth2/v1/token"
134
- },
135
- ```
136
- 4. Enter the following command to initiate authentication.
137
- `npm run authenticate`
138
-
139
- The user is now authenticated and can proceed to either publish or list the components.
140
-
141
- ## Publish custom components
142
- Enter the following command to publish custom components to Pega Infinity Server:
143
- `npm run publish`
144
- `npm run publishAll`
145
- Publish the finalized custom components changes to Pega Infinity Server so that it can be discoverable in authoring (design palette).
146
- You will then be asked to enter the following details:
147
-
148
- - The component to be published to Pega Infinity Server. It will be updated if the component exists.
149
- - If publishAll, then you won't get a list
150
- - The name of the ruleset where the component must be published.
151
- - The version of the ruleset where the component must be published.
152
- - Specify if the development build should be generated for debugging.
153
-
154
- - If publishAll, will sequentiall go through the list of local components and publish them
155
- You can also pre-configure the values for the above options in a tasks.config.json file as shown below. The server, user name, and password must be pre-configured.
156
-
157
- ```json
158
- {
159
- "components-server-config": {
160
- "server": "http://127.0.0.1:8080/prweb",
161
- "user": "customcomponentoperator",
162
- "password": "pwd"
163
- "rulesetName": "TestPega-C11nGall",
164
- "rulesetVersion": "01-01-03",
165
- "sourceOfComponents": "Server",
166
- "devBuild": false,
167
- }
168
- }
169
- ```
170
- When the component is successfully published, you can use the newly published component in App Studio's view authoring.
171
-
172
- > **Note**:
173
- > The Rule-UI-Component instance (with component name) is created on the Pega Infinity Server after publishing the component.
174
-
175
- ## List custom components
176
-
177
- View the available components in the local machine or the server.
178
-
179
- Enter the following command to list custom components:
180
- `npm run list`
181
-
182
- You will then be asked to enter the following details:
183
-
184
- - List components from Server or Local?
185
- Example - `Server`
186
-
187
- The custom components will now be listed in the terminal.
188
-
189
- ## Delete custom components
190
-
191
- Delete the available or published components in the local machine or the server.
192
-
193
- Enter the following command to delete custom components:
194
- `npm run delete`
195
- `npm run deleteAll`
196
-
197
- You will then be asked to enter the following details:
198
-
199
- - Delete components from Server or Local?
200
- Example - `Local`
201
-
202
- - Select component to delete
203
- The list of available components in the following path will be displayed: \_/Users/your_user_name/project_name/src/components
204
- Select the component to be deleted from this list.
205
- - For deleteAll you will see the full list and asked if you want to delete them all.
206
-
207
- - Are you sure?
208
- Example - `yes`
209
-
210
- > **Note**:
211
- > If you choose to delete components from the server, the successfully published components along with their ruleset name and ruleset version from the Pega Infinity Server will be displayed. Select the component to be deleted from this list.
212
-
213
- ## View existing custom components in storybook
214
-
215
- View custom components in a storybook by performing the following procedure:
216
-
217
- 1. Enter the following command to open the project.
218
- `cd <enter your project's name>`
219
-
220
- 2. Enter the following command to start the storybook in development mode.
221
- `npm start`
222
-
223
- The storybook is launched in a browser where you can view the components working in isolation.
21
+ Find the latest documentation on using **DX Component Builder** [here](https://docs.pega.com/bundle/constellation-dx-components-88/page/constellation-dx-components/custom-components/lifecycle-dx-cosmos-components.html)
@@ -56,7 +56,7 @@
56
56
  },
57
57
  "devDependencies": {
58
58
  "@pega/configs": "^0.5.3",
59
- "@pega/custom-dx-components": "^8.8.9",
59
+ "@pega/custom-dx-components": "^8.8.10",
60
60
  "@pega/eslint-config": "^0.3.2",
61
61
  "@storybook/addon-actions": "^6.5.12",
62
62
  "@storybook/addon-essentials": "^6.5.12",
@@ -0,0 +1 @@
1
+ # directory for components #
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "components-directory-path": "src/components",
3
3
  "server-config": {
4
- "rulesetName": "rulesetName",
5
- "rulesetVersion": "rulesetVersion",
4
+ "rulesetName": "CustomDXComponents",
5
+ "rulesetVersion": "01-01-01",
6
6
  "sourceOfComponents": "Server",
7
7
  "devBuild": false,
8
8
  "serverType": "infinity",
9
- "server": "https://localhost:38764/prweb",
9
+ "server": "https://localhost:1080/prweb",
10
10
  "clientId": "10095186356008396159",
11
11
  "clientSecret_comment": "Needed only when using 'passwordCreds' or 'clientCreds' grantType",
12
12
  "clientSecret": "",
@@ -24,9 +24,9 @@
24
24
  "questions_askNever": ""
25
25
  },
26
26
  "component": {
27
- "library": "",
27
+ "library": "Extensions",
28
28
  "type": "",
29
- "version": "",
29
+ "version": "1.0.0",
30
30
  "subtype": "",
31
31
  "description": "",
32
32
  "icon": ""
@@ -1,19 +0,0 @@
1
- import type { Meta, Story } from '@storybook/react';
2
-
3
- import MediaURLInput from './MediaURLInput';
4
- import MediaURLDisplay from './MediaURLDisplay';
5
-
6
- export default {
7
- title: 'MediaURL',
8
- parameters: {
9
- layout: 'centered'
10
- }
11
- } as Meta;
12
-
13
- export const InputMode: Story = () => {
14
- return <MediaURLInput label='Media src url' />;
15
- };
16
-
17
- export const DisplayMode: Story = () => {
18
- return <MediaURLDisplay value='https://youtu.be/BxogmCLpy0w' />;
19
- };
@@ -1,5 +0,0 @@
1
- import styled, { css } from 'styled-components';
2
-
3
- export default styled.div(() => {
4
- return css``;
5
- });
@@ -1,10 +0,0 @@
1
- import type { FormControlProps, OmitStrict, URLDisplayProps } from '@pega/cosmos-react-core';
2
-
3
- export interface MediaURLInputProps extends OmitStrict<FormControlProps, 'defaultValue'> {
4
- testId?: string;
5
- }
6
-
7
- export interface MediaURLDisplayProps extends OmitStrict<URLDisplayProps, 'variant' | 'ref'> {
8
- variant?: 'player' | URLDisplayProps['variant'];
9
- testId?: string;
10
- }
@@ -1,25 +0,0 @@
1
- import type { FunctionComponent } from 'react';
2
- import { URLDisplay } from '@pega/cosmos-react-core';
3
- import ReactPlayer from 'react-player';
4
-
5
- import StyledMediaURLDisplay from './MediaURL.styles';
6
- import type { MediaURLDisplayProps } from './MediaURL.types';
7
-
8
- const MediaURLDisplay: FunctionComponent<MediaURLDisplayProps> = ({
9
- value,
10
- variant = 'player',
11
- testId,
12
- ...restProps
13
- }) => {
14
- if ((!value && variant !== 'player') || variant !== 'player') {
15
- return <URLDisplay value={value} variant={variant} {...restProps} />;
16
- }
17
-
18
- return (
19
- <StyledMediaURLDisplay data-testid={testId}>
20
- <ReactPlayer url={value} />
21
- </StyledMediaURLDisplay>
22
- );
23
- };
24
-
25
- export default MediaURLDisplay;
@@ -1,24 +0,0 @@
1
- import { ChangeEvent, FunctionComponent, useState } from 'react';
2
- import { Input } from '@pega/cosmos-react-core';
3
-
4
- import type { MediaURLInputProps } from './MediaURL.types';
5
-
6
- const MediaURLInput: FunctionComponent<MediaURLInputProps> = ({
7
- value,
8
- ...restProps
9
- }: MediaURLInputProps) => {
10
- const [url, setURL] = useState(value);
11
-
12
- return (
13
- <Input
14
- {...restProps}
15
- type='url'
16
- value={url}
17
- onChange={(e: ChangeEvent<HTMLInputElement>) => {
18
- setURL(e.target.value);
19
- }}
20
- />
21
- );
22
- };
23
-
24
- export default MediaURLInput;
@@ -1,13 +0,0 @@
1
- {
2
- "name": "Organization_Library_MediaURL",
3
- "label": "MediaURL",
4
- "description": "A pair of components for taking input and displaying teh value of a video or audio url.",
5
- "organization": "TBD",
6
- "version": "0.0.1",
7
- "library": "TBD",
8
- "componentKey": "Organization_Library_MediaURL",
9
- "type": "Field",
10
- "subtype": "Text",
11
- "icon": "TBD",
12
- "properties": ["TBD"]
13
- }
@@ -1,2 +0,0 @@
1
- export { default as MediaURLInput } from './MediaURLInput';
2
- export { default as MediaURLDisplay } from './MediaURLDisplay';
@@ -1,44 +0,0 @@
1
- {
2
- "name": "Organization_Library_VideoPlayer",
3
- "label": "Video Player",
4
- "description": "video player",
5
- "organization": "apple",
6
- "version": "0.0.1",
7
- "library": "basic",
8
- "componentKey": "Organization_Library_VideoPlayer",
9
- "type": "Field",
10
- "subtype": "Text",
11
- "icon": "images/pz-text-input-active.svg",
12
- "properties": [
13
- {
14
- "name": "value",
15
- "label": "Property",
16
- "format": "PROPERTY"
17
- },
18
- {
19
- "name": "label",
20
- "label": "Label value",
21
- "format": "TEXT"
22
- },
23
- {
24
- "name": "placeholder",
25
- "label": "Placeholder",
26
- "format": "TEXT"
27
- },
28
- {
29
- "name": "visibility",
30
- "label": "Visible",
31
- "format": "VISIBILITY"
32
- },
33
- {
34
- "name": "disabled",
35
- "label": "Disabled",
36
- "format": "DISABLED"
37
- },
38
- {
39
- "name": "required",
40
- "label": "Required",
41
- "format": "REQUIRED"
42
- }
43
- ]
44
- }
@@ -1,40 +0,0 @@
1
- import React, { useState } from 'react';
2
- import { withKnobs, text, boolean } from '@storybook/addon-knobs';
3
-
4
- import VideoPlayer from './index';
5
-
6
- export default {
7
- title: 'VideoPlayer',
8
- decorators: [withKnobs],
9
- component: VideoPlayer
10
- };
11
-
12
- export const baseVideoPlayer = () => {
13
- const [value, setValue] = useState('test value');
14
-
15
- const props = {
16
- getPConnect: () => {
17
- return {
18
- getActionsApi: () => {
19
- return {
20
- updateFieldValue: (propName, value) => {
21
- setValue(value);
22
- }
23
- };
24
- },
25
- getStateProps: () => {
26
- return { value: '.name' };
27
- }
28
- };
29
- },
30
- value: text('src', 'https://www.youtube.com/watch?v=EtG5IuNGYSk'),
31
- placeholder: text('Placeholder', 'Test placeholder'),
32
- disabled: boolean('Disabled', false),
33
- readOnly: boolean('Disabled', false),
34
- required: boolean('Disabled', false),
35
- label: text('Label', 'Video player label'),
36
- testId: text('Test id', 'video-12344566')
37
- };
38
-
39
- return <VideoPlayer {...props} />;
40
- };
@@ -1,42 +0,0 @@
1
- import PropTypes from 'prop-types';
2
- import React from 'react';
3
- import { Label } from '@pega/cosmos-react-core';
4
- import ReactPlayer from 'react-player';
5
-
6
- import StyledVideoPlayerWrapper from './styles';
7
-
8
- const VideoPlayer = props => {
9
- const { getPConnect, value, placeholder, disabled, readOnly, required, label } = props;
10
-
11
- const pConn = getPConnect();
12
- const actions = pConn.getActionsApi();
13
- const propName = pConn?.getStateProps()?.value;
14
-
15
- return (
16
- <StyledVideoPlayerWrapper>
17
- <Label>{label}</Label>
18
- <ReactPlayer url={value} />
19
- </StyledVideoPlayerWrapper>
20
- );
21
- };
22
-
23
- VideoPlayer.defaultProps = {
24
- value: '',
25
- placeholder: '',
26
- disabled: false,
27
- readOnly: false,
28
- required: false,
29
- testId: null
30
- };
31
- VideoPlayer.propTypes = {
32
- label: PropTypes.string,
33
- value: PropTypes.string.isRequired,
34
- placeholder: PropTypes.string,
35
- getPConnect: PropTypes.func.isRequired,
36
- disabled: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
37
- readOnly: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
38
- required: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
39
- testId: PropTypes.string
40
- };
41
-
42
- export default VideoPlayer;
@@ -1,5 +0,0 @@
1
- import styled, { css } from 'styled-components';
2
-
3
- export default styled.div(() => {
4
- return css``;
5
- });