@pega/custom-dx-components 2.0.10 → 2.0.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/README.md +73 -57
- package/package.json +2 -2
- package/src/cli.js +18 -0
- package/src/tasks/authenticate/index.js +3 -1
- package/src/tasks/build/helper.js +123 -0
- package/src/tasks/build/index.js +54 -0
- package/src/tasks/{publish/bundle → bundle}/builder/index.js +0 -0
- package/src/tasks/{publish/bundle → bundle}/builder/modules.js +0 -0
- package/src/tasks/{publish/bundle → bundle}/builder/paths.js +0 -0
- package/src/tasks/{publish/bundle → bundle}/builder/webpack.config.js +2 -4
- package/src/tasks/{publish/bundle → bundle}/index.js +2 -2
- package/src/tasks/create/index.js +6 -3
- package/src/tasks/create/templates/Constellation/Field/Boolean/boolean-format.js.mustache +1 -1
- package/src/tasks/create/templates/Constellation/Field/Boolean/demo.stories.jsx.mustache +29 -18
- package/src/tasks/create/templates/Constellation/Field/Boolean/index.jsx.mustache +1 -2
- package/src/tasks/create/templates/Constellation/Field/Boolean/mock.stories.js.mustache +21 -0
- package/src/tasks/create/templates/Constellation/Field/Date/DateFormatter.js.mustache +61 -0
- package/src/tasks/create/templates/Constellation/Field/Date/FormattedText.jsx.mustache +41 -0
- package/src/tasks/create/templates/Constellation/Field/Date/date.js.mustache +179 -67
- package/src/tasks/create/templates/Constellation/Field/Date/demo.stories.jsx.mustache +39 -16
- package/src/tasks/create/templates/Constellation/Field/Date/index.jsx.mustache +3 -1
- package/src/tasks/create/templates/Constellation/Field/Date/mock.stories.js.mustache +23 -0
- package/src/tasks/create/templates/Constellation/Field/DateTime/date-time.js.mustache +0 -1
- package/src/tasks/create/templates/Constellation/Field/DateTime/{date-utils.js → date-utils.js.mustache} +1 -0
- package/src/tasks/create/templates/Constellation/Field/DateTime/date.js.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Field/DateTime/demo.stories.jsx.mustache +39 -15
- package/src/tasks/create/templates/Constellation/Field/DateTime/index.jsx.mustache +2 -0
- package/src/tasks/create/templates/Constellation/Field/DateTime/mock.stories.js.mustache +23 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal/demo.stories.jsx.mustache +22 -17
- package/src/tasks/create/templates/Constellation/Field/Decimal/index.jsx.mustache +2 -1
- package/src/tasks/create/templates/Constellation/Field/Decimal/mock.stories.js.mustache +21 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/demo.stories.jsx.mustache +25 -17
- package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/index.jsx.mustache +3 -4
- package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/mock.stories.js.mustache +23 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/demo.stories.jsx.mustache +22 -17
- package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/index.jsx.mustache +8 -2
- package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/mock.stories.js.mustache +21 -0
- package/src/tasks/create/templates/Constellation/Field/Integer/demo.stories.jsx.mustache +22 -17
- package/src/tasks/create/templates/Constellation/Field/Integer/index.jsx.mustache +2 -1
- package/src/tasks/create/templates/Constellation/Field/Integer/mock.stories.js.mustache +21 -0
- package/src/tasks/create/templates/Constellation/Field/Picklist/demo.stories.jsx.mustache +42 -14
- package/src/tasks/create/templates/Constellation/Field/Picklist/index.jsx.mustache +44 -1
- package/src/tasks/create/templates/Constellation/Field/Picklist/mock.stories.js.mustache +67 -0
- package/src/tasks/create/templates/Constellation/Field/Text/demo.stories.jsx.mustache +21 -16
- package/src/tasks/create/templates/Constellation/Field/Text/mock.stories.js.mustache +13 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Email/demo.stories.jsx.mustache +20 -16
- package/src/tasks/create/templates/Constellation/Field/Text-Email/index.jsx.mustache +44 -2
- package/src/tasks/create/templates/Constellation/Field/Text-Email/mock.stories.js.mustache +22 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Input/{StatusWork.js → StatusWork.jsx} +0 -1
- package/src/tasks/create/templates/Constellation/Field/Text-Input/demo.stories.jsx.mustache +21 -17
- package/src/tasks/create/templates/Constellation/Field/Text-Input/index.jsx.mustache +46 -3
- package/src/tasks/create/templates/Constellation/Field/Text-Input/mock.stories.js.mustache +21 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/demo.stories.jsx.mustache +21 -17
- package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/index.jsx.mustache +44 -2
- package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/mock.stories.js.mustache +20 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Phone/demo.stories.jsx.mustache +19 -17
- package/src/tasks/create/templates/Constellation/Field/Text-Phone/index.jsx.mustache +46 -2
- package/src/tasks/create/templates/Constellation/Field/Text-Phone/mock.stories.js.mustache +37 -0
- package/src/tasks/create/templates/Constellation/Field/Text-URL/demo.stories.jsx.mustache +19 -17
- package/src/tasks/create/templates/Constellation/Field/Text-URL/index.jsx.mustache +174 -3
- package/src/tasks/create/templates/Constellation/Field/Text-URL/mock.stories.js.mustache +22 -0
- package/src/tasks/create/templates/Constellation/Field/TimeofDay/demo.stories.jsx.mustache +24 -16
- package/src/tasks/create/templates/Constellation/Field/TimeofDay/mock.stories.js.mustache +20 -0
- package/src/tasks/create/templates/Constellation/Field/TimeofDay/time-of-day.js.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/StatusWork.jsx.mustache +26 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/demo.stories.jsx.mustache +110 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/index.jsx.mustache +14 -29
- package/src/tasks/create/templates/Constellation/Template/DETAILS/mock.stories.js.mustache +179 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/utils.js.mustache +3 -77
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/StatusWork.jsx.mustache +26 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/demo.stories.jsx.mustache +118 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/index.jsx.mustache +14 -29
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/mock.stories.js.mustache +215 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/utils.js.mustache +3 -74
- package/src/tasks/create/templates/Constellation/Template/FORM/demo.stories.jsx.mustache +89 -0
- package/src/tasks/create/templates/Constellation/Template/FORM/index.jsx.mustache +6 -10
- package/src/tasks/create/templates/Constellation/Template/FORM/mock.stories.js.mustache +125 -0
- package/src/tasks/create/templates/Constellation/Template/FORM-region/demo.stories.jsx.mustache +92 -0
- package/src/tasks/create/templates/Constellation/Template/FORM-region/index.jsx.mustache +10 -8
- package/src/tasks/create/templates/Constellation/Template/FORM-region/mock.stories.js.mustache +125 -0
- package/src/tasks/create/templates/Constellation/Template/PAGE/{GetNextWork.js.mustache → GetNextWork.jsx.mustache} +6 -0
- package/src/tasks/create/templates/Constellation/Template/PAGE/demo.stories.jsx.mustache +102 -0
- package/src/tasks/create/templates/Constellation/Template/PAGE/index.jsx.mustache +9 -7
- package/src/tasks/create/templates/Constellation/Template/PAGE/mock.stories.js.mustache +94 -0
- package/src/tasks/create/templates/Constellation/Template/PAGE/styles.js.mustache +1 -1
- package/src/tasks/create/templates/Constellation/Template/PAGE/utils.js.mustache +4 -1
- package/src/tasks/create/templates/Constellation/Widget/CASE/demo.stories.jsx.mustache +78 -0
- package/src/tasks/create/templates/Constellation/Widget/CASE/index.jsx.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Widget/CASE/mock.stories.js.mustache +389 -0
- package/src/tasks/create/templates/Constellation/Widget/CASE/styles.js.mustache +1 -1
- package/src/tasks/create/templates/Constellation/Widget/PAGE/demo.stories.jsx.mustache +30 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE/index.jsx.mustache +8 -8
- package/src/tasks/create/templates/Constellation/Widget/PAGE/mock.stories.js.mustache +22 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE/styles.js.mustache +1 -1
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/{Avatar.js.mustache → Avatar.jsx.mustache} +2 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/{Operator.js.mustache → Operator.jsx.mustache} +2 -1
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/demo.stories.jsx.mustache +68 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/index.jsx.mustache +9 -9
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/mock.stories.js.mustache +51 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/styles.js.mustache +1 -1
- package/src/tasks/delete/helper.js +4 -0
- package/src/tasks/delete/index.js +4 -0
- package/src/tasks/delete-all/helper.js +175 -0
- package/src/tasks/delete-all/index.js +49 -0
- package/src/tasks/index.js +3 -0
- package/src/tasks/init/index.js +1 -1
- package/src/tasks/init/template/.eslintignore +8 -0
- package/src/tasks/init/template/.eslintrc.json +186 -5
- package/src/tasks/init/template/package.json.mustache +19 -4
- package/src/tasks/linter/index.js +46 -0
- package/src/tasks/list/index.js +4 -0
- package/src/tasks/publish/index.js +14 -1
- package/src/tasks/publish-all/helper.js +139 -0
- package/src/tasks/publish-all/index.js +84 -0
- package/src/util.js +10 -0
- package/src/tasks/create/templates/Constellation/Field/Picklist/picklist.js.mustache +0 -43
- package/src/tasks/create/templates/Constellation/Field/Text-Email/text-email.js.mustache +0 -43
- package/src/tasks/create/templates/Constellation/Field/Text-Input/text-input.js.mustache +0 -43
- package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/text-paragraph.js.mustache +0 -43
- package/src/tasks/create/templates/Constellation/Field/Text-Phone/text-phone.js.mustache +0 -43
- package/src/tasks/create/templates/Constellation/Field/Text-URL/text-url.js.mustache +0 -172
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import https from 'https';
|
|
4
|
+
|
|
5
|
+
import fetch from 'node-fetch';
|
|
6
|
+
import AdmZip from 'adm-zip';
|
|
7
|
+
import chalk from 'chalk';
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
constructCompleteUrl,
|
|
11
|
+
getComponentDirectoryPath,
|
|
12
|
+
getComponents,
|
|
13
|
+
getPegaServerConfig,
|
|
14
|
+
validateRulesetVersion
|
|
15
|
+
} from '../../util.js';
|
|
16
|
+
import { PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT, TOKEN_PATH } from '../../constants.js';
|
|
17
|
+
|
|
18
|
+
export const getPublishComponentQuestions = async () => {
|
|
19
|
+
const components = await getComponents();
|
|
20
|
+
const defaultPegaConfig = await getPegaServerConfig();
|
|
21
|
+
|
|
22
|
+
return [
|
|
23
|
+
{
|
|
24
|
+
name: 'rulesetName',
|
|
25
|
+
message: 'Enter ruleset name',
|
|
26
|
+
default: defaultPegaConfig.rulesetName,
|
|
27
|
+
validate: value => {
|
|
28
|
+
if (value.trim()) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
return 'Ruleset name cannot be empty';
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: 'rulesetVersion',
|
|
36
|
+
message: 'Enter ruleset version',
|
|
37
|
+
default: defaultPegaConfig.rulesetVersion,
|
|
38
|
+
validate: value => {
|
|
39
|
+
if (validateRulesetVersion(value)) {
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
return 'Please provide compatible version e.g 01-01-01';
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: 'sourceMap',
|
|
47
|
+
message: 'Generate source map ?',
|
|
48
|
+
default: defaultPegaConfig.sourceMap,
|
|
49
|
+
when: () => false && !process.env.SOURCE_MAP
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: 'devBuild',
|
|
53
|
+
message: 'Generate development build ?',
|
|
54
|
+
default: defaultPegaConfig.devBuild
|
|
55
|
+
}
|
|
56
|
+
];
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export const zipComponent = async componentKey => {
|
|
60
|
+
const srcDirectory = await getComponentDirectoryPath(componentKey);
|
|
61
|
+
const buildDirectory = await path.join(path.resolve(), 'dist/components', componentKey);
|
|
62
|
+
const configJson = `${srcDirectory}/config.json`;
|
|
63
|
+
|
|
64
|
+
const zip = new AdmZip();
|
|
65
|
+
|
|
66
|
+
zip.addLocalFolder(srcDirectory, 'src/');
|
|
67
|
+
zip.addLocalFile(configJson);
|
|
68
|
+
zip.addLocalFolder(buildDirectory);
|
|
69
|
+
const zipContent = zip.toBuffer().toString('base64');
|
|
70
|
+
|
|
71
|
+
const configContent = Buffer.from(fs.readFileSync(`${srcDirectory}/config.json`)).toString();
|
|
72
|
+
fs.rmdir('dist', { recursive: true }, err => {
|
|
73
|
+
if (err) {
|
|
74
|
+
throw err;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
return { zipContent, configContent };
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export const publishComponentToServer = async data => {
|
|
81
|
+
const { configContent, zipContent, componentKey, rulesetName, rulesetVersion } = data;
|
|
82
|
+
|
|
83
|
+
const apiBody = {
|
|
84
|
+
configContent,
|
|
85
|
+
zipContent,
|
|
86
|
+
componentKey: JSON.parse(configContent).componentKey,
|
|
87
|
+
publishFor: 'constellation',
|
|
88
|
+
rulesetName,
|
|
89
|
+
rulesetVersion,
|
|
90
|
+
category: ''
|
|
91
|
+
};
|
|
92
|
+
const defaultPegaConfig = await getPegaServerConfig();
|
|
93
|
+
const url = constructCompleteUrl(
|
|
94
|
+
defaultPegaConfig.server,
|
|
95
|
+
PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT
|
|
96
|
+
);
|
|
97
|
+
try {
|
|
98
|
+
const OauthData = fs.readFileSync(TOKEN_PATH, 'utf8');
|
|
99
|
+
if (OauthData) {
|
|
100
|
+
const {
|
|
101
|
+
access_token: accessToken,
|
|
102
|
+
token_type: tokenType,
|
|
103
|
+
refresh_token: refreshToken
|
|
104
|
+
} = JSON.parse(OauthData);
|
|
105
|
+
let status = 500;
|
|
106
|
+
fetch(url, {
|
|
107
|
+
method: 'POST',
|
|
108
|
+
agent: new https.Agent({ rejectUnauthorized: false }),
|
|
109
|
+
headers: {
|
|
110
|
+
Authorization: `${tokenType} ${accessToken}`
|
|
111
|
+
},
|
|
112
|
+
body: JSON.stringify(apiBody)
|
|
113
|
+
})
|
|
114
|
+
.then(response => {
|
|
115
|
+
status = response.status;
|
|
116
|
+
return response.text();
|
|
117
|
+
})
|
|
118
|
+
.then(resp => {
|
|
119
|
+
const respData = JSON.parse(resp);
|
|
120
|
+
if (status === 401) {
|
|
121
|
+
throw new Error(
|
|
122
|
+
'Error occured in authentication. Please regenerate using authenticate'
|
|
123
|
+
);
|
|
124
|
+
// console.log(accessTokenUri, refreshToken);
|
|
125
|
+
/* TODO - Handle refresh_token */
|
|
126
|
+
} else if (status == 200) {
|
|
127
|
+
console.log(chalk.bold.green(`Success : ${respData.message}`));
|
|
128
|
+
} else {
|
|
129
|
+
throw new Error(`${respData.message}`);
|
|
130
|
+
}
|
|
131
|
+
})
|
|
132
|
+
.catch(e => Promise.reject(`${chalk.bold.red(e)}`));
|
|
133
|
+
} else {
|
|
134
|
+
throw new Error(`Error occured in authentication. Please regenerate using authenticate`);
|
|
135
|
+
}
|
|
136
|
+
} catch (err) {
|
|
137
|
+
throw new Error(`Error occured in authentication. Please regenerate using authenticate`);
|
|
138
|
+
}
|
|
139
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import inquirer from 'inquirer';
|
|
2
|
+
import Listr from 'listr';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
|
|
5
|
+
import validate from '../validator/index.js';
|
|
6
|
+
|
|
7
|
+
import bundleComponent from '../bundle/index.js';
|
|
8
|
+
import { lintComponent } from '../linter/index.js';
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
import { getPublishComponentQuestions, publishComponentToServer, zipComponent } from './helper.js';
|
|
12
|
+
import {
|
|
13
|
+
getComponents,
|
|
14
|
+
getComponentDirectoryPath,
|
|
15
|
+
showVersion
|
|
16
|
+
} from '../../util.js';
|
|
17
|
+
|
|
18
|
+
export default async options => {
|
|
19
|
+
showVersion();
|
|
20
|
+
|
|
21
|
+
const components = await getComponents();
|
|
22
|
+
const questions = await getPublishComponentQuestions();
|
|
23
|
+
const answers = await inquirer.prompt(questions);
|
|
24
|
+
const {sourceMap, devBuild } = answers;
|
|
25
|
+
|
|
26
|
+
let content = {
|
|
27
|
+
...answers
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
var componentKey;
|
|
31
|
+
|
|
32
|
+
const tasks = new Listr(
|
|
33
|
+
[
|
|
34
|
+
{
|
|
35
|
+
title: 'Validate config schema',
|
|
36
|
+
task: async () => {
|
|
37
|
+
await validate(componentKey);
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
title: 'Bundle Component',
|
|
42
|
+
task: async () => await bundleComponent(componentKey, sourceMap, devBuild),
|
|
43
|
+
skip: () => (options.skipBundle ? 'Skipped bundling component' : undefined)
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
title: 'Lint component',
|
|
47
|
+
task: async () => {
|
|
48
|
+
const targetDirectory = await getComponentDirectoryPath(componentKey);
|
|
49
|
+
// console.log(`in buildComponent Lint component task: componentKey: ${componentKey} targetDirectory: ${targetDirectory}`);
|
|
50
|
+
await lintComponent(targetDirectory);
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
title: 'Zip Component',
|
|
55
|
+
task: async () => {
|
|
56
|
+
const output = await zipComponent(componentKey);
|
|
57
|
+
content = { ...content, ...output };
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
title: 'Publish Component',
|
|
62
|
+
task: async () => {
|
|
63
|
+
await publishComponentToServer(content);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
],
|
|
67
|
+
{
|
|
68
|
+
exitOnError: true
|
|
69
|
+
}
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
for (var index in components) {
|
|
73
|
+
componentKey = components[index];
|
|
74
|
+
console.log(chalk.bold.green("Publishing: " + componentKey));
|
|
75
|
+
await tasks.run().catch(err => {
|
|
76
|
+
console.log(chalk.bold.red(err.toString()));
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// await tasks.run().catch(err => {
|
|
81
|
+
// console.log(chalk.bold.red(err.toString()));
|
|
82
|
+
// });
|
|
83
|
+
return true;
|
|
84
|
+
};
|
package/src/util.js
CHANGED
|
@@ -7,6 +7,8 @@ import chalk from 'chalk';
|
|
|
7
7
|
import mustache from 'mustache';
|
|
8
8
|
import pascalCase from 'pascalcase';
|
|
9
9
|
import fetch from 'node-fetch';
|
|
10
|
+
import { createRequire } from 'module';
|
|
11
|
+
|
|
10
12
|
|
|
11
13
|
import {
|
|
12
14
|
COMPONENTS_DIRECTORY_PATH,
|
|
@@ -218,6 +220,14 @@ export const validateRulesetVersion = str => {
|
|
|
218
220
|
return regex.test(str);
|
|
219
221
|
};
|
|
220
222
|
|
|
223
|
+
export const showVersion = () => {
|
|
224
|
+
// get package version, so can display at start
|
|
225
|
+
const require = createRequire(import.meta.url);
|
|
226
|
+
const pData = require("@pega/custom-dx-components/package.json");
|
|
227
|
+
|
|
228
|
+
console.log(chalk.green("DX Component Builder v" + pData.version));
|
|
229
|
+
}
|
|
230
|
+
|
|
221
231
|
export const getOOTBComponents = async () => {
|
|
222
232
|
return new Promise((resolve, reject) => {
|
|
223
233
|
fs.readFile(OOTB_COMPONENTS, 'utf-8', async (err, data) => {
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import {EmailDisplay, PhoneDisplay, URLDisplay } from "@pega/cosmos-react-core";
|
|
2
|
-
|
|
3
|
-
export const formatExists = (formatterVal) => {
|
|
4
|
-
const formatterValues = [
|
|
5
|
-
"TextInput",
|
|
6
|
-
"WorkStatus",
|
|
7
|
-
"RichText",
|
|
8
|
-
"Email",
|
|
9
|
-
"Phone",
|
|
10
|
-
"URL",
|
|
11
|
-
"Operator"
|
|
12
|
-
];
|
|
13
|
-
let isformatter = false;
|
|
14
|
-
if (formatterValues.includes(formatterVal)) {
|
|
15
|
-
isformatter = true;
|
|
16
|
-
}
|
|
17
|
-
return isformatter;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
export const textFormatter = (formatter,value) => {
|
|
22
|
-
let displayComponent = null;
|
|
23
|
-
switch(formatter){
|
|
24
|
-
case "TextInput" : {
|
|
25
|
-
displayComponent = value;
|
|
26
|
-
break;
|
|
27
|
-
}
|
|
28
|
-
case "Email" : {
|
|
29
|
-
displayComponent = (<EmailDisplay value={value} displayText={value} variant="link" />);
|
|
30
|
-
break;
|
|
31
|
-
}
|
|
32
|
-
case "Phone" : {
|
|
33
|
-
displayComponent = (<PhoneDisplay value={value} variant="link" />);
|
|
34
|
-
break;
|
|
35
|
-
}
|
|
36
|
-
case "URL" : {
|
|
37
|
-
displayComponent = (<URLDisplay target="_blank" value={value} displayText={value} variant="link" />);
|
|
38
|
-
break;
|
|
39
|
-
}
|
|
40
|
-
// no default
|
|
41
|
-
}
|
|
42
|
-
return displayComponent;
|
|
43
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import {EmailDisplay, PhoneDisplay, URLDisplay } from "@pega/cosmos-react-core";
|
|
2
|
-
|
|
3
|
-
export const formatExists = (formatterVal) => {
|
|
4
|
-
const formatterValues = [
|
|
5
|
-
"TextInput",
|
|
6
|
-
"WorkStatus",
|
|
7
|
-
"RichText",
|
|
8
|
-
"Email",
|
|
9
|
-
"Phone",
|
|
10
|
-
"URL",
|
|
11
|
-
"Operator"
|
|
12
|
-
];
|
|
13
|
-
let isformatter = false;
|
|
14
|
-
if (formatterValues.includes(formatterVal)) {
|
|
15
|
-
isformatter = true;
|
|
16
|
-
}
|
|
17
|
-
return isformatter;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
export const textFormatter = (formatter,value) => {
|
|
22
|
-
let displayComponent = null;
|
|
23
|
-
switch(formatter){
|
|
24
|
-
case "TextInput" : {
|
|
25
|
-
displayComponent = value;
|
|
26
|
-
break;
|
|
27
|
-
}
|
|
28
|
-
case "Email" : {
|
|
29
|
-
displayComponent = (<EmailDisplay value={value} displayText={value} variant="link" />);
|
|
30
|
-
break;
|
|
31
|
-
}
|
|
32
|
-
case "Phone" : {
|
|
33
|
-
displayComponent = (<PhoneDisplay value={value} variant="link" />);
|
|
34
|
-
break;
|
|
35
|
-
}
|
|
36
|
-
case "URL" : {
|
|
37
|
-
displayComponent = (<URLDisplay target="_blank" value={value} displayText={value} variant="link" />);
|
|
38
|
-
break;
|
|
39
|
-
}
|
|
40
|
-
// no default
|
|
41
|
-
}
|
|
42
|
-
return displayComponent;
|
|
43
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import {EmailDisplay, PhoneDisplay, URLDisplay } from "@pega/cosmos-react-core";
|
|
2
|
-
|
|
3
|
-
export const formatExists = (formatterVal) => {
|
|
4
|
-
const formatterValues = [
|
|
5
|
-
"TextInput",
|
|
6
|
-
"WorkStatus",
|
|
7
|
-
"RichText",
|
|
8
|
-
"Email",
|
|
9
|
-
"Phone",
|
|
10
|
-
"URL",
|
|
11
|
-
"Operator"
|
|
12
|
-
];
|
|
13
|
-
let isformatter = false;
|
|
14
|
-
if (formatterValues.includes(formatterVal)) {
|
|
15
|
-
isformatter = true;
|
|
16
|
-
}
|
|
17
|
-
return isformatter;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
export const textFormatter = (formatter,value) => {
|
|
22
|
-
let displayComponent = null;
|
|
23
|
-
switch(formatter){
|
|
24
|
-
case "TextInput" : {
|
|
25
|
-
displayComponent = value;
|
|
26
|
-
break;
|
|
27
|
-
}
|
|
28
|
-
case "Email" : {
|
|
29
|
-
displayComponent = (<EmailDisplay value={value} displayText={value} variant="link" />);
|
|
30
|
-
break;
|
|
31
|
-
}
|
|
32
|
-
case "Phone" : {
|
|
33
|
-
displayComponent = (<PhoneDisplay value={value} variant="link" />);
|
|
34
|
-
break;
|
|
35
|
-
}
|
|
36
|
-
case "URL" : {
|
|
37
|
-
displayComponent = (<URLDisplay target="_blank" value={value} displayText={value} variant="link" />);
|
|
38
|
-
break;
|
|
39
|
-
}
|
|
40
|
-
// no default
|
|
41
|
-
}
|
|
42
|
-
return displayComponent;
|
|
43
|
-
};
|
package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/text-paragraph.js.mustache
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import {EmailDisplay, PhoneDisplay, URLDisplay } from "@pega/cosmos-react-core";
|
|
2
|
-
|
|
3
|
-
export const formatExists = (formatterVal) => {
|
|
4
|
-
const formatterValues = [
|
|
5
|
-
"TextInput",
|
|
6
|
-
"WorkStatus",
|
|
7
|
-
"RichText",
|
|
8
|
-
"Email",
|
|
9
|
-
"Phone",
|
|
10
|
-
"URL",
|
|
11
|
-
"Operator"
|
|
12
|
-
];
|
|
13
|
-
let isformatter = false;
|
|
14
|
-
if (formatterValues.includes(formatterVal)) {
|
|
15
|
-
isformatter = true;
|
|
16
|
-
}
|
|
17
|
-
return isformatter;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
export const textFormatter = (formatter,value) => {
|
|
22
|
-
let displayComponent = null;
|
|
23
|
-
switch(formatter){
|
|
24
|
-
case "TextInput" : {
|
|
25
|
-
displayComponent = value;
|
|
26
|
-
break;
|
|
27
|
-
}
|
|
28
|
-
case "Email" : {
|
|
29
|
-
displayComponent = (<EmailDisplay value={value} displayText={value} variant="link" />);
|
|
30
|
-
break;
|
|
31
|
-
}
|
|
32
|
-
case "Phone" : {
|
|
33
|
-
displayComponent = (<PhoneDisplay value={value} variant="link" />);
|
|
34
|
-
break;
|
|
35
|
-
}
|
|
36
|
-
case "URL" : {
|
|
37
|
-
displayComponent = (<URLDisplay target="_blank" value={value} displayText={value} variant="link" />);
|
|
38
|
-
break;
|
|
39
|
-
}
|
|
40
|
-
// no default
|
|
41
|
-
}
|
|
42
|
-
return displayComponent;
|
|
43
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import {EmailDisplay, PhoneDisplay, URLDisplay } from "@pega/cosmos-react-core";
|
|
2
|
-
|
|
3
|
-
export const formatExists = (formatterVal) => {
|
|
4
|
-
const formatterValues = [
|
|
5
|
-
"TextInput",
|
|
6
|
-
"WorkStatus",
|
|
7
|
-
"RichText",
|
|
8
|
-
"Email",
|
|
9
|
-
"Phone",
|
|
10
|
-
"URL",
|
|
11
|
-
"Operator"
|
|
12
|
-
];
|
|
13
|
-
let isformatter = false;
|
|
14
|
-
if (formatterValues.includes(formatterVal)) {
|
|
15
|
-
isformatter = true;
|
|
16
|
-
}
|
|
17
|
-
return isformatter;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
export const textFormatter = (formatter,value) => {
|
|
22
|
-
let displayComponent = null;
|
|
23
|
-
switch(formatter){
|
|
24
|
-
case "TextInput" : {
|
|
25
|
-
displayComponent = value;
|
|
26
|
-
break;
|
|
27
|
-
}
|
|
28
|
-
case "Email" : {
|
|
29
|
-
displayComponent = (<EmailDisplay value={value} displayText={value} variant="link" />);
|
|
30
|
-
break;
|
|
31
|
-
}
|
|
32
|
-
case "Phone" : {
|
|
33
|
-
displayComponent = (<PhoneDisplay value={value} variant="link" />);
|
|
34
|
-
break;
|
|
35
|
-
}
|
|
36
|
-
case "URL" : {
|
|
37
|
-
displayComponent = (<URLDisplay target="_blank" value={value} displayText={value} variant="link" />);
|
|
38
|
-
break;
|
|
39
|
-
}
|
|
40
|
-
// no default
|
|
41
|
-
}
|
|
42
|
-
return displayComponent;
|
|
43
|
-
};
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
import {EmailDisplay, PhoneDisplay, URLDisplay } from "@pega/cosmos-react-core";
|
|
2
|
-
|
|
3
|
-
export const formatExists = (formatterVal) => {
|
|
4
|
-
const formatterValues = [
|
|
5
|
-
"TextInput",
|
|
6
|
-
"WorkStatus",
|
|
7
|
-
"RichText",
|
|
8
|
-
"Email",
|
|
9
|
-
"Phone",
|
|
10
|
-
"URL",
|
|
11
|
-
"Operator"
|
|
12
|
-
];
|
|
13
|
-
let isformatter = false;
|
|
14
|
-
if (formatterValues.includes(formatterVal)) {
|
|
15
|
-
isformatter = true;
|
|
16
|
-
}
|
|
17
|
-
return isformatter;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const urlLabelVal = (urlLabelSelection, btnVal, urlLabel, propUrlLabel) => {
|
|
21
|
-
if ((urlLabel !== '' || propUrlLabel !== '') && btnVal !== null) {
|
|
22
|
-
switch (urlLabelSelection) {
|
|
23
|
-
case 'constant': {
|
|
24
|
-
btnVal = urlLabel;
|
|
25
|
-
break;
|
|
26
|
-
}
|
|
27
|
-
case 'propertyRef': {
|
|
28
|
-
btnVal = propUrlLabel;
|
|
29
|
-
break;
|
|
30
|
-
}
|
|
31
|
-
// no default
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return btnVal;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
const isImage = (url) => /\.(jpg|jpeg|png|webp|avif|gif|svg)$/.test(url);
|
|
38
|
-
|
|
39
|
-
const TableImage = (imageProps) => {
|
|
40
|
-
const { value, altText, altTextOfImage, propaltTextOfImage, urlLabelSelection, urlLabel, propUrlLabel } = imageProps;
|
|
41
|
-
const demoButtonRef = useRef(null);
|
|
42
|
-
let imageDisplayComp = null;
|
|
43
|
-
const [images, setImages] = useState(null);
|
|
44
|
-
const imgDescription = {
|
|
45
|
-
id: 'url',
|
|
46
|
-
name: urlLabelSelection === 'constant' ? urlLabel : propUrlLabel,
|
|
47
|
-
description: altText === 'constant' ? altTextOfImage : propaltTextOfImage,
|
|
48
|
-
src: value
|
|
49
|
-
};
|
|
50
|
-
const onClick = () => {
|
|
51
|
-
setImages([imgDescription]);
|
|
52
|
-
};
|
|
53
|
-
const onItemDownload = async (id) => {
|
|
54
|
-
const a = document.createElement('a');
|
|
55
|
-
a.href = await fetch(images[0].src)
|
|
56
|
-
.then((response) => {
|
|
57
|
-
return response.blob();
|
|
58
|
-
})
|
|
59
|
-
.then((blob) => {
|
|
60
|
-
return URL.createObjectURL(blob);
|
|
61
|
-
});
|
|
62
|
-
a.download = images?.find((image) => image.id === id)?.name ?? id;
|
|
63
|
-
document.body.appendChild(a);
|
|
64
|
-
a.click();
|
|
65
|
-
document.body.removeChild(a);
|
|
66
|
-
};
|
|
67
|
-
let btnVal = value;
|
|
68
|
-
btnVal = urlLabelVal(urlLabelSelection, btnVal, urlLabel, propUrlLabel);
|
|
69
|
-
imageDisplayComp = (
|
|
70
|
-
<React.Fragment>
|
|
71
|
-
{btnVal !== null && (
|
|
72
|
-
<Button ref={demoButtonRef} variant='link' compact={false} onClick={onClick} autoFocus>
|
|
73
|
-
{btnVal}
|
|
74
|
-
</Button>
|
|
75
|
-
)}
|
|
76
|
-
{images && (
|
|
77
|
-
<Lightbox
|
|
78
|
-
items={images}
|
|
79
|
-
cycle={false}
|
|
80
|
-
onAfterClose={() => {
|
|
81
|
-
setImages(null);
|
|
82
|
-
demoButtonRef.current?.focus();
|
|
83
|
-
}}
|
|
84
|
-
onItemDownload={isImage(images[0].src) ? onItemDownload : undefined}
|
|
85
|
-
/>
|
|
86
|
-
)}
|
|
87
|
-
</React.Fragment>
|
|
88
|
-
);
|
|
89
|
-
return imageDisplayComp;
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
export const textFormatter = (formatter,value) => {
|
|
93
|
-
let displayComponent = null;
|
|
94
|
-
switch(formatter){
|
|
95
|
-
case "TextInput" : {
|
|
96
|
-
displayComponent = value;
|
|
97
|
-
break;
|
|
98
|
-
}
|
|
99
|
-
case "Email" : {
|
|
100
|
-
displayComponent = (<EmailDisplay value={value} displayText={value} variant="link" />);
|
|
101
|
-
break;
|
|
102
|
-
}
|
|
103
|
-
case "Phone" : {
|
|
104
|
-
displayComponent = (<PhoneDisplay value={value} variant="link" />);
|
|
105
|
-
break;
|
|
106
|
-
}
|
|
107
|
-
case "URL" : {
|
|
108
|
-
displayComponent = (<URLDisplay target="_blank" value={value} displayText={value} variant="link" />);
|
|
109
|
-
break;
|
|
110
|
-
}
|
|
111
|
-
// no default
|
|
112
|
-
}
|
|
113
|
-
return displayComponent;
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Returns a URL display component based on the options
|
|
118
|
-
* @function urlFormatter
|
|
119
|
-
* @param {string} value value
|
|
120
|
-
* @param {object} options options for formatting
|
|
121
|
-
* { displayAs,tableDisplayAs,isTableFormatter,altText,altTextOfImage,propaltTextOfImage,urlLabelSelection, urlLabel,propUrlLabel, widthSel, customWidth}
|
|
122
|
-
*/
|
|
123
|
-
export const urlFormatter = (value, options) => {
|
|
124
|
-
const {
|
|
125
|
-
displayAs,
|
|
126
|
-
tableDisplayAs,
|
|
127
|
-
isTableFormatter,
|
|
128
|
-
altText,
|
|
129
|
-
altTextOfImage,
|
|
130
|
-
propaltTextOfImage,
|
|
131
|
-
urlLabelSelection,
|
|
132
|
-
urlLabel,
|
|
133
|
-
propUrlLabel,
|
|
134
|
-
widthSel,
|
|
135
|
-
customWidth
|
|
136
|
-
} = options;
|
|
137
|
-
|
|
138
|
-
let urlFormatComp = null;
|
|
139
|
-
if (
|
|
140
|
-
(displayAs === 'labelText' || (isTableFormatter && tableDisplayAs === 'link')) &&
|
|
141
|
-
(urlLabel !== '' || propUrlLabel !== '')
|
|
142
|
-
) {
|
|
143
|
-
urlFormatComp = (
|
|
144
|
-
<URLDisplay
|
|
145
|
-
target='_blank'
|
|
146
|
-
value={value}
|
|
147
|
-
displayText={urlLabelSelection === 'constant' ? urlLabel : propUrlLabel}
|
|
148
|
-
variant='link'
|
|
149
|
-
/>
|
|
150
|
-
);
|
|
151
|
-
} else if ((displayAs === 'Image' || tableDisplayAs === 'Image') && !!value) {
|
|
152
|
-
if (isTableFormatter) {
|
|
153
|
-
urlFormatComp = TableImage({
|
|
154
|
-
value,
|
|
155
|
-
altText,
|
|
156
|
-
altTextOfImage,
|
|
157
|
-
propaltTextOfImage,
|
|
158
|
-
urlLabelSelection,
|
|
159
|
-
urlLabel,
|
|
160
|
-
propUrlLabel
|
|
161
|
-
});
|
|
162
|
-
} else {
|
|
163
|
-
const width = widthSel === 'widthpx' ? customWidth : null;
|
|
164
|
-
urlFormatComp = (
|
|
165
|
-
<Image src={value} width={width} alt={altText === 'constant' ? altTextOfImage : propaltTextOfImage} />
|
|
166
|
-
);
|
|
167
|
-
}
|
|
168
|
-
} else {
|
|
169
|
-
urlFormatComp = <URLDisplay target='_blank' value={value} displayText={value} variant='link' />;
|
|
170
|
-
}
|
|
171
|
-
return urlFormatComp;
|
|
172
|
-
};
|