@pega/dx-component-builder-sdk 0.1.6 → 0.1.8
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/constants.js +8 -4
- package/src/tasks/build/helper.js +5 -23
- package/src/tasks/build/index.js +54 -7
- package/src/tasks/bundle/index.js +2 -2
- package/src/tasks/create/index.js +13 -5
- 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 +60 -0
- 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 +40 -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 +40 -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 +3 -5
- 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 -6
- 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 +3 -5
- 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 -3
- 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 +100 -0
- package/src/tasks/create/templates/Constellation/Template/FORM-region/index.jsx.mustache +5 -11
- package/src/tasks/create/templates/Constellation/Template/FORM-region/mock.stories.js.mustache +131 -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/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/PAGE/demo.stories.jsx.mustache +30 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE/mock.stories.js.mustache +22 -0
- 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/SDK-React/Template/PAGE/demo.stories.jsx.mustache +79 -0
- package/src/tasks/create/templates/SDK-React/Template/PAGE/mock.stories.js.mustache +115 -0
- package/src/tasks/delete/helper.js +7 -25
- package/src/tasks/delete/index.js +2 -3
- package/src/tasks/delete-all/helper.js +7 -24
- package/src/tasks/delete-all/index.js +2 -3
- package/src/tasks/list/helper.js +3 -21
- package/src/tasks/list/index.js +2 -3
- package/src/tasks/map/map.js +4 -10
- package/src/tasks/override/index.js +50 -21
- package/src/tasks/publish/helper.js +77 -15
- package/src/tasks/publish/index.js +103 -15
- package/src/tasks/publish-all/helper.js +77 -13
- package/src/tasks/publish-all/index.js +109 -25
- package/src/tasks/validator/index.js +7 -5
- package/src/util.js +56 -10
- 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
package/package.json
CHANGED
package/src/constants.js
CHANGED
|
@@ -22,6 +22,10 @@ export const COMPONENT_PREFIX_WIDGETS_PATH = "widgets/";
|
|
|
22
22
|
export const COMPONENT_PREFIX_DSE_PATH = "designSystemExtensions/";
|
|
23
23
|
export const COMPONENT_PREFIX_INFRA_PATH = "infra/";
|
|
24
24
|
|
|
25
|
+
export const CATEGORY_CUSTOM = "custom";
|
|
26
|
+
export const CATEGORY_OVERRIDE = "override";
|
|
27
|
+
export const CATEGORY_CONSTELLATION = "constellation";
|
|
28
|
+
|
|
25
29
|
/* REST end points */
|
|
26
30
|
export const PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT = 'PRRestService/dev/v1/publish_component';
|
|
27
31
|
export const LIST_COMPONENT_SERVICE_REST_ENDPOINT = 'PRRestService/dev/v1/list_component';
|
|
@@ -225,7 +229,7 @@ export const COMPONENT_SCHEMA = {
|
|
|
225
229
|
},
|
|
226
230
|
{
|
|
227
231
|
name: 'Radio Buttons',
|
|
228
|
-
value: '
|
|
232
|
+
value: 'RadioButtons'
|
|
229
233
|
},
|
|
230
234
|
{
|
|
231
235
|
name: 'Semantic Link',
|
|
@@ -312,8 +316,8 @@ export const COMPONENT_SCHEMA = {
|
|
|
312
316
|
value: 'DeferLoad'
|
|
313
317
|
},
|
|
314
318
|
{
|
|
315
|
-
name: 'Error
|
|
316
|
-
value: '
|
|
319
|
+
name: 'Error Boundary',
|
|
320
|
+
value: 'ErrorBoundary'
|
|
317
321
|
},
|
|
318
322
|
{
|
|
319
323
|
name: 'Multi Step',
|
|
@@ -493,7 +497,7 @@ export const COMPONENT_SCHEMA = {
|
|
|
493
497
|
widgets: [
|
|
494
498
|
{
|
|
495
499
|
name: 'App Announcement',
|
|
496
|
-
value: '
|
|
500
|
+
value: 'AppAnnouncement'
|
|
497
501
|
},
|
|
498
502
|
{
|
|
499
503
|
name: 'Case History',
|
|
@@ -12,31 +12,13 @@ import {
|
|
|
12
12
|
getComponents,
|
|
13
13
|
getComponentsObj,
|
|
14
14
|
getPegaServerConfig,
|
|
15
|
-
validateRulesetVersion
|
|
15
|
+
validateRulesetVersion,
|
|
16
|
+
getOptionsCategory,
|
|
16
17
|
} from '../../util.js';
|
|
17
|
-
import { PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT, TOKEN_PATH, COMPONENT_SCHEMA } from '../../constants.js';
|
|
18
|
+
import { PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT, TOKEN_PATH, COMPONENT_SCHEMA, CATEGORY_CUSTOM } from '../../constants.js';
|
|
18
19
|
|
|
19
|
-
export const getOptionsCategory = (options) => {
|
|
20
|
-
let categoryType = null;
|
|
21
|
-
if (options.params[3]) {
|
|
22
|
-
let catType = options.params[3];
|
|
23
|
-
|
|
24
|
-
switch (catType.toLowerCase()) {
|
|
25
|
-
case "override" :
|
|
26
|
-
case "o" :
|
|
27
|
-
categoryType = "override";
|
|
28
|
-
break;
|
|
29
|
-
case "custom" :
|
|
30
|
-
case "c" :
|
|
31
|
-
categoryType = "custom";
|
|
32
|
-
break;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return categoryType;
|
|
36
|
-
}
|
|
37
20
|
|
|
38
21
|
export const getBuildCategory = async (options) => {
|
|
39
|
-
const defaultPegaServerConfig = await getPegaServerConfig();
|
|
40
22
|
const categoryType = getOptionsCategory(options);
|
|
41
23
|
|
|
42
24
|
return [
|
|
@@ -83,7 +65,7 @@ export const getBuildComponentQuestions = async (category) => {
|
|
|
83
65
|
];
|
|
84
66
|
};
|
|
85
67
|
|
|
86
|
-
export const zipComponent = async (componentKey, category =
|
|
68
|
+
export const zipComponent = async (componentKey, category = CATEGORY_CUSTOM) => {
|
|
87
69
|
const srcDirectory = await getComponentDirectoryPath(componentKey, category);
|
|
88
70
|
const buildDirectory = await path.join(path.resolve(), 'dist/components', componentKey);
|
|
89
71
|
const configJson = `${srcDirectory}/config.json`;
|
|
@@ -96,7 +78,7 @@ export const zipComponent = async (componentKey, category = "custom") => {
|
|
|
96
78
|
const zipContent = zip.toBuffer().toString('base64');
|
|
97
79
|
|
|
98
80
|
const configContent = Buffer.from(fs.readFileSync(`${srcDirectory}/config.json`)).toString();
|
|
99
|
-
fs.
|
|
81
|
+
fs.rmd('dist', { recursive: true }, err => {
|
|
100
82
|
if (err) {
|
|
101
83
|
throw err;
|
|
102
84
|
}
|
package/src/tasks/build/index.js
CHANGED
|
@@ -6,8 +6,10 @@ import validate from '../validator/index.js';
|
|
|
6
6
|
|
|
7
7
|
import bundleComponent from '../bundle/index.js';
|
|
8
8
|
import lintComponent from '../linter/index.js';
|
|
9
|
-
import { getBuildComponentQuestions, getBuildCategory
|
|
10
|
-
import { getComponentDirectoryPath, showVersion } from '../../util.js';
|
|
9
|
+
import { getBuildComponentQuestions, getBuildCategory } from './helper.js';
|
|
10
|
+
import { getComponentDirectoryPath, showVersion, getOptionsCategory } from '../../util.js';
|
|
11
|
+
|
|
12
|
+
import { CATEGORY_CUSTOM } from '../../constants.js';
|
|
11
13
|
|
|
12
14
|
export default async options => {
|
|
13
15
|
showVersion();
|
|
@@ -28,7 +30,45 @@ export default async options => {
|
|
|
28
30
|
...answers
|
|
29
31
|
};
|
|
30
32
|
|
|
31
|
-
const
|
|
33
|
+
const customTasks = new Listr(
|
|
34
|
+
[
|
|
35
|
+
{
|
|
36
|
+
title: 'Validate config schema',
|
|
37
|
+
task: async () => {
|
|
38
|
+
await validate(componentKey, category);
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
title: 'Lint component',
|
|
43
|
+
task: async () => {
|
|
44
|
+
const targetDirectory = await getComponentDirectoryPath(componentKey, category);
|
|
45
|
+
// console.log(`in buildComponent Lint component task: componentKey: ${componentKey} targetDirectory: ${targetDirectory}`);
|
|
46
|
+
await lintComponent(targetDirectory);
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
title: 'Bundle component',
|
|
51
|
+
task: async () => await bundleComponent(componentKey, sourceMap, devBuild, category),
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
title: 'Lint companion component',
|
|
55
|
+
task: async () => {
|
|
56
|
+
const targetDirectory = await getComponentDirectoryPath(componentKey, "constellation");
|
|
57
|
+
// console.log(`in buildComponent Lint component task: componentKey: ${componentKey} targetDirectory: ${targetDirectory}`);
|
|
58
|
+
await lintComponent(targetDirectory);
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
title: 'Bundle companion component',
|
|
63
|
+
task: async () => await bundleComponent(componentKey, sourceMap, devBuild, "constellation")
|
|
64
|
+
}
|
|
65
|
+
],
|
|
66
|
+
{
|
|
67
|
+
exitOnError: true
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
const overrideTasks = new Listr(
|
|
32
72
|
[
|
|
33
73
|
{
|
|
34
74
|
title: 'Validate config schema',
|
|
@@ -47,7 +87,6 @@ export default async options => {
|
|
|
47
87
|
{
|
|
48
88
|
title: 'Bundle Component',
|
|
49
89
|
task: async () => await bundleComponent(componentKey, sourceMap, devBuild, category),
|
|
50
|
-
skip: () => (options.skipBundle ? 'Skipped bundling component' : undefined)
|
|
51
90
|
}
|
|
52
91
|
],
|
|
53
92
|
{
|
|
@@ -55,8 +94,16 @@ export default async options => {
|
|
|
55
94
|
}
|
|
56
95
|
);
|
|
57
96
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
97
|
+
if (category == CATEGORY_CUSTOM) {
|
|
98
|
+
await customTasks.run().catch(err => {
|
|
99
|
+
console.log(chalk.bold.red(err.toString()));
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
await overrideTasks.run().catch(err => {
|
|
104
|
+
console.log(chalk.bold.red(err.toString()));
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
|
|
61
108
|
return true;
|
|
62
109
|
};
|
|
@@ -2,14 +2,14 @@ import path from 'path';
|
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import { stat } from 'fs/promises';
|
|
4
4
|
|
|
5
|
-
import { BUILD_CONFIG_JSON_FILENAME } from '../../constants.js';
|
|
5
|
+
import { BUILD_CONFIG_JSON_FILENAME, CATEGORY_CUSTOM } from '../../constants.js';
|
|
6
6
|
import { getComponentDirectoryPath } from '../../util.js';
|
|
7
7
|
|
|
8
8
|
import buildComponent from './builder/index.js';
|
|
9
9
|
|
|
10
10
|
const extensions = ['ts', 'tsx', 'js', 'jsx'];
|
|
11
11
|
|
|
12
|
-
const bundleComponent = async (componentKey, sourceMap, devBuild, category =
|
|
12
|
+
const bundleComponent = async (componentKey, sourceMap, devBuild, category = CATEGORY_CUSTOM) => {
|
|
13
13
|
const componentDirectory = await getComponentDirectoryPath(componentKey, category);
|
|
14
14
|
|
|
15
15
|
const idx = (
|
|
@@ -9,6 +9,7 @@ import ncp from 'ncp';
|
|
|
9
9
|
import chalk from 'chalk';
|
|
10
10
|
|
|
11
11
|
import { checkPathAccess, getTokenUrl, showVersion } from '../../util.js';
|
|
12
|
+
import { CATEGORY_CONSTELLATION } from '../../constants.js';
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
export const DXCB_CONFIG_JSON_FILENAME = 'dxcb.config.json';
|
|
@@ -21,6 +22,7 @@ import {
|
|
|
21
22
|
convertIntoPascalCase,
|
|
22
23
|
compileMustacheTemplate,
|
|
23
24
|
getComponentDirectoryPath,
|
|
25
|
+
getPegaConfig,
|
|
24
26
|
getComponents,
|
|
25
27
|
getComponentDefaults,
|
|
26
28
|
sanitize,
|
|
@@ -44,7 +46,7 @@ const copyComponentTemplate = async options => {
|
|
|
44
46
|
|
|
45
47
|
};
|
|
46
48
|
|
|
47
|
-
const compileMustacheTemplates = async (
|
|
49
|
+
export const compileMustacheTemplates = async (
|
|
48
50
|
componentDirectory,
|
|
49
51
|
{
|
|
50
52
|
componentKey,
|
|
@@ -156,7 +158,13 @@ const validateCompile = async (
|
|
|
156
158
|
|
|
157
159
|
framework = internalData.sdkType;
|
|
158
160
|
|
|
159
|
-
|
|
161
|
+
let pegaConfig = await getPegaConfig();
|
|
162
|
+
let templateParentDir = `./templates/${framework}`;
|
|
163
|
+
if (pegaConfig['custom-templates-path'] && pegaConfig['custom-templates-path'] != "") {
|
|
164
|
+
templateParentDir = pegaConfig['custom-templates-path'];
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const templateDir = `${templateParentDir}/${type}/${sSubType}`;
|
|
160
168
|
const templateDirectory = fileURLToPath(new URL(templateDir, import.meta.url));
|
|
161
169
|
|
|
162
170
|
const templateDirConstellation = `./templates/Constellation/${type}/${sSubType}`;
|
|
@@ -166,13 +174,13 @@ const validateCompile = async (
|
|
|
166
174
|
|
|
167
175
|
const typeLC = type.toLowerCase();
|
|
168
176
|
const targetDirectory = await getComponentDirectoryPath(join(typeLC, "/",componentKey));
|
|
169
|
-
const targetDirectoryConstellation = await getComponentDirectoryPath(join(typeLC, "/",componentKey),
|
|
177
|
+
const targetDirectoryConstellation = await getComponentDirectoryPath(join(typeLC, "/",componentKey), CATEGORY_CONSTELLATION);
|
|
170
178
|
|
|
171
179
|
const components = await getComponents(false);
|
|
172
180
|
if (components.includes(componentKey)) {
|
|
173
181
|
console.log(chalk.red(`${componentKey} component already exists in ${targetDirectory}`));
|
|
174
182
|
|
|
175
|
-
let componentsConstellation = await getComponents(false,
|
|
183
|
+
let componentsConstellation = await getComponents(false, CATEGORY_CONSTELLATION);
|
|
176
184
|
if (components.includes(componentKey)) {
|
|
177
185
|
console.log(chalk.red(`${componentKey} companion component already exists in ${targetDirectoryConstellation}`));
|
|
178
186
|
}
|
|
@@ -180,7 +188,7 @@ const validateCompile = async (
|
|
|
180
188
|
return;
|
|
181
189
|
}
|
|
182
190
|
// test for constellation
|
|
183
|
-
const componentsConstellation = await getComponents(false,
|
|
191
|
+
const componentsConstellation = await getComponents(false, CATEGORY_CONSTELLATION);
|
|
184
192
|
if (components.includes(componentKey)) {
|
|
185
193
|
console.log(chalk.red(`${componentKey} companion component already exists in ${targetDirectoryConstellation}`));
|
|
186
194
|
return;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { withKnobs } from '@storybook/addon-knobs';
|
|
3
|
+
|
|
4
|
+
import { configProps, stateProps } from './mock.stories';
|
|
5
|
+
|
|
6
|
+
import {{COMPONENT_CLASS_NAME}} from './index';
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
title: '{{COMPONENT_CLASS_NAME}}',
|
|
10
|
+
decorators: [withKnobs],
|
|
11
|
+
component: {{COMPONENT_CLASS_NAME}}
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const base{{COMPONENT_CLASS_NAME}} = () => {
|
|
15
|
+
const [value, setValue] = useState(configProps.value);
|
|
16
|
+
|
|
17
|
+
const props = {
|
|
18
|
+
value,
|
|
19
|
+
label: configProps.label,
|
|
20
|
+
helperText: configProps.helperText,
|
|
21
|
+
caption: configProps.caption,
|
|
22
|
+
validatemessage: configProps.validatemessage,
|
|
23
|
+
hideLabel: configProps.hideLabel,
|
|
24
|
+
testId: configProps.testId,
|
|
25
|
+
additionalProps: configProps.additionalProps,
|
|
26
|
+
displayMode: configProps.displayMode,
|
|
27
|
+
variant: configProps.variant,
|
|
28
|
+
trueLabel: configProps.trueLabel,
|
|
29
|
+
falseLabel: configProps.falseLabel,
|
|
30
|
+
disabled: configProps.disabled,
|
|
31
|
+
readOnly: configProps.readOnly,
|
|
32
|
+
required: configProps.required,
|
|
33
|
+
getPConnect: () => {
|
|
34
|
+
return {
|
|
35
|
+
getStateProps: () => {
|
|
36
|
+
return stateProps;
|
|
37
|
+
},
|
|
38
|
+
getActionsApi: () => {
|
|
39
|
+
return {
|
|
40
|
+
updateFieldValue: (propName, theValue) => {
|
|
41
|
+
setValue(theValue);
|
|
42
|
+
},
|
|
43
|
+
triggerFieldChange: () => { /* nothing */}
|
|
44
|
+
};
|
|
45
|
+
},
|
|
46
|
+
getValidationApi: () => {
|
|
47
|
+
return {
|
|
48
|
+
validate: () => { /* nothing */}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<>
|
|
57
|
+
<{{COMPONENT_CLASS_NAME}} {...props} />
|
|
58
|
+
</>
|
|
59
|
+
);
|
|
60
|
+
};
|
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
import PropTypes from "prop-types";
|
|
8
8
|
|
|
9
9
|
// includes in bundle
|
|
10
|
-
import { format } from "./boolean-format";
|
|
11
10
|
import handleEvent from "./event-utils";
|
|
12
11
|
|
|
13
12
|
import Styled{{COMPONENT_CLASS_NAME}}Wrapper from './styles';
|
|
@@ -70,7 +69,7 @@ const {{COMPONENT_CLASS_NAME}} = props => {
|
|
|
70
69
|
|
|
71
70
|
let displayComponent;
|
|
72
71
|
if (displayMode) {
|
|
73
|
-
displayComponent = <
|
|
72
|
+
displayComponent = <{{COMPONENT_CLASS_NAME}} value={value} trueLabel={trueLabel} falseLabel={falseLabel} />;
|
|
74
73
|
}
|
|
75
74
|
|
|
76
75
|
if (displayMode === 'DISPLAY_ONLY') {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export const configProps = {
|
|
2
|
+
value: true,
|
|
3
|
+
label: 'Boolean label',
|
|
4
|
+
helperText: 'Test helper text',
|
|
5
|
+
caption: 'Boolean caption',
|
|
6
|
+
validatemessage: '',
|
|
7
|
+
hideLabel: false,
|
|
8
|
+
testId: '12345678',
|
|
9
|
+
additionalProps: {},
|
|
10
|
+
displayMode: '',
|
|
11
|
+
variant: '',
|
|
12
|
+
trueLabel: 'True',
|
|
13
|
+
falseLabel: 'False',
|
|
14
|
+
disabled: false,
|
|
15
|
+
readOnly: false,
|
|
16
|
+
required: true
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const stateProps = {
|
|
20
|
+
value: '.Test'
|
|
21
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import dayjs from 'dayjs';
|
|
2
|
+
import relativeTime from 'dayjs/plugin/relativeTime';
|
|
3
|
+
import localizedFormat from 'dayjs/plugin/localizedFormat';
|
|
4
|
+
import utc from 'dayjs/plugin/utc';
|
|
5
|
+
import tzone from 'dayjs/plugin/timezone';
|
|
6
|
+
|
|
7
|
+
dayjs.extend(relativeTime);
|
|
8
|
+
dayjs.extend(localizedFormat);
|
|
9
|
+
dayjs.extend(utc);
|
|
10
|
+
dayjs.extend(tzone);
|
|
11
|
+
|
|
12
|
+
const types = ['fromNow', 'customFormat'];
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
// value should be in ISO 8601 format.
|
|
17
|
+
function DateFormatter(
|
|
18
|
+
value,
|
|
19
|
+
{ type = types[1], format = "DD/MM/YYYY", timezone } = {}
|
|
20
|
+
) {
|
|
21
|
+
if (!value) return value;
|
|
22
|
+
switch (type) {
|
|
23
|
+
case types[1]:
|
|
24
|
+
if (timezone) return dayjs(value).tz(timezone).format(format);
|
|
25
|
+
return dayjs(value).format(format);
|
|
26
|
+
case types[0]:
|
|
27
|
+
return dayjs(value).from(dayjs());
|
|
28
|
+
default:
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// value should be in hh:mm:ss format (00:00:00 - 23:59:59).
|
|
34
|
+
function TimeFormatter(value, options) {
|
|
35
|
+
if (!value) return value;
|
|
36
|
+
const { locale = "en-US" } = options;
|
|
37
|
+
const timeOnlyRegex = /^(?:[01]\d|2[0123]):(?:[012345]\d):(?:[012345]\d)$/;
|
|
38
|
+
if (value.length === 8 && timeOnlyRegex.test(value)) {
|
|
39
|
+
const tempDate = new Date();
|
|
40
|
+
const hours = parseInt(value.substr(0, 2), 10);
|
|
41
|
+
const minutes = parseInt(value.substr(3, 2), 10);
|
|
42
|
+
const seconds = parseInt(value.substr(6, 2), 10);
|
|
43
|
+
tempDate.setHours(hours);
|
|
44
|
+
tempDate.setMinutes(minutes);
|
|
45
|
+
tempDate.setSeconds(seconds);
|
|
46
|
+
return tempDate.toLocaleTimeString(locale);
|
|
47
|
+
}
|
|
48
|
+
return DateFormatter(value, options);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export default {
|
|
52
|
+
Date: (value, options) => DateFormatter(value, { type: 'customFormat', ...options }),
|
|
53
|
+
'Date-Time-Default': (value, options) =>
|
|
54
|
+
DateFormatter(value, { ...options, type: 'customFormat', format: 'lll' }),
|
|
55
|
+
'Time-Default': (value, options) =>
|
|
56
|
+
TimeFormatter(value, {
|
|
57
|
+
...options,
|
|
58
|
+
type: 'customFormat',
|
|
59
|
+
format: 'hh:mm A'
|
|
60
|
+
})
|
|
61
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { FieldValueList } from '@pega/cosmos-react-core';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
|
|
4
|
+
import { format } from './date.js';
|
|
5
|
+
|
|
6
|
+
export default function FormattedText(props) {
|
|
7
|
+
const { formatType, label, value, testId, hideLabel, variant, additionalProps } = props;
|
|
8
|
+
|
|
9
|
+
let text = value;
|
|
10
|
+
|
|
11
|
+
text = format(text, formatType, additionalProps);
|
|
12
|
+
|
|
13
|
+
const fields = [
|
|
14
|
+
{
|
|
15
|
+
id: label.toLowerCase(),
|
|
16
|
+
name: hideLabel ? '' : label,
|
|
17
|
+
value: text
|
|
18
|
+
}
|
|
19
|
+
];
|
|
20
|
+
return <FieldValueList variant={variant} fields={fields} data-testid={testId} />;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
FormattedText.defaultProps = {
|
|
24
|
+
formatType: 'none',
|
|
25
|
+
variant: 'stacked',
|
|
26
|
+
value: undefined,
|
|
27
|
+
label: '',
|
|
28
|
+
testId: null,
|
|
29
|
+
hideLabel: false,
|
|
30
|
+
additionalProps: {}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
FormattedText.propTypes = {
|
|
34
|
+
formatType: PropTypes.string,
|
|
35
|
+
variant: PropTypes.oneOf(['inline', 'stacked']),
|
|
36
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.bool]),
|
|
37
|
+
label: PropTypes.string,
|
|
38
|
+
testId: PropTypes.string,
|
|
39
|
+
additionalProps: PropTypes.objectOf(PropTypes.any),
|
|
40
|
+
hideLabel: PropTypes.bool
|
|
41
|
+
};
|