@pega/dx-component-builder-sdk 0.1.23 → 0.1.25

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.
@@ -0,0 +1,34 @@
1
+ const operatorDetails = {
2
+ data: {
3
+ "pzLoadTime": "March 13, 2023 10:58:15 AM EDT",
4
+ "pzPageNameHash": "_pa134221491644431pz",
5
+ "pyOperatorInfo": {
6
+ "pyUserName": "User DigV2",
7
+ "pyPosition": "",
8
+ "pyImageInsKey": "",
9
+ "pySkills": [
10
+ {
11
+ "pySkillName": "",
12
+ "pzIndexOwnerKey": "DATA-ADMIN-OPERATOR-ID USER.DIGV2",
13
+ "pySkillRating": 0
14
+ }
15
+ ],
16
+ "pyReportToUserName": "",
17
+ "pyReportTo": "",
18
+ "pyOrganization": "DXIL",
19
+ "pyTitle": "",
20
+ "pyLabel": "User.DigV2",
21
+ "pyEmailAddress": "User@DigV2",
22
+ "pyTelephone": ""
23
+ }
24
+ },
25
+ status: 200,
26
+ statusText: '',
27
+ headers: {
28
+ 'content-length': '435',
29
+ 'content-type': 'application/json;charset=UTF-8'
30
+ },
31
+ request: {}
32
+ };
33
+
34
+ export default operatorDetails;
@@ -0,0 +1,200 @@
1
+ import { useState } from 'react';
2
+
3
+ import { withKnobs } from '@storybook/addon-knobs';
4
+
5
+ import {{COMPONENT_CLASS_NAME}} from './index.tsx';
6
+
7
+ export default {
8
+ title: '{{COMPONENT_CLASS_NAME}}',
9
+ decorators: [withKnobs],
10
+ component: {{COMPONENT_CLASS_NAME}}
11
+ };
12
+
13
+ if (!window.PCore) {
14
+ window.PCore = {};
15
+ }
16
+
17
+ window.PCore = {
18
+ getErrorHandler() {
19
+ return {
20
+ getGenericFailedMessage() {
21
+ /* nothing */
22
+ }
23
+ };
24
+ }
25
+ };
26
+
27
+ export const Base{{COMPONENT_CLASS_NAME}} = () => {
28
+
29
+ const [firstName, setFirstName] = useState('John');
30
+ const [middleName, setMiddleName] = useState('');
31
+ const [lastName, setLastName] = useState('Joe');
32
+ const [phone, setPhone] = useState('+16397975093');
33
+ const [suffix, setSuffix] = useState('');
34
+ const [email, setEmail] = useState('john@doe.com');
35
+
36
+ const props = {
37
+ NumCols: "1",
38
+ template: 'DefaultForm',
39
+
40
+ getPConnect: () => {
41
+ return {
42
+ getChildren: () => {
43
+ return [
44
+ {
45
+ getPConnect: () => {
46
+ return {
47
+ getChildren: () => {
48
+ return [
49
+ {
50
+ readOnly: undefined,
51
+ placeholder: 'First Name',
52
+ value: firstName,
53
+ label: 'First Name',
54
+ hasSuggestions: false,
55
+ onChange: val => {
56
+ setFirstName(val.target.value);
57
+ }
58
+ },
59
+ {
60
+ readOnly: undefined,
61
+ placeholder: 'Middle Name',
62
+ value: middleName,
63
+ label: 'Middle Name',
64
+ hasSuggestions: false,
65
+ onChange: val => {
66
+ setMiddleName(val.target.value);
67
+ }
68
+ },
69
+
70
+ {
71
+ value: lastName,
72
+ label: 'Last Name',
73
+ required: true,
74
+ placeholder: 'Last Name',
75
+ testId: '77587239BF4C54EA493C7033E1DBF636',
76
+ hasSuggestions: false,
77
+ onChange: val => {
78
+ setLastName(val.target.value);
79
+ }
80
+ },
81
+
82
+ {
83
+ readOnly: undefined,
84
+ value: phone,
85
+ label: 'Phone Number',
86
+ datasource: {
87
+ fields: {
88
+ value: undefined
89
+ },
90
+ source: [
91
+ {
92
+ value: '+1'
93
+ },
94
+ {
95
+ value: '+91'
96
+ },
97
+ {
98
+ value: '+48'
99
+ },
100
+ {
101
+ value: '+44'
102
+ }
103
+ ]
104
+ },
105
+ hasSuggestions: false,
106
+ onChange: val => {
107
+ setPhone(val.value);
108
+ },
109
+ onBlur: () => {
110
+ /* nothing */
111
+ }
112
+ },
113
+
114
+ {
115
+ value: suffix,
116
+ label: 'Suffix',
117
+ placeholder: 'Select...',
118
+ listType: 'associated',
119
+ datasource: [
120
+ {
121
+ key: 'Sr',
122
+ value: 'Sr'
123
+ },
124
+ {
125
+ key: 'Jr',
126
+ value: 'Jr'
127
+ },
128
+ {
129
+ key: 'III',
130
+ value: 'III'
131
+ },
132
+ {
133
+ key: 'IV',
134
+ value: 'IV'
135
+ },
136
+ {
137
+ key: 'V',
138
+ value: 'V'
139
+ }
140
+ ],
141
+ testId: '56E6DDD1CB6CEC596B433440DFB21C17',
142
+ hasSuggestions: false,
143
+ deferDatasource: false,
144
+ getPConnect: () => {
145
+ return {
146
+ getContextName: () => {
147
+ return null;
148
+ },
149
+ getDataObject: () => {
150
+ return null;
151
+ },
152
+ getActionsApi: () => {
153
+ return {
154
+ updateFieldValue: (propName, value) => {
155
+ setSuffix(value);
156
+ },
157
+ triggerFieldChange: () => {
158
+ /* nothing */
159
+ }
160
+ };
161
+ },
162
+ getStateProps: () => {
163
+ return {
164
+ value: ''
165
+ };
166
+ }
167
+ };
168
+ },
169
+ onChange: val => {
170
+ setSuffix(val.target.value);
171
+ }
172
+ },
173
+
174
+ {
175
+ value: email,
176
+ label: 'Email',
177
+ required: true,
178
+ testId: 'CE8AE9DA5B7CD6C3DF2929543A9AF92D',
179
+ hasSuggestions: false,
180
+ onChange: val => {
181
+ setEmail(val.target.value);
182
+ }
183
+ }
184
+ ];
185
+ }
186
+ };
187
+ }
188
+ }
189
+ ];
190
+ }
191
+ };
192
+ }
193
+ };
194
+
195
+ return (
196
+ <>
197
+ <{{COMPONENT_CLASS_NAME}} {...props}></{{COMPONENT_CLASS_NAME}}>
198
+ </>
199
+ );
200
+ };
@@ -0,0 +1,183 @@
1
+ import { useState } from 'react';
2
+ import {{COMPONENT_CLASS_NAME}} from './index.tsx';
3
+ import { pyReviewRaw } from './mock.stories';
4
+ import { TextField } from '@material-ui/core';
5
+ import MuiPhoneNumber from 'material-ui-phone-number';
6
+ import { KeyboardDatePicker, MuiPickersUtilsProvider } from '@material-ui/pickers';
7
+ import DayjsUtils from '@date-io/dayjs';
8
+
9
+ export default {
10
+ title: '{{COMPONENT_CLASS_NAME}}',
11
+ component: {{COMPONENT_CLASS_NAME}}
12
+ };
13
+
14
+ const renderField = resolvedProps => {
15
+ const { displayMode, value = '', label = '', onChange} = resolvedProps;
16
+
17
+ const variant = displayMode === 'LABELS_LEFT' ? 'inline' : 'stacked';
18
+ let val = '';
19
+ if (label === 'Service Date')
20
+ val = <MuiPickersUtilsProvider utils={DayjsUtils}><KeyboardDatePicker
21
+ variant='inline'
22
+ inputVariant='outlined'
23
+ placeholder='mm/dd/yyyy'
24
+ fullWidth
25
+ format='MM/DD/YYYY'
26
+ mask='__/__/____'
27
+ size='small'
28
+ label={label}
29
+ value={value || null}
30
+ onChange={onChange}
31
+ />
32
+ </MuiPickersUtilsProvider>
33
+
34
+ {{! pick new delimiteres for mustache }}
35
+ {{=<% %>=}}
36
+
37
+ if (label === 'Email')
38
+ val = <TextField type='email' value={value} size='small' variant='outlined' style={{ fontSize: '14px' }} label={label} onChange={onChange}></TextField>;
39
+
40
+ if (label === 'First Name' || label === 'Last Name' || label === 'Middle Name')
41
+ val = <TextField value={value} size='small' variant='outlined' style={{ fontSize: '14px' }} label={label} onChange={onChange}></TextField>;
42
+
43
+ if (label === 'Phone Number')
44
+ val = <MuiPhoneNumber value={value} variant='outlined' size='small' style={{ fontSize: '14px' }} defaultCountry='us' label={label} onChange={onChange}></MuiPhoneNumber>;
45
+
46
+ <%={{ }}=%> {{! revert delimiteres for mustache }}
47
+
48
+ if (variant === 'inline') {
49
+ val = value || <span aria-hidden='true'>&ndash;&ndash;</span>;
50
+ }
51
+
52
+ return val;
53
+ };
54
+
55
+ export const Base{{COMPONENT_CLASS_NAME}} = () => {
56
+ const [firstName, setFirstName] = useState('John');
57
+ const [middleName, setMiddleName] = useState('');
58
+ const [lastName, setLastName] = useState('Joe');
59
+ const [phone, setPhone] = useState('+16397975093');
60
+ const [serviceDate, setServiceDate] = useState('2023-01-25');
61
+ const [email, setEmail] = useState('john@doe.com');
62
+ const regionChildrenResolved = [
63
+ {
64
+ readOnly: undefined,
65
+ value: firstName,
66
+ label: 'First Name',
67
+ hasSuggestions: false,
68
+ onChange: val => {
69
+ setFirstName(val.target.value);
70
+ }
71
+ },
72
+ {
73
+ readOnly: undefined,
74
+ value: middleName,
75
+ label: 'Middle Name',
76
+ hasSuggestions: false,
77
+ onChange: val => {
78
+ setMiddleName(val.target.value);
79
+ }
80
+ },
81
+ {
82
+ readOnly: undefined,
83
+ value: lastName,
84
+ label: 'Last Name',
85
+ hasSuggestions: false,
86
+ onChange: val => {
87
+ setLastName(val.target.value);
88
+ }
89
+ },
90
+ {
91
+ readOnly: undefined,
92
+ value: email,
93
+ label: 'Email',
94
+ hasSuggestions: false,
95
+ onChange: val => {
96
+ setEmail(val.target.value);
97
+ }
98
+ },
99
+ {
100
+ readOnly: undefined,
101
+ value: phone,
102
+ label: 'Phone Number',
103
+ datasource: {
104
+ fields: {
105
+ value: undefined
106
+ },
107
+ source: [
108
+ {
109
+ value: '+1'
110
+ },
111
+ {
112
+ value: '+91'
113
+ },
114
+ {
115
+ value: '+48'
116
+ },
117
+ {
118
+ value: '+44'
119
+ }
120
+ ]
121
+ },
122
+ hasSuggestions: false,
123
+ onChange: val => {
124
+ setPhone(val);
125
+ }
126
+ },
127
+ {
128
+ readOnly: undefined,
129
+ value: serviceDate,
130
+ label: 'Service Date',
131
+ hasSuggestions: false,
132
+ onChange: date => {
133
+ const changeValue = date && date.isValid() ? date.toISOString() : null;
134
+ setServiceDate(changeValue);
135
+ }
136
+
137
+ }
138
+ ];
139
+ const props = {
140
+ template: 'DefaultForm',
141
+ getPConnect: () => {
142
+ return {
143
+ getChildren: () => {
144
+ return pyReviewRaw.children;
145
+ },
146
+ createComponent: config => {
147
+ switch (config.config.value) {
148
+ case '@P .FirstName':
149
+ return renderField(regionChildrenResolved[0]);
150
+ case '@P .MiddleName':
151
+ return renderField(regionChildrenResolved[1]);
152
+ case '@P .LastName':
153
+ return renderField(regionChildrenResolved[2]);
154
+ case '@P .Email':
155
+ return renderField(regionChildrenResolved[3]);
156
+ case '@P .PhoneNumber':
157
+ return renderField(regionChildrenResolved[4]);
158
+ case '@P .ServiceDate':
159
+ return renderField(regionChildrenResolved[5]);
160
+ default:
161
+ break;
162
+ }
163
+ }
164
+ };
165
+ }
166
+ };
167
+
168
+ const regionAChildren = pyReviewRaw.children[0].children.map(child => {
169
+ return props.getPConnect().createComponent(child);
170
+ });
171
+ const regionBChildren = pyReviewRaw.children[1].children.map(child => {
172
+ return props.getPConnect().createComponent(child);
173
+ });
174
+
175
+ return (
176
+ <>
177
+ <{{COMPONENT_CLASS_NAME}} {...props}>
178
+ {regionAChildren}
179
+ {regionBChildren}
180
+ </{{COMPONENT_CLASS_NAME}}>
181
+ </>
182
+ );
183
+ };
@@ -0,0 +1,132 @@
1
+ export const pyReviewRaw = {
2
+ name: 'CollectInformation',
3
+ type: 'View',
4
+ config: {
5
+ template: 'DefaultForm',
6
+ ruleClass: 'OM5W9U-SampleApp-Work-Test',
7
+ localeReference: '@LR OM5W9U-SAMPLEAPP-WORK-TEST!VIEW!COLLECTINFORMATION',
8
+ context: '@P .pyViewContext'
9
+ },
10
+ children: [
11
+ {
12
+ name: 'A',
13
+ type: 'Region',
14
+ children: [
15
+ {
16
+ type: 'TextInput',
17
+ config: {
18
+ value: '@P .FirstName',
19
+ label: '@L First Name'
20
+ }
21
+ },
22
+ {
23
+ type: 'TextInput',
24
+ config: {
25
+ value: '@P .MiddleName',
26
+ label: '@L Middle Name'
27
+ }
28
+ },
29
+ {
30
+ type: 'TextInput',
31
+ config: {
32
+ value: '@P .LastName',
33
+ label: '@L Last Name'
34
+ }
35
+ }
36
+ ]
37
+ },
38
+ {
39
+ name: 'B',
40
+ type: 'Region',
41
+ children: [
42
+ {
43
+ type: 'Email',
44
+ config: {
45
+ value: '@P .Email',
46
+ label: '@L Email'
47
+ }
48
+ },
49
+ {
50
+ type: 'Phone',
51
+ config: {
52
+ value: '@P .PhoneNumber',
53
+ label: '@L Phone Number',
54
+ datasource: {
55
+ source: '@DATASOURCE D_pyCountryCallingCodeList.pxResults',
56
+ fields: {
57
+ value: '@P .pyCallingCode'
58
+ }
59
+ }
60
+ }
61
+ },
62
+ {
63
+ type: 'Date',
64
+ config: {
65
+ value: '@P .ServiceDate',
66
+ label: '@L Service Date'
67
+ }
68
+ }
69
+ ]
70
+ }
71
+ ],
72
+ classID: 'OM5W9U-SampleApp-Work-Test'
73
+ };
74
+
75
+ export const regionChildrenResolved = [
76
+ {
77
+ readOnly: undefined,
78
+ value: 'John',
79
+ label: 'First Name',
80
+ hasSuggestions: false
81
+ },
82
+ {
83
+ readOnly: undefined,
84
+ value: 'Din',
85
+ label: 'Middle Name',
86
+ hasSuggestions: false
87
+ },
88
+ {
89
+ readOnly: undefined,
90
+ value: 'Doe',
91
+ label: 'Last Name',
92
+ hasSuggestions: false
93
+ },
94
+ {
95
+ readOnly: undefined,
96
+ value: 'John@doe.com',
97
+ label: 'Email',
98
+ hasSuggestions: false
99
+ },
100
+ {
101
+ readOnly: undefined,
102
+ value: '+16397975093',
103
+ label: 'Phone Number',
104
+ datasource: {
105
+ fields: {
106
+ value: undefined
107
+ },
108
+ source: [
109
+ {
110
+ value: '+1'
111
+ },
112
+ {
113
+ value: '+91'
114
+ },
115
+ {
116
+ value: '+48'
117
+ },
118
+ {
119
+ value: '+44'
120
+ }
121
+ ]
122
+ },
123
+ hasSuggestions: false
124
+ },
125
+ {
126
+ readOnly: undefined,
127
+ value: '2023-01-25',
128
+ label: 'Service Date',
129
+ hasSuggestions: false
130
+ }
131
+ ];
132
+
@@ -1,5 +1,6 @@
1
1
  export { default as createComponent } from './create/index.js';
2
2
  export { default as overrideComponent } from './override/index.js';
3
+ export { default as overrideAllComponents } from './override-all/index.js';
3
4
  export { default as deleteComponent } from './delete/index.js';
4
5
  export { default as deleteAllComponents } from './delete-all/index.js';
5
6
  export { default as mapAllComponents } from './map-all/index.js';
@@ -57,7 +57,7 @@ const checkAndCreateConfigComponentKey = async (targetDirectory) => {
57
57
  }
58
58
 
59
59
 
60
- // stringify "4", makes the json string look like JSON in the file
60
+ // stringify "4", makes the json string look like JSON in the file, formated instead of a single line
61
61
  const configContent = JSON.stringify(configObj, null, 4);
62
62
 
63
63
  // update file
@@ -67,7 +67,9 @@ const checkAndCreateConfigComponentKey = async (targetDirectory) => {
67
67
  }
68
68
  catch (err) {
69
69
  // no config-ext.json file, so no update, which is ok
70
- console.log(chalk.yellow("Component has no config file for extension."));
70
+ const arPaths = targetDirectory.split("/");
71
+ const compName = arPaths[arPaths.length-1] ;
72
+ console.log(chalk.yellow(`Component ${compName} has no config file for extension.`));
71
73
  }
72
74
  }
73
75