@pega/dx-component-builder-sdk 0.1.34 → 0.1.36
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/cli.js +6 -0
- package/src/tasks/authenticate/index.js +6 -3
- package/src/tasks/create/templates/Constellation/field/Boolean/styles.js.mustache +1 -1
- package/src/tasks/create/templates/Constellation/field/Date/styles.js.mustache +1 -1
- package/src/tasks/create/templates/Constellation/field/DateTime/styles.js.mustache +1 -1
- package/src/tasks/create/templates/Constellation/field/Decimal/styles.js.mustache +1 -1
- package/src/tasks/create/templates/Constellation/field/Decimal-Currency/styles.js.mustache +1 -1
- package/src/tasks/create/templates/Constellation/field/Decimal-Percentage/styles.js.mustache +1 -1
- package/src/tasks/create/templates/Constellation/field/Integer/styles.js.mustache +1 -1
- package/src/tasks/create/templates/Constellation/field/Picklist/styles.js.mustache +1 -1
- package/src/tasks/create/templates/Constellation/field/Text/styles.js.mustache +1 -1
- package/src/tasks/create/templates/Constellation/field/Text-Email/styles.js.mustache +1 -1
- package/src/tasks/create/templates/Constellation/field/Text-Input/styles.js.mustache +1 -1
- package/src/tasks/create/templates/Constellation/field/Text-Paragraph/styles.js.mustache +1 -1
- package/src/tasks/create/templates/Constellation/field/Text-Phone/styles.js.mustache +1 -1
- package/src/tasks/create/templates/Constellation/field/Text-URL/styles.js.mustache +1 -1
- package/src/tasks/create/templates/Constellation/field/TimeofDay/styles.js.mustache +1 -1
- package/src/tasks/create/templates/Constellation/template/DETAILS/styles.js.mustache +1 -1
- package/src/tasks/create/templates/Constellation/template/DETAILS-region/styles.js.mustache +1 -1
- package/src/tasks/create/templates/Constellation/template/FORM/styles.js.mustache +1 -1
- package/src/tasks/create/templates/Constellation/template/FORM-region/index.jsx.mustache +4 -1
- package/src/tasks/create/templates/Constellation/template/FORM-region/styles.js.mustache +1 -1
- package/src/tasks/create/templates/Constellation/template/PAGE/styles.js.mustache +1 -1
- package/src/tasks/index.js +1 -0
- package/src/tasks/map/map.js +20 -6
- package/src/tasks/rename/index.js +333 -0
- package/src/tasks/create/template/config.json.mustache +0 -62
- package/src/tasks/create/template/demo.stories.jsx.mustache +0 -44
- package/src/tasks/create/template/index.jsx.mustache +0 -55
- package/src/tasks/create/template/styles.js.mustache +0 -7
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
overrideAllComponents,
|
|
17
17
|
publishComponent,
|
|
18
18
|
publishAllComponents,
|
|
19
|
+
renameComponent,
|
|
19
20
|
updateComponent,
|
|
20
21
|
validate,
|
|
21
22
|
upgrade
|
|
@@ -31,6 +32,7 @@ const TASKS = {
|
|
|
31
32
|
MAP_ALL: "mapAll",
|
|
32
33
|
PUBLISH: 'publish',
|
|
33
34
|
PUBLISH_ALL: 'publishAll',
|
|
35
|
+
RENAME: 'rename',
|
|
34
36
|
LIST: 'list',
|
|
35
37
|
VALIDATE_SCHEMA: 'validateSchema',
|
|
36
38
|
UPDATE: 'update',
|
|
@@ -92,6 +94,10 @@ export default async (args = []) => {
|
|
|
92
94
|
publishAllComponents(options);
|
|
93
95
|
break;
|
|
94
96
|
}
|
|
97
|
+
case TASKS.RENAME: {
|
|
98
|
+
renameComponent(options);
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
95
101
|
case TASKS.BUILD: {
|
|
96
102
|
buildComponent(options);
|
|
97
103
|
break;
|
|
@@ -123,9 +123,12 @@ export default async options => {
|
|
|
123
123
|
let bWriteUpdate = false;
|
|
124
124
|
for (let i = 0; i < aProps.length; i += 1) {
|
|
125
125
|
const prop = aProps[i];
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
126
|
+
const configValue = serverConfig[prop];
|
|
127
|
+
const answerValue = answers[prop];
|
|
128
|
+
// Treat an empty serverConfig property value as same as an undefined answer response
|
|
129
|
+
if (configValue !== answerValue && !(configValue === '' && answerValue === undefined)) {
|
|
130
|
+
// console.log(`property ${prop} changed from ${configValue} to ${answerValue}`);
|
|
131
|
+
serverConfig[prop] = answerValue;
|
|
129
132
|
if (prop !== 'password' || isPwdNonEmpty) {
|
|
130
133
|
bWriteUpdate = true;
|
|
131
134
|
}
|
|
@@ -19,13 +19,16 @@ export default function {{COMPONENT_CLASS_NAME}}(props) {
|
|
|
19
19
|
gridContainer.cols = gridRepeat;
|
|
20
20
|
gridContainer.alignItems = 'start';
|
|
21
21
|
|
|
22
|
+
const flexContainer = {direction: 'column'};
|
|
23
|
+
flexContainer.gap = 2;
|
|
24
|
+
|
|
22
25
|
return (
|
|
23
26
|
<Styled{{COMPONENT_CLASS_NAME}}Wrapper>
|
|
24
27
|
{{! pick new delimiteres for mustache }}
|
|
25
28
|
{{=<% %>=}}
|
|
26
29
|
<Grid container={gridContainer}>
|
|
27
30
|
{children.map((child, i) => (
|
|
28
|
-
<Flex container={
|
|
31
|
+
<Flex container={flexContainer} key={`r-${i + 1}`}>
|
|
29
32
|
{child}
|
|
30
33
|
</Flex>
|
|
31
34
|
))}
|
package/src/tasks/index.js
CHANGED
|
@@ -7,6 +7,7 @@ export { default as deleteAllComponents } from './delete-all/index.js';
|
|
|
7
7
|
export { default as mapAllComponents } from './map-all/index.js';
|
|
8
8
|
export { default as publishComponent } from './publish/index.js';
|
|
9
9
|
export { default as publishAllComponents } from './publish-all/index.js';
|
|
10
|
+
export { default as renameComponent } from './rename/index.js';
|
|
10
11
|
export { default as listComponents } from './list/index.js';
|
|
11
12
|
export { default as updateComponent } from './update/index.js';
|
|
12
13
|
export { default as validate } from './validator/index.js';
|
package/src/tasks/map/map.js
CHANGED
|
@@ -33,9 +33,6 @@ export const updateComponentMap = async (componentKey, category = CATEGORY_CUSTO
|
|
|
33
33
|
|
|
34
34
|
let mapData = fs.readFileSync(pegaLocalComponentMapPath, { encoding: 'utf8' });
|
|
35
35
|
|
|
36
|
-
let data = fs.readFileSync(pegaConfigJsonPath, { encoding: 'utf8' });
|
|
37
|
-
data = JSON.parse(data);
|
|
38
|
-
|
|
39
36
|
let importComponent = join(COMPONENTS_DIRECTORY_PATH, categoryDirectory, componentKey);
|
|
40
37
|
importComponent = "./".concat(importComponent);
|
|
41
38
|
|
|
@@ -77,9 +74,6 @@ export const deleteFromComponentMap = async (componentKey, category = CATEGORY_C
|
|
|
77
74
|
|
|
78
75
|
let mapData = fs.readFileSync(pegaLocalComponentMapPath, { encoding: 'utf8' });
|
|
79
76
|
|
|
80
|
-
let data = fs.readFileSync(pegaConfigJsonPath, { encoding: 'utf8' });
|
|
81
|
-
data = JSON.parse(data);
|
|
82
|
-
|
|
83
77
|
let importComponent = join(COMPONENTS_DIRECTORY_PATH, categoryDirectory, componentKey);
|
|
84
78
|
importComponent = "./".concat(importComponent);
|
|
85
79
|
|
|
@@ -101,3 +95,23 @@ export const deleteFromComponentMap = async (componentKey, category = CATEGORY_C
|
|
|
101
95
|
|
|
102
96
|
|
|
103
97
|
};
|
|
98
|
+
|
|
99
|
+
export const renameComponentInMap = async (oldComponentKey, newComponentKey) => {
|
|
100
|
+
const pegaLocalComponentMapPath = path.join(path.resolve(), SDK_LOCAL_COMPONENT_MAP_FILENAME);
|
|
101
|
+
|
|
102
|
+
const oldComponentNameNoPrefix = removeComponentPrefix(oldComponentKey);
|
|
103
|
+
const oldComponentName = convertIntoPascalCase(oldComponentNameNoPrefix);
|
|
104
|
+
|
|
105
|
+
const newComponentNameNoPrefix = removeComponentPrefix(newComponentKey);
|
|
106
|
+
const newComponentName = convertIntoPascalCase(newComponentNameNoPrefix);
|
|
107
|
+
|
|
108
|
+
let mapData = fs.readFileSync(pegaLocalComponentMapPath, { encoding: 'utf8' });
|
|
109
|
+
|
|
110
|
+
if (mapData.indexOf(oldComponentName) >= 0) {
|
|
111
|
+
mapData = mapData.replaceAll(oldComponentName, newComponentName);
|
|
112
|
+
mapData = mapData.replaceAll(oldComponentNameNoPrefix, newComponentNameNoPrefix);
|
|
113
|
+
fs.writeFileSync(pegaLocalComponentMapPath, mapData, { encoding: 'utf8' });
|
|
114
|
+
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { URL, fileURLToPath } from 'url';
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
import { promisify } from 'util';
|
|
5
|
+
import { join } from 'path';
|
|
6
|
+
|
|
7
|
+
import inquirer from 'inquirer';
|
|
8
|
+
import ncp from 'ncp';
|
|
9
|
+
import chalk from 'chalk';
|
|
10
|
+
|
|
11
|
+
import { checkPathAccess, showVersion, getComponentsObj, getDirectoryFiles } from '../../util.js';
|
|
12
|
+
import { CATEGORY_CONSTELLATION,
|
|
13
|
+
CATEGORY_CUSTOM,
|
|
14
|
+
SDK_CONFIG_JSON_FILENAME,
|
|
15
|
+
DXCB_CONFIG,
|
|
16
|
+
DXCB_COMPONENT_DEFAULTS } from '../../constants.js';
|
|
17
|
+
|
|
18
|
+
import { renameComponentInMap } from '../map/map.js';
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
export const DXCB_CONFIG_INTERNAL_JSON_FILENAME = 'src/dxcb.config.json';
|
|
22
|
+
|
|
23
|
+
const pegaConfigJsonPath = path.join(path.resolve(), SDK_CONFIG_JSON_FILENAME);
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
import {
|
|
27
|
+
convertIntoPascalCase,
|
|
28
|
+
getComponentDirectoryPath,
|
|
29
|
+
getPegaConfig,
|
|
30
|
+
getComponentDefaults,
|
|
31
|
+
sanitize,
|
|
32
|
+
validateSemver
|
|
33
|
+
} from '../../util.js';
|
|
34
|
+
import { COMPONENT_SCHEMA } from '../../constants.js';
|
|
35
|
+
|
|
36
|
+
const copy = promisify(ncp);
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
export const updateConfig = async (
|
|
40
|
+
{
|
|
41
|
+
oldComponentKey,
|
|
42
|
+
newComponentKey,
|
|
43
|
+
library,
|
|
44
|
+
organization,
|
|
45
|
+
componentName,
|
|
46
|
+
componentLabel,
|
|
47
|
+
version,
|
|
48
|
+
description,
|
|
49
|
+
allowedApplications,
|
|
50
|
+
targetDirectory,
|
|
51
|
+
},
|
|
52
|
+
options,
|
|
53
|
+
onlyCompanion = false
|
|
54
|
+
) => {
|
|
55
|
+
|
|
56
|
+
let configData = fs.readFileSync(join(targetDirectory, "/config.json"), { encoding: 'utf8' });
|
|
57
|
+
configData = configData && JSON.parse(configData);
|
|
58
|
+
|
|
59
|
+
configData.name = newComponentKey;
|
|
60
|
+
configData.label = componentLabel;
|
|
61
|
+
configData.organization = organization;
|
|
62
|
+
if (configData.componentKey) configData.componentKey = newComponentKey;
|
|
63
|
+
configData.library = library;
|
|
64
|
+
configData.version = version;
|
|
65
|
+
configData.description = (description != '') ? description : componentLabel;
|
|
66
|
+
configData.allowedApplications = allowedApplications;
|
|
67
|
+
|
|
68
|
+
// stringify "4", makes the json string look like JSON in the file, formated instead of a single line
|
|
69
|
+
fs.writeFileSync(join(targetDirectory, "/config.json"), JSON.stringify(configData, null, 4), { encoding: 'utf8' });
|
|
70
|
+
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export const updateFile = async (
|
|
74
|
+
fileName,
|
|
75
|
+
oldComponentKeyPC,
|
|
76
|
+
newComponentKeyPC,
|
|
77
|
+
targetDirectory,
|
|
78
|
+
) => {
|
|
79
|
+
|
|
80
|
+
let fileData = fs.readFileSync(join(targetDirectory, "/", fileName), { encoding: 'utf8' });
|
|
81
|
+
|
|
82
|
+
if (fileData.indexOf(oldComponentKeyPC) >= 0) {
|
|
83
|
+
fileData = fileData.replaceAll(oldComponentKeyPC, newComponentKeyPC);
|
|
84
|
+
|
|
85
|
+
fs.writeFileSync(join(targetDirectory, "/", fileName), fileData, { encoding: 'utf8' });
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
export const renameComponent = async (
|
|
92
|
+
{
|
|
93
|
+
library,
|
|
94
|
+
organization,
|
|
95
|
+
componentKey,
|
|
96
|
+
componentName,
|
|
97
|
+
componentLabel,
|
|
98
|
+
version,
|
|
99
|
+
description,
|
|
100
|
+
allowedApplications
|
|
101
|
+
},
|
|
102
|
+
options,
|
|
103
|
+
onlyCompanion = false
|
|
104
|
+
) => {
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
let pegaConfig = await getPegaConfig();
|
|
108
|
+
|
|
109
|
+
const newComponentKey = `${organization}_${library}_${componentName}`;
|
|
110
|
+
const typeLC = componentKey.split("/")[0];
|
|
111
|
+
const oldComponentKey = componentKey.split("/")[1];
|
|
112
|
+
const newComponentKeyPC = convertIntoPascalCase(newComponentKey);
|
|
113
|
+
const oldComponentKeyPC = convertIntoPascalCase(oldComponentKey);
|
|
114
|
+
|
|
115
|
+
const currentDirectory = await getComponentDirectoryPath(componentKey);
|
|
116
|
+
const currentDirectoryConstellation = await getComponentDirectoryPath(componentKey, CATEGORY_CONSTELLATION);
|
|
117
|
+
|
|
118
|
+
const targetDirectory = await getComponentDirectoryPath(join(typeLC, "/",newComponentKey));
|
|
119
|
+
const targetDirectoryConstellation = await getComponentDirectoryPath(join(typeLC, "/",newComponentKey), CATEGORY_CONSTELLATION);
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
// custom component
|
|
124
|
+
try {
|
|
125
|
+
fs.renameSync(currentDirectory, targetDirectory);
|
|
126
|
+
} catch(err) {
|
|
127
|
+
console.log(err)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const targetFileList = await getDirectoryFiles(targetDirectory);
|
|
131
|
+
|
|
132
|
+
for (var fileIndex in targetFileList) {
|
|
133
|
+
const fileName = targetFileList[fileIndex];
|
|
134
|
+
|
|
135
|
+
if (fileName === "config.json") {
|
|
136
|
+
await updateConfig(
|
|
137
|
+
{
|
|
138
|
+
oldComponentKey,
|
|
139
|
+
newComponentKey,
|
|
140
|
+
componentName,
|
|
141
|
+
componentLabel,
|
|
142
|
+
library,
|
|
143
|
+
version,
|
|
144
|
+
description,
|
|
145
|
+
allowedApplications,
|
|
146
|
+
organization,
|
|
147
|
+
targetDirectory,
|
|
148
|
+
},
|
|
149
|
+
options
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
await updateFile(
|
|
154
|
+
fileName,
|
|
155
|
+
oldComponentKeyPC,
|
|
156
|
+
newComponentKeyPC,
|
|
157
|
+
targetDirectory );
|
|
158
|
+
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
} // for
|
|
162
|
+
|
|
163
|
+
// associated component
|
|
164
|
+
try {
|
|
165
|
+
fs.renameSync(currentDirectoryConstellation, targetDirectoryConstellation);
|
|
166
|
+
} catch(err) {
|
|
167
|
+
console.log(err)
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const targetConstellationFileList = await getDirectoryFiles(targetDirectoryConstellation);
|
|
171
|
+
|
|
172
|
+
for (var fileIndex in targetConstellationFileList) {
|
|
173
|
+
const fileName = targetConstellationFileList[fileIndex];
|
|
174
|
+
|
|
175
|
+
await updateFile(
|
|
176
|
+
fileName,
|
|
177
|
+
oldComponentKeyPC,
|
|
178
|
+
newComponentKeyPC,
|
|
179
|
+
targetDirectoryConstellation
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
} // for
|
|
183
|
+
|
|
184
|
+
// update map
|
|
185
|
+
renameComponentInMap(oldComponentKey, newComponentKey);
|
|
186
|
+
|
|
187
|
+
console.log(chalk.green(`Component ${oldComponentKey} renamed to ${newComponentKey}`));
|
|
188
|
+
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
export default async options => {
|
|
196
|
+
showVersion();
|
|
197
|
+
|
|
198
|
+
await checkPathAccess(pegaConfigJsonPath);
|
|
199
|
+
|
|
200
|
+
let data = fs.readFileSync(pegaConfigJsonPath, { encoding: 'utf8' });
|
|
201
|
+
data = data && JSON.parse(data);
|
|
202
|
+
|
|
203
|
+
if (!data[DXCB_CONFIG] || !data[DXCB_CONFIG][DXCB_COMPONENT_DEFAULTS]) {
|
|
204
|
+
console.error(
|
|
205
|
+
`${chalk.red.bold('ERROR')} Could not able find component defaults in config.json`
|
|
206
|
+
);
|
|
207
|
+
process.exit(1);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const componentData = data[DXCB_CONFIG][DXCB_COMPONENT_DEFAULTS];
|
|
211
|
+
|
|
212
|
+
const { organization, library} = componentData;
|
|
213
|
+
|
|
214
|
+
let componentDefaults = await getComponentDefaults();
|
|
215
|
+
componentDefaults.library = library;
|
|
216
|
+
|
|
217
|
+
const localComponents = await getComponentsObj(true, CATEGORY_CUSTOM);
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
const questions = [
|
|
221
|
+
{
|
|
222
|
+
name: 'componentKey',
|
|
223
|
+
type: 'rawlist',
|
|
224
|
+
pageSize: 15,
|
|
225
|
+
message: 'Select component to rename',
|
|
226
|
+
choices: localComponents
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
name: 'componentName',
|
|
230
|
+
message: 'Enter new component name (required, no spaces)',
|
|
231
|
+
validate: value => {
|
|
232
|
+
/* value should not be empty
|
|
233
|
+
It should not have spaces
|
|
234
|
+
It should not start with a number
|
|
235
|
+
Only case-insensitive alphanumeric values are allowed
|
|
236
|
+
*/
|
|
237
|
+
if (value && !/^\d/.test(value) && value === sanitize(value)) {
|
|
238
|
+
return true;
|
|
239
|
+
}
|
|
240
|
+
return 'Only alphanumeric values are allowed, starting with alphabets';
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
name: 'componentLabel',
|
|
245
|
+
message: 'Enter new component label for display (required)',
|
|
246
|
+
validate: value => {
|
|
247
|
+
if (value) {
|
|
248
|
+
return true;
|
|
249
|
+
}
|
|
250
|
+
return 'Please provide value for label';
|
|
251
|
+
}
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
name: 'organization',
|
|
255
|
+
message: 'Enter new component organization',
|
|
256
|
+
default: componentDefaults.organization,
|
|
257
|
+
validate: value => {
|
|
258
|
+
if (value) {
|
|
259
|
+
return true;
|
|
260
|
+
}
|
|
261
|
+
return 'Please provide value for organization';
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
name: 'version',
|
|
266
|
+
message: 'Enter new component version',
|
|
267
|
+
default: componentDefaults.version,
|
|
268
|
+
validate: value => {
|
|
269
|
+
if (validateSemver(value)) {
|
|
270
|
+
return true;
|
|
271
|
+
}
|
|
272
|
+
return 'Please provide semver compatible version e.g 0.0.1';
|
|
273
|
+
}
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
name: 'library',
|
|
277
|
+
message: 'Enter new library name (required)',
|
|
278
|
+
default: componentDefaults.library,
|
|
279
|
+
validate: value => {
|
|
280
|
+
/* value should not be empty
|
|
281
|
+
It should not have spaces
|
|
282
|
+
It should not start with a number
|
|
283
|
+
Only case-insensitive alphanumeric values are allowed
|
|
284
|
+
*/
|
|
285
|
+
if (value && !/^\d/.test(value) && value === sanitize(value)) {
|
|
286
|
+
return true;
|
|
287
|
+
}
|
|
288
|
+
return 'Only alphanumeric values are allowed, starting with alphabets';
|
|
289
|
+
}
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
name: 'allowedApplications',
|
|
293
|
+
message: 'Please enter the application names to be supported (comma-separated). ',
|
|
294
|
+
suffix: 'Keep empty for all applications'
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
name: 'description',
|
|
298
|
+
message: 'Enter new description for the component (defaults to new label)',
|
|
299
|
+
default: componentDefaults.description,
|
|
300
|
+
/* if left blank and no defaults, mustache will use componentLabel, because description is used in app studio and
|
|
301
|
+
shouldn't be blank */
|
|
302
|
+
}
|
|
303
|
+
];
|
|
304
|
+
|
|
305
|
+
await inquirer.prompt(questions).then(async answers => {
|
|
306
|
+
const {
|
|
307
|
+
componentKey,
|
|
308
|
+
componentName,
|
|
309
|
+
componentLabel,
|
|
310
|
+
organization,
|
|
311
|
+
library,
|
|
312
|
+
version,
|
|
313
|
+
description,
|
|
314
|
+
allowedApplications
|
|
315
|
+
} = answers;
|
|
316
|
+
|
|
317
|
+
await renameComponent(
|
|
318
|
+
{
|
|
319
|
+
componentKey,
|
|
320
|
+
componentName,
|
|
321
|
+
componentLabel,
|
|
322
|
+
library,
|
|
323
|
+
version,
|
|
324
|
+
description,
|
|
325
|
+
allowedApplications,
|
|
326
|
+
organization
|
|
327
|
+
},
|
|
328
|
+
options
|
|
329
|
+
);
|
|
330
|
+
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
};
|
|
@@ -1,62 +0,0 @@
|
|
|
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
|
-
{{#IS_TEMPLATE}}
|
|
13
|
-
"icon": "images/pz-text-input-active.svg",
|
|
14
|
-
{{/IS_TEMPLATE}}
|
|
15
|
-
"properties": [
|
|
16
|
-
{
|
|
17
|
-
"name": "label",
|
|
18
|
-
"label": "Label value",
|
|
19
|
-
"format": "TEXT"
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
"name": "placeholder",
|
|
23
|
-
"label": "Placeholder",
|
|
24
|
-
"format": "TEXT"
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
"name": "visibility",
|
|
28
|
-
"label": "Visible",
|
|
29
|
-
"format": "VISIBILITY"
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
"name": "disabled",
|
|
33
|
-
"label": "Disabled",
|
|
34
|
-
"format": "DISABLED"
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
"name": "required",
|
|
38
|
-
"label": "Required",
|
|
39
|
-
"format": "REQUIRED"
|
|
40
|
-
}
|
|
41
|
-
],
|
|
42
|
-
"defaultConfig": {
|
|
43
|
-
{{#IS_PICKLIST}}
|
|
44
|
-
"label": "@L $this.label",
|
|
45
|
-
"placeholder": "@L Select...",
|
|
46
|
-
"listType": "associated",
|
|
47
|
-
"datasource": "@ASSOCIATED .$this.name"
|
|
48
|
-
{{/IS_PICKLIST}}
|
|
49
|
-
{{#IS_BOOLEAN}}
|
|
50
|
-
"trueText": "True",
|
|
51
|
-
"falseText": "False"
|
|
52
|
-
{{/IS_BOOLEAN}}
|
|
53
|
-
{{#IS_PHONE}}
|
|
54
|
-
"datasource": {
|
|
55
|
-
"source": "@DATASOURCE D_pyCountryCallingCodeList.pxResults",
|
|
56
|
-
"fields": {
|
|
57
|
-
"value": "@P .pyCallingCode"
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
{{/IS_PHONE}}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
|
-
import { withKnobs, text, boolean } from '@storybook/addon-knobs';
|
|
3
|
-
|
|
4
|
-
import {{COMPONENT_CLASS_NAME}} from './index.jsx';
|
|
5
|
-
|
|
6
|
-
export default {
|
|
7
|
-
title: '{{COMPONENT_CLASS_NAME}}',
|
|
8
|
-
decorators: [withKnobs],
|
|
9
|
-
component: {{COMPONENT_CLASS_NAME}}
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export const base{{COMPONENT_CLASS_NAME}} = () => {
|
|
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,
|
|
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', 'Sample Label'),
|
|
36
|
-
testId: text('Test id', 'text-12344566')
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
return (
|
|
40
|
-
<>
|
|
41
|
-
<{{COMPONENT_CLASS_NAME}} {...props} />
|
|
42
|
-
</>
|
|
43
|
-
);
|
|
44
|
-
};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import PropTypes from 'prop-types';
|
|
2
|
-
import { Input, Label } from '@pega/cosmos-react-core';
|
|
3
|
-
|
|
4
|
-
import Styled{{COMPONENT_CLASS_NAME}}Wrapper from './styles';
|
|
5
|
-
|
|
6
|
-
const {{COMPONENT_CLASS_NAME}} = props => {
|
|
7
|
-
const { getPConnect, value, placeholder, disabled, readOnly, required, label, testId } = props;
|
|
8
|
-
|
|
9
|
-
const pConn = getPConnect();
|
|
10
|
-
const actions = pConn.getActionsApi();
|
|
11
|
-
const propName = pConn?.getStateProps()?.value;
|
|
12
|
-
|
|
13
|
-
const handleOnChange = event => {
|
|
14
|
-
const { value: updatedValue } = event.target;
|
|
15
|
-
actions.updateFieldValue(propName, updatedValue);
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
return (
|
|
19
|
-
<Styled{{COMPONENT_CLASS_NAME}}Wrapper>
|
|
20
|
-
<Label>{label}</Label>
|
|
21
|
-
<Input
|
|
22
|
-
type='text'
|
|
23
|
-
value={value}
|
|
24
|
-
placeholder={placeholder}
|
|
25
|
-
disabled={disabled}
|
|
26
|
-
readOnly={readOnly}
|
|
27
|
-
required={required}
|
|
28
|
-
onChange={handleOnChange}
|
|
29
|
-
testId={testId}
|
|
30
|
-
/>
|
|
31
|
-
</Styled{{COMPONENT_CLASS_NAME}}Wrapper>
|
|
32
|
-
);
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
{{COMPONENT_CLASS_NAME}}.defaultProps = {
|
|
36
|
-
value: '',
|
|
37
|
-
placeholder: '',
|
|
38
|
-
disabled: false,
|
|
39
|
-
readOnly: false,
|
|
40
|
-
required: false,
|
|
41
|
-
testId: null
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
{{COMPONENT_CLASS_NAME}}.propTypes = {
|
|
45
|
-
label: PropTypes.string,
|
|
46
|
-
value: PropTypes.string,
|
|
47
|
-
placeholder: PropTypes.string,
|
|
48
|
-
getPConnect: PropTypes.func.isRequired,
|
|
49
|
-
disabled: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
|
|
50
|
-
readOnly: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
|
|
51
|
-
required: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
|
|
52
|
-
testId: PropTypes.string
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export default {{COMPONENT_CLASS_NAME}};
|