@pega/dx-component-builder-sdk 0.1.7 → 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.
Files changed (94) hide show
  1. package/package.json +1 -1
  2. package/src/tasks/build/helper.js +1 -1
  3. package/src/tasks/create/index.js +8 -1
  4. package/src/tasks/create/templates/Constellation/Field/Boolean/boolean-format.js.mustache +1 -1
  5. package/src/tasks/create/templates/Constellation/Field/Boolean/demo.stories.jsx.mustache +60 -0
  6. package/src/tasks/create/templates/Constellation/Field/Boolean/index.jsx.mustache +1 -2
  7. package/src/tasks/create/templates/Constellation/Field/Boolean/mock.stories.js.mustache +21 -0
  8. package/src/tasks/create/templates/Constellation/Field/Date/DateFormatter.js.mustache +61 -0
  9. package/src/tasks/create/templates/Constellation/Field/Date/FormattedText.jsx.mustache +41 -0
  10. package/src/tasks/create/templates/Constellation/Field/Date/date.js.mustache +179 -67
  11. package/src/tasks/create/templates/Constellation/Field/Date/demo.stories.jsx.mustache +40 -16
  12. package/src/tasks/create/templates/Constellation/Field/Date/index.jsx.mustache +3 -1
  13. package/src/tasks/create/templates/Constellation/Field/Date/mock.stories.js.mustache +23 -0
  14. package/src/tasks/create/templates/Constellation/Field/DateTime/date-time.js.mustache +0 -1
  15. package/src/tasks/create/templates/Constellation/Field/DateTime/{date-utils.js → date-utils.js.mustache} +1 -0
  16. package/src/tasks/create/templates/Constellation/Field/DateTime/date.js.mustache +1 -0
  17. package/src/tasks/create/templates/Constellation/Field/DateTime/demo.stories.jsx.mustache +40 -15
  18. package/src/tasks/create/templates/Constellation/Field/DateTime/index.jsx.mustache +2 -0
  19. package/src/tasks/create/templates/Constellation/Field/DateTime/mock.stories.js.mustache +23 -0
  20. package/src/tasks/create/templates/Constellation/Field/Decimal/demo.stories.jsx.mustache +22 -17
  21. package/src/tasks/create/templates/Constellation/Field/Decimal/index.jsx.mustache +2 -1
  22. package/src/tasks/create/templates/Constellation/Field/Decimal/mock.stories.js.mustache +21 -0
  23. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/demo.stories.jsx.mustache +25 -17
  24. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/index.jsx.mustache +3 -4
  25. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/mock.stories.js.mustache +23 -0
  26. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/demo.stories.jsx.mustache +22 -17
  27. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/index.jsx.mustache +8 -2
  28. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/mock.stories.js.mustache +21 -0
  29. package/src/tasks/create/templates/Constellation/Field/Integer/demo.stories.jsx.mustache +22 -17
  30. package/src/tasks/create/templates/Constellation/Field/Integer/index.jsx.mustache +2 -1
  31. package/src/tasks/create/templates/Constellation/Field/Integer/mock.stories.js.mustache +21 -0
  32. package/src/tasks/create/templates/Constellation/Field/Picklist/demo.stories.jsx.mustache +42 -14
  33. package/src/tasks/create/templates/Constellation/Field/Picklist/index.jsx.mustache +44 -1
  34. package/src/tasks/create/templates/Constellation/Field/Picklist/mock.stories.js.mustache +67 -0
  35. package/src/tasks/create/templates/Constellation/Field/Text/demo.stories.jsx.mustache +21 -16
  36. package/src/tasks/create/templates/Constellation/Field/Text/mock.stories.js.mustache +13 -0
  37. package/src/tasks/create/templates/Constellation/Field/Text-Email/demo.stories.jsx.mustache +20 -16
  38. package/src/tasks/create/templates/Constellation/Field/Text-Email/index.jsx.mustache +44 -2
  39. package/src/tasks/create/templates/Constellation/Field/Text-Email/mock.stories.js.mustache +22 -0
  40. package/src/tasks/create/templates/Constellation/Field/Text-Input/{StatusWork.js → StatusWork.jsx} +0 -1
  41. package/src/tasks/create/templates/Constellation/Field/Text-Input/demo.stories.jsx.mustache +21 -17
  42. package/src/tasks/create/templates/Constellation/Field/Text-Input/index.jsx.mustache +46 -3
  43. package/src/tasks/create/templates/Constellation/Field/Text-Input/mock.stories.js.mustache +21 -0
  44. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/demo.stories.jsx.mustache +21 -17
  45. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/index.jsx.mustache +44 -2
  46. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/mock.stories.js.mustache +20 -0
  47. package/src/tasks/create/templates/Constellation/Field/Text-Phone/demo.stories.jsx.mustache +19 -17
  48. package/src/tasks/create/templates/Constellation/Field/Text-Phone/index.jsx.mustache +46 -2
  49. package/src/tasks/create/templates/Constellation/Field/Text-Phone/mock.stories.js.mustache +37 -0
  50. package/src/tasks/create/templates/Constellation/Field/Text-URL/demo.stories.jsx.mustache +19 -17
  51. package/src/tasks/create/templates/Constellation/Field/Text-URL/index.jsx.mustache +174 -3
  52. package/src/tasks/create/templates/Constellation/Field/Text-URL/mock.stories.js.mustache +22 -0
  53. package/src/tasks/create/templates/Constellation/Field/TimeofDay/demo.stories.jsx.mustache +24 -16
  54. package/src/tasks/create/templates/Constellation/Field/TimeofDay/mock.stories.js.mustache +20 -0
  55. package/src/tasks/create/templates/Constellation/Field/TimeofDay/time-of-day.js.mustache +1 -0
  56. package/src/tasks/create/templates/Constellation/Template/DETAILS/StatusWork.jsx.mustache +26 -0
  57. package/src/tasks/create/templates/Constellation/Template/DETAILS/demo.stories.jsx.mustache +110 -0
  58. package/src/tasks/create/templates/Constellation/Template/DETAILS/index.jsx.mustache +3 -5
  59. package/src/tasks/create/templates/Constellation/Template/DETAILS/mock.stories.js.mustache +179 -0
  60. package/src/tasks/create/templates/Constellation/Template/DETAILS/utils.js.mustache +3 -6
  61. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/StatusWork.jsx.mustache +26 -0
  62. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/demo.stories.jsx.mustache +118 -0
  63. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/index.jsx.mustache +3 -5
  64. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/mock.stories.js.mustache +215 -0
  65. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/utils.js.mustache +3 -3
  66. package/src/tasks/create/templates/Constellation/Template/FORM/demo.stories.jsx.mustache +89 -0
  67. package/src/tasks/create/templates/Constellation/Template/FORM/index.jsx.mustache +6 -10
  68. package/src/tasks/create/templates/Constellation/Template/FORM/mock.stories.js.mustache +125 -0
  69. package/src/tasks/create/templates/Constellation/Template/FORM-region/demo.stories.jsx.mustache +100 -0
  70. package/src/tasks/create/templates/Constellation/Template/FORM-region/index.jsx.mustache +5 -11
  71. package/src/tasks/create/templates/Constellation/Template/FORM-region/mock.stories.js.mustache +131 -0
  72. package/src/tasks/create/templates/Constellation/Template/PAGE/{GetNextWork.js.mustache → GetNextWork.jsx.mustache} +6 -0
  73. package/src/tasks/create/templates/Constellation/Template/PAGE/demo.stories.jsx.mustache +102 -0
  74. package/src/tasks/create/templates/Constellation/Template/PAGE/index.jsx.mustache +9 -7
  75. package/src/tasks/create/templates/Constellation/Template/PAGE/mock.stories.js.mustache +94 -0
  76. package/src/tasks/create/templates/Constellation/Template/PAGE/utils.js.mustache +4 -1
  77. package/src/tasks/create/templates/Constellation/Widget/CASE/demo.stories.jsx.mustache +78 -0
  78. package/src/tasks/create/templates/Constellation/Widget/CASE/index.jsx.mustache +1 -0
  79. package/src/tasks/create/templates/Constellation/Widget/CASE/mock.stories.js.mustache +389 -0
  80. package/src/tasks/create/templates/Constellation/Widget/PAGE/demo.stories.jsx.mustache +30 -0
  81. package/src/tasks/create/templates/Constellation/Widget/PAGE/mock.stories.js.mustache +22 -0
  82. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/{Avatar.js.mustache → Avatar.jsx.mustache} +2 -0
  83. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/{Operator.js.mustache → Operator.jsx.mustache} +2 -1
  84. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/demo.stories.jsx.mustache +68 -0
  85. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/index.jsx.mustache +9 -9
  86. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/mock.stories.js.mustache +51 -0
  87. package/src/tasks/map/map.js +0 -7
  88. package/src/tasks/override/index.js +38 -9
  89. package/src/tasks/create/templates/Constellation/Field/Picklist/picklist.js.mustache +0 -43
  90. package/src/tasks/create/templates/Constellation/Field/Text-Email/text-email.js.mustache +0 -43
  91. package/src/tasks/create/templates/Constellation/Field/Text-Input/text-input.js.mustache +0 -43
  92. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/text-paragraph.js.mustache +0 -43
  93. package/src/tasks/create/templates/Constellation/Field/Text-Phone/text-phone.js.mustache +0 -43
  94. package/src/tasks/create/templates/Constellation/Field/Text-URL/text-url.js.mustache +0 -172
@@ -0,0 +1,68 @@
1
+ import { withKnobs } from '@storybook/addon-knobs';
2
+
3
+ import {{COMPONENT_CLASS_NAME}} from './index.jsx';
4
+
5
+ import { configProps, operatorDetails } from './mock.stories';
6
+
7
+ export default {
8
+ title: '{{COMPONENT_CLASS_NAME}}',
9
+ decorators: [withKnobs],
10
+ component: {{COMPONENT_CLASS_NAME}}
11
+ };
12
+
13
+ if (!window.PCore) {
14
+ window.PCore = {};
15
+ }
16
+
17
+ window.PCore.getLocaleUtils = () => {
18
+ return {
19
+ getLocaleValue: value => {
20
+ return value;
21
+ }
22
+ };
23
+ };
24
+
25
+ window.PCore.getUserApi = () => {
26
+ return {
27
+ getOperatorDetails: () => {
28
+ return new Promise(resolve => {
29
+ resolve(operatorDetails);
30
+ });
31
+ }
32
+ };
33
+ };
34
+
35
+ export const base{{COMPONENT_CLASS_NAME}} = () => {
36
+
37
+ const props = {
38
+ label: configProps.label,
39
+ createLabel: configProps.createLabel,
40
+ updateLabel: configProps.updateLabel,
41
+ createOperator: configProps.createOperator,
42
+ updateOperator: configProps.updateOperator,
43
+ createDateTime: configProps.createDateTime,
44
+ updateDateTime: configProps.updateDateTime,
45
+ hideLabel: configProps.hideLabel,
46
+
47
+ getPConnect: () => {
48
+ return {
49
+ getActionsApi: () => {
50
+ return {
51
+ updateFieldValue: () => {},
52
+ triggerFieldChange: () => {}
53
+ };
54
+ },
55
+ ignoreSuggestion: () => {},
56
+ acceptSuggestion: () => {},
57
+ setInheritedProps: () => {},
58
+ resolveConfigProps: () => {}
59
+ };
60
+ }
61
+ };
62
+
63
+ return (
64
+ <>
65
+ <{{COMPONENT_CLASS_NAME}} {...props} />
66
+ </>
67
+ );
68
+ };
@@ -1,9 +1,10 @@
1
- import { Fragment, memo } from 'react';
1
+ /* eslint-disable no-nested-ternary */
2
+ import { Fragment } from 'react';
2
3
  import { DateTimeDisplay, Card, CardHeader, CardContent, Flex } from '@pega/cosmos-react-core';
3
4
  import PropTypes from 'prop-types';
4
5
 
5
6
  // includes in bundle
6
- import Operator from './Operator';
7
+ import Operator from './Operator.jsx';
7
8
 
8
9
  import Styled{{COMPONENT_CLASS_NAME}}Wrapper from './styles';
9
10
 
@@ -27,8 +28,7 @@ export default function {{COMPONENT_CLASS_NAME}}(props) {
27
28
  resolveLabel,
28
29
  resolveOperator,
29
30
  resolveDateTime,
30
- hideLabel,
31
- defVal
31
+ hideLabel
32
32
  } = props;
33
33
 
34
34
 
@@ -84,13 +84,13 @@ export default function {{COMPONENT_CLASS_NAME}}(props) {
84
84
  resolveLabel: null,
85
85
  resolveOperator: null,
86
86
  resolveDateTime: null,
87
- hideLabel: false,
88
- defVal: '––'
87
+ hideLabel: false
89
88
  };
90
89
 
91
90
  {{COMPONENT_CLASS_NAME}}.propTypes = {
92
91
  getPConnect: PropTypes.func.isRequired,
93
92
  label: PropTypes.string,
93
+ title: PropTypes.string,
94
94
  createLabel: PropTypes.string,
95
95
  updateLabel: PropTypes.string,
96
96
  resolveLabel: PropTypes.string,
@@ -105,6 +105,6 @@ export default function {{COMPONENT_CLASS_NAME}}(props) {
105
105
 
106
106
  // as objects are there in props, shallow comparision fails & re-rendering of comp happens even with
107
107
  // same key value pairs in obj. hence using custom comparison function on when to re-render
108
- //const comparisonFn = (prevProps, nextProps) => {
109
- // return prevProps.updateDateTime === nextProps.updateDateTime;
110
- //};
108
+ // const comparisonFn = (prevProps, nextProps) => {
109
+ // return prevProps.updateDateTime === nextProps.updateDateTime;
110
+ // };
@@ -0,0 +1,51 @@
1
+ export const configProps = {
2
+ label: 'Create operator',
3
+ createLabel: 'Created',
4
+ updateLabel: 'Updated',
5
+ updateDateTime: '2023-01-16T14:53:33.280Z',
6
+ createDateTime: '2023-01-16T14:53:33.198Z',
7
+ updateOperator: {
8
+ userId: 'admin@mediaco',
9
+ userName: 'admin'
10
+ },
11
+ createOperator: {
12
+ userId: 'admin@mediaco',
13
+ userName: 'admin'
14
+ },
15
+ hideLabel: true,
16
+ key: '_532zx1dah',
17
+ displayMode: 'LABELS_LEFT'
18
+ };
19
+
20
+ export const operatorDetails = {
21
+ data: {
22
+ pzLoadTime: 'January 18, 2023 10:33:19 AM EST',
23
+ pzPageNameHash: '_pa1519192551088960pz',
24
+ pyOperatorInfo: {
25
+ pyUserName: 'french DigV2',
26
+ pyPosition: '',
27
+ pyImageInsKey: '',
28
+ pySkills: [
29
+ {
30
+ pySkillName: '',
31
+ pzIndexOwnerKey: 'DATA-ADMIN-OPERATOR-ID FRENCHTEST.DIGV2',
32
+ pySkillRating: 0
33
+ }
34
+ ],
35
+ pyReportToUserName: '',
36
+ pyReportTo: '',
37
+ pyOrganization: 'DXIL',
38
+ pyTitle: '',
39
+ pyLabel: 'frenchTest.DigV2',
40
+ pyEmailAddress: 'User@DigV2',
41
+ pyTelephone: ''
42
+ }
43
+ },
44
+ status: 200,
45
+ statusText: '',
46
+ headers: {
47
+ 'content-length': '435',
48
+ 'content-type': 'application/json;charset=UTF-8'
49
+ },
50
+ request: {}
51
+ };
@@ -56,8 +56,6 @@ export const updateComponentMap = async (componentKey, category = CATEGORY_CUSTO
56
56
 
57
57
  mapData = mapDataStart.concat(importFull).concat("\n").concat(mapDataEnd);
58
58
 
59
-
60
-
61
59
  // add map
62
60
  let endMapIndex = mapData.indexOf(MAP_END_TAG);
63
61
  mapDataStart = mapData.substring(0, endMapIndex);
@@ -65,11 +63,6 @@ export const updateComponentMap = async (componentKey, category = CATEGORY_CUSTO
65
63
 
66
64
  mapData = mapDataStart.concat(" ").concat(mapFull).concat("\n").concat(mapDataEnd);
67
65
 
68
-
69
- //console.log(mapData);
70
-
71
- //console.log("update");
72
-
73
66
  fs.writeFileSync(pegaLocalComponentMapPath, mapData, { encoding: 'utf8' });
74
67
 
75
68
 
@@ -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
  }
@@ -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
- };
@@ -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
- };