@pega/dx-component-builder-sdk 0.1.7 → 0.1.9

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.
Files changed (97) hide show
  1. package/package.json +1 -1
  2. package/src/constants.js +14 -2
  3. package/src/tasks/build/helper.js +1 -1
  4. package/src/tasks/bundle/index.js +6 -0
  5. package/src/tasks/create/index.js +8 -1
  6. package/src/tasks/create/templates/Constellation/Field/Boolean/boolean-format.js.mustache +1 -1
  7. package/src/tasks/create/templates/Constellation/Field/Boolean/demo.stories.jsx.mustache +60 -0
  8. package/src/tasks/create/templates/Constellation/Field/Boolean/index.jsx.mustache +1 -2
  9. package/src/tasks/create/templates/Constellation/Field/Boolean/mock.stories.js.mustache +21 -0
  10. package/src/tasks/create/templates/Constellation/Field/Date/DateFormatter.js.mustache +61 -0
  11. package/src/tasks/create/templates/Constellation/Field/Date/FormattedText.jsx.mustache +41 -0
  12. package/src/tasks/create/templates/Constellation/Field/Date/date.js.mustache +179 -67
  13. package/src/tasks/create/templates/Constellation/Field/Date/demo.stories.jsx.mustache +40 -16
  14. package/src/tasks/create/templates/Constellation/Field/Date/index.jsx.mustache +3 -1
  15. package/src/tasks/create/templates/Constellation/Field/Date/mock.stories.js.mustache +23 -0
  16. package/src/tasks/create/templates/Constellation/Field/DateTime/date-time.js.mustache +0 -1
  17. package/src/tasks/create/templates/Constellation/Field/DateTime/{date-utils.js → date-utils.js.mustache} +1 -0
  18. package/src/tasks/create/templates/Constellation/Field/DateTime/date.js.mustache +1 -0
  19. package/src/tasks/create/templates/Constellation/Field/DateTime/demo.stories.jsx.mustache +40 -15
  20. package/src/tasks/create/templates/Constellation/Field/DateTime/index.jsx.mustache +2 -0
  21. package/src/tasks/create/templates/Constellation/Field/DateTime/mock.stories.js.mustache +23 -0
  22. package/src/tasks/create/templates/Constellation/Field/Decimal/demo.stories.jsx.mustache +22 -17
  23. package/src/tasks/create/templates/Constellation/Field/Decimal/index.jsx.mustache +2 -1
  24. package/src/tasks/create/templates/Constellation/Field/Decimal/mock.stories.js.mustache +21 -0
  25. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/demo.stories.jsx.mustache +25 -17
  26. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/index.jsx.mustache +3 -4
  27. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/mock.stories.js.mustache +23 -0
  28. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/demo.stories.jsx.mustache +22 -17
  29. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/index.jsx.mustache +8 -2
  30. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/mock.stories.js.mustache +21 -0
  31. package/src/tasks/create/templates/Constellation/Field/Integer/demo.stories.jsx.mustache +22 -17
  32. package/src/tasks/create/templates/Constellation/Field/Integer/index.jsx.mustache +2 -1
  33. package/src/tasks/create/templates/Constellation/Field/Integer/mock.stories.js.mustache +21 -0
  34. package/src/tasks/create/templates/Constellation/Field/Picklist/demo.stories.jsx.mustache +42 -14
  35. package/src/tasks/create/templates/Constellation/Field/Picklist/index.jsx.mustache +44 -1
  36. package/src/tasks/create/templates/Constellation/Field/Picklist/mock.stories.js.mustache +67 -0
  37. package/src/tasks/create/templates/Constellation/Field/Text/demo.stories.jsx.mustache +21 -16
  38. package/src/tasks/create/templates/Constellation/Field/Text/mock.stories.js.mustache +13 -0
  39. package/src/tasks/create/templates/Constellation/Field/Text-Email/demo.stories.jsx.mustache +20 -16
  40. package/src/tasks/create/templates/Constellation/Field/Text-Email/index.jsx.mustache +44 -2
  41. package/src/tasks/create/templates/Constellation/Field/Text-Email/mock.stories.js.mustache +22 -0
  42. package/src/tasks/create/templates/Constellation/Field/Text-Input/{StatusWork.js → StatusWork.jsx} +0 -1
  43. package/src/tasks/create/templates/Constellation/Field/Text-Input/demo.stories.jsx.mustache +21 -17
  44. package/src/tasks/create/templates/Constellation/Field/Text-Input/index.jsx.mustache +46 -3
  45. package/src/tasks/create/templates/Constellation/Field/Text-Input/mock.stories.js.mustache +21 -0
  46. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/demo.stories.jsx.mustache +21 -17
  47. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/index.jsx.mustache +44 -2
  48. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/mock.stories.js.mustache +20 -0
  49. package/src/tasks/create/templates/Constellation/Field/Text-Phone/demo.stories.jsx.mustache +19 -17
  50. package/src/tasks/create/templates/Constellation/Field/Text-Phone/index.jsx.mustache +46 -2
  51. package/src/tasks/create/templates/Constellation/Field/Text-Phone/mock.stories.js.mustache +37 -0
  52. package/src/tasks/create/templates/Constellation/Field/Text-URL/demo.stories.jsx.mustache +19 -17
  53. package/src/tasks/create/templates/Constellation/Field/Text-URL/mock.stories.js.mustache +22 -0
  54. package/src/tasks/create/templates/Constellation/Field/TimeofDay/demo.stories.jsx.mustache +24 -16
  55. package/src/tasks/create/templates/Constellation/Field/TimeofDay/mock.stories.js.mustache +20 -0
  56. package/src/tasks/create/templates/Constellation/Field/TimeofDay/time-of-day.js.mustache +1 -0
  57. package/src/tasks/create/templates/Constellation/Template/DETAILS/StatusWork.jsx.mustache +26 -0
  58. package/src/tasks/create/templates/Constellation/Template/DETAILS/demo.stories.jsx.mustache +110 -0
  59. package/src/tasks/create/templates/Constellation/Template/DETAILS/index.jsx.mustache +3 -5
  60. package/src/tasks/create/templates/Constellation/Template/DETAILS/mock.stories.js.mustache +179 -0
  61. package/src/tasks/create/templates/Constellation/Template/DETAILS/utils.js.mustache +3 -6
  62. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/StatusWork.jsx.mustache +26 -0
  63. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/demo.stories.jsx.mustache +118 -0
  64. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/index.jsx.mustache +3 -5
  65. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/mock.stories.js.mustache +215 -0
  66. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/utils.js.mustache +3 -3
  67. package/src/tasks/create/templates/Constellation/Template/FORM/demo.stories.jsx.mustache +89 -0
  68. package/src/tasks/create/templates/Constellation/Template/FORM/index.jsx.mustache +6 -10
  69. package/src/tasks/create/templates/Constellation/Template/FORM/mock.stories.js.mustache +125 -0
  70. package/src/tasks/create/templates/Constellation/Template/FORM-region/demo.stories.jsx.mustache +100 -0
  71. package/src/tasks/create/templates/Constellation/Template/FORM-region/index.jsx.mustache +5 -11
  72. package/src/tasks/create/templates/Constellation/Template/FORM-region/mock.stories.js.mustache +131 -0
  73. package/src/tasks/create/templates/Constellation/Template/PAGE/{GetNextWork.js.mustache → GetNextWork.jsx.mustache} +6 -0
  74. package/src/tasks/create/templates/Constellation/Template/PAGE/demo.stories.jsx.mustache +102 -0
  75. package/src/tasks/create/templates/Constellation/Template/PAGE/index.jsx.mustache +9 -7
  76. package/src/tasks/create/templates/Constellation/Template/PAGE/mock.stories.js.mustache +94 -0
  77. package/src/tasks/create/templates/Constellation/Template/PAGE/utils.js.mustache +4 -1
  78. package/src/tasks/create/templates/Constellation/Widget/CASE/demo.stories.jsx.mustache +78 -0
  79. package/src/tasks/create/templates/Constellation/Widget/CASE/index.jsx.mustache +1 -0
  80. package/src/tasks/create/templates/Constellation/Widget/CASE/mock.stories.js.mustache +389 -0
  81. package/src/tasks/create/templates/Constellation/Widget/PAGE/demo.stories.jsx.mustache +30 -0
  82. package/src/tasks/create/templates/Constellation/Widget/PAGE/mock.stories.js.mustache +22 -0
  83. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/{Avatar.js.mustache → Avatar.jsx.mustache} +2 -0
  84. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/{Operator.js.mustache → Operator.jsx.mustache} +2 -1
  85. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/demo.stories.jsx.mustache +68 -0
  86. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/index.jsx.mustache +9 -9
  87. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/mock.stories.js.mustache +51 -0
  88. package/src/tasks/linter/index.js +2 -2
  89. package/src/tasks/map/map.js +0 -7
  90. package/src/tasks/override/index.js +38 -9
  91. package/src/tasks/publish/helper.js +16 -1
  92. package/src/tasks/publish-all/helper.js +7 -0
  93. package/src/tasks/create/templates/Constellation/Field/Picklist/picklist.js.mustache +0 -43
  94. package/src/tasks/create/templates/Constellation/Field/Text-Email/text-email.js.mustache +0 -43
  95. package/src/tasks/create/templates/Constellation/Field/Text-Input/text-input.js.mustache +0 -43
  96. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/text-paragraph.js.mustache +0 -43
  97. package/src/tasks/create/templates/Constellation/Field/Text-Phone/text-phone.js.mustache +0 -43
@@ -10,7 +10,7 @@ import ncp from 'ncp';
10
10
  import chalk from 'chalk';
11
11
  import { updateComponentMap } from '../map/map.js';
12
12
 
13
- import { checkPathAccess, getTokenUrl, showVersion, getDirectoryFiles } from '../../util.js';
13
+ import { checkPathAccess, getTokenUrl, showVersion, getDirectoryFiles, getPegaConfig } from '../../util.js';
14
14
  import {
15
15
  convertIntoPascalCase,
16
16
  compileMustacheTemplate,
@@ -39,9 +39,21 @@ const copyComponentTemplate = async options => {
39
39
  };
40
40
 
41
41
 
42
+ const getListAvailableComponents = async (type) => {
43
+ const components = await getComponents(false, CATEGORY_OVERRIDE);
44
+ const fullList = COMPONENT_SCHEMA.overrideComponent[type];
45
+ let availList = [];
46
+ for (var el in fullList) {
47
+ if (components.includes(fullList[el].value)) {
48
+ availList.push(new inquirer.Separator("** " + fullList[el].name));
49
+ }
50
+ else {
51
+ availList.push(fullList[el]);
52
+ }
53
+ }
42
54
 
43
-
44
-
55
+ return availList;
56
+ }
45
57
 
46
58
 
47
59
  const validateCompile = async (
@@ -52,8 +64,15 @@ const validateCompile = async (
52
64
  options
53
65
  ) => {
54
66
 
67
+ let pegaConfig =
68
+ await getPegaConfig();
69
+ let templateParentDir = "node_modules/@pega/react-sdk-overrides/lib";
70
+ if (pegaConfig['override-templates-path'] && pegaConfig['override-templates-path'] != "") {
71
+ templateParentDir = pegaConfig['override-templates-path'];
72
+ }
73
+
55
74
  // componentName has sub directory if components are in a sub directory of main "type"
56
- const overrideDirectory = `node_modules/@pega/react-sdk-overrides/lib/${type}/${componentName}`;
75
+ const overrideDirectory = `${templateParentDir}/${type}/${componentName}`;
57
76
 
58
77
  await checkPathAccess(overrideDirectory);
59
78
 
@@ -130,6 +149,11 @@ export default async options => {
130
149
  let componentDefaults = await getComponentDefaults();
131
150
  componentDefaults.library = library;
132
151
 
152
+ const formsList = await getListAvailableComponents("forms");
153
+ const desList = await getListAvailableComponents("designSystemExtensions");
154
+ const templateList = await getListAvailableComponents("templates");
155
+ const widgetList = await getListAvailableComponents("widgets");
156
+ const infraList = await getListAvailableComponents("infra");
133
157
 
134
158
  const questions = [
135
159
  {
@@ -145,7 +169,8 @@ export default async options => {
145
169
  name: 'componentName',
146
170
  type: 'rawlist',
147
171
  message: 'Enter component to be overridden',
148
- choices: COMPONENT_SCHEMA.overrideComponent.forms,
172
+ choices: formsList,
173
+ pageSize: 15,
149
174
  when(answers) {
150
175
  return answers.type === 'forms' || promptType === 'forms';
151
176
  }
@@ -154,7 +179,8 @@ export default async options => {
154
179
  name: 'componentName',
155
180
  type: 'rawlist',
156
181
  message: 'Enter component to be overridden',
157
- choices: COMPONENT_SCHEMA.overrideComponent.designSystemExtensions,
182
+ choices: desList,
183
+ pageSize: 15,
158
184
  when(answers) {
159
185
  return answers.type === 'designSystemExtensions' || promptType === 'designSystemExtensions';
160
186
  }
@@ -163,7 +189,8 @@ export default async options => {
163
189
  name: 'componentName',
164
190
  type: 'rawlist',
165
191
  message: 'Enter component to be overridden',
166
- choices: COMPONENT_SCHEMA.overrideComponent.infra,
192
+ choices: infraList,
193
+ pageSize: 15,
167
194
  when(answers) {
168
195
  return answers.type === 'infra' || promptType === 'infra';
169
196
  }
@@ -172,7 +199,8 @@ export default async options => {
172
199
  name: 'componentName',
173
200
  type: 'rawlist',
174
201
  message: 'Enter component to be overridden',
175
- choices: COMPONENT_SCHEMA.overrideComponent.templates,
202
+ choices: templateList,
203
+ pageSize: 15,
176
204
  when(answers) {
177
205
  return answers.type === 'templates' || promptType === 'templates';
178
206
  }
@@ -181,7 +209,8 @@ export default async options => {
181
209
  name: 'componentName',
182
210
  type: 'rawlist',
183
211
  message: 'Enter component to be overridden',
184
- choices: COMPONENT_SCHEMA.overrideComponent.widgets,
212
+ choices: widgetList,
213
+ pageSize: 15,
185
214
  when(answers) {
186
215
  return answers.type === 'widgets' || promptType === 'widgets';
187
216
  }
@@ -93,7 +93,15 @@ export const getPublishComponentQuestions = async (category) => {
93
93
 
94
94
  export const zipComponent = async (componentKey, category = CATEGORY_CUSTOM) => {
95
95
  const srcDirectory = await getComponentDirectoryPath(componentKey, category);
96
+
97
+ // build temp directory doesn't have sub folder
98
+ if (componentKey.indexOf("/") >=0) {
99
+ const arKey = componentKey.split("/");
100
+ componentKey = arKey[arKey.length - 1];
101
+ }
102
+
96
103
  const buildDirectory = await path.join(path.resolve(), 'dist/components', componentKey);
104
+
97
105
  const configJson = `${srcDirectory}/config.json`;
98
106
  const configExtJson = `${srcDirectory}/config-ext.json`;
99
107
 
@@ -148,7 +156,14 @@ export const zipComponent = async (componentKey, category = CATEGORY_CUSTOM) =>
148
156
  };
149
157
 
150
158
  export const publishComponentToServer = async data => {
151
- const { configContent, zipContent, componentKey, rulesetName, rulesetVersion } = data;
159
+ const { configContent, zipContent, rulesetName, rulesetVersion } = data;
160
+ let { componentKey } = data;
161
+
162
+
163
+ if (componentKey.indexOf("/") >=0) {
164
+ const arKey = componentKey.split("/");
165
+ componentKey = arKey[arKey.length - 1];
166
+ }
152
167
 
153
168
  const apiBody = {
154
169
  configContent,
@@ -87,6 +87,13 @@ export const getPublishComponentQuestions = async () => {
87
87
 
88
88
  export const zipComponent = async (componentKey, category = CATEGORY_CUSTOM) => {
89
89
  const srcDirectory = await getComponentDirectoryPath(componentKey, category);
90
+
91
+ // build temp directory doesn't have sub folder
92
+ if (componentKey.indexOf("/") >=0) {
93
+ const arKey = componentKey.split("/");
94
+ componentKey = arKey[arKey.length - 1];
95
+ }
96
+
90
97
  const buildDirectory = await path.join(path.resolve(), 'dist/components', componentKey);
91
98
  const configJson = `${srcDirectory}/config.json`;
92
99
  const configExtJson = `${srcDirectory}/config-ext.json`;
@@ -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
- };
@@ -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
- };