@pega/dx-component-builder-sdk 0.1.8 → 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/dx-component-builder-sdk",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "Utility for building custom UI components",
5
5
  "bin": "./bin/index.js",
6
6
  "scripts": {
package/src/constants.js CHANGED
@@ -345,7 +345,11 @@ export const COMPONENT_SCHEMA = {
345
345
  },
346
346
  {
347
347
  name: 'Vertical Tabs',
348
- value: 'VerticalTabs'
348
+ value: 'VerticalTabs/VerticalTabs'
349
+ },
350
+ {
351
+ name: 'Left Align Vertical Tabs',
352
+ value: 'VerticalTabs/LeftAlignVerticalTabs'
349
353
  },
350
354
  {
351
355
  name: 'View',
@@ -365,6 +369,10 @@ export const COMPONENT_SCHEMA = {
365
369
  name: 'Case View',
366
370
  value: 'CaseView'
367
371
  },
372
+ {
373
+ name: 'Case View Actions Menu',
374
+ value: 'CaseViewActionsMenu'
375
+ },
368
376
  {
369
377
  name: 'Data Reference',
370
378
  value: 'DataReference'
@@ -505,7 +513,11 @@ export const COMPONENT_SCHEMA = {
505
513
  },
506
514
  {
507
515
  name: 'File Utility',
508
- value: 'FileUtility'
516
+ value: 'FileUtility/FileUtility'
517
+ },
518
+ {
519
+ name: 'Action Buttons For File Utility',
520
+ value: 'FileUtility/ActionButtonsForFileUtility'
509
521
  },
510
522
  {
511
523
  name: 'Followers',
@@ -24,6 +24,12 @@ const bundleComponent = async (componentKey, sourceMap, devBuild, category = CAT
24
24
 
25
25
  if (idx === -1) throw new Error('Index file not found.');
26
26
 
27
+ // remove sub folder, component goes in dist directory without it
28
+ if (componentKey.indexOf("/") >=0) {
29
+ const arKey = componentKey.split("/");
30
+ componentKey = arKey[arKey.length - 1];
31
+ }
32
+
27
33
  const inputFile = path.join(componentDirectory, `index.${extensions[idx]}`);
28
34
  const outputFile = `${componentKey}.js`;
29
35
 
@@ -1,185 +1,14 @@
1
- import { useState, useEffect, useRef, React} from "react";
2
- import { Input, FieldValueList, Text, EmailDisplay, PhoneDisplay, URLDisplay, Button, Lightbox, Image } from "@pega/cosmos-react-core";
1
+ import { useState, useEffect, useRef} from "react";
2
+ import { Input, FieldValueList, Text } from "@pega/cosmos-react-core";
3
3
  import PropTypes from "prop-types";
4
4
 
5
5
  // includes in bundle
6
+ import {formatExists,textFormatter, urlFormatter, suggestionHandler} from "./text-url";
6
7
  import handleEvent from "./event-utils";
7
8
  import { suggestionsHandler } from './suggestions-handler';
8
9
 
9
10
  import Styled{{COMPONENT_CLASS_NAME}}Wrapper from './styles';
10
11
 
11
- export const formatExists = (formatterVal) => {
12
- const formatterValues = [
13
- "TextInput",
14
- "WorkStatus",
15
- "RichText",
16
- "Email",
17
- "Phone",
18
- "URL",
19
- "Operator"
20
- ];
21
- let isformatter = false;
22
- if (formatterValues.includes(formatterVal)) {
23
- isformatter = true;
24
- }
25
- return isformatter;
26
- };
27
-
28
- const urlLabelVal = (urlLabelSelection, btnVal, urlLabel, propUrlLabel) => {
29
- if ((urlLabel !== '' || propUrlLabel !== '') && btnVal !== null) {
30
- switch (urlLabelSelection) {
31
- case 'constant': {
32
- btnVal = urlLabel;
33
- break;
34
- }
35
- case 'propertyRef': {
36
- btnVal = propUrlLabel;
37
- break;
38
- }
39
- // no default
40
- }
41
- }
42
- return btnVal;
43
- };
44
-
45
- const isImage = (url) => /\.(jpg|jpeg|png|webp|avif|gif|svg)$/.test(url);
46
-
47
- const TableImage = (imageProps) => {
48
- const { value, altText, altTextOfImage, propaltTextOfImage, urlLabelSelection, urlLabel, propUrlLabel } = imageProps;
49
- const demoButtonRef = useRef(null);
50
- let imageDisplayComp = null;
51
- const [images, setImages] = useState(null);
52
- const imgDescription = {
53
- id: 'url',
54
- name: urlLabelSelection === 'constant' ? urlLabel : propUrlLabel,
55
- description: altText === 'constant' ? altTextOfImage : propaltTextOfImage,
56
- src: value
57
- };
58
- const onClick = () => {
59
- setImages([imgDescription]);
60
- };
61
- const onItemDownload = async (id) => {
62
- const a = document.createElement('a');
63
- a.href = await fetch(images[0].src)
64
- .then((response) => {
65
- return response.blob();
66
- })
67
- .then((blob) => {
68
- return URL.createObjectURL(blob);
69
- });
70
- a.download = images?.find((image) => image.id === id)?.name ?? id;
71
- document.body.appendChild(a);
72
- a.click();
73
- document.body.removeChild(a);
74
- };
75
- let btnVal = value;
76
- btnVal = urlLabelVal(urlLabelSelection, btnVal, urlLabel, propUrlLabel);
77
- imageDisplayComp = (
78
- <React.Fragment>
79
- {btnVal !== null && (
80
- <Button ref={demoButtonRef} variant='link' compact={false} onClick={onClick} autoFocus>
81
- {btnVal}
82
- </Button>
83
- )}
84
- {images && (
85
- <Lightbox
86
- items={images}
87
- cycle={false}
88
- onAfterClose={() => {
89
- setImages(null);
90
- demoButtonRef.current?.focus();
91
- }}
92
- onItemDownload={isImage(images[0].src) ? onItemDownload : undefined}
93
- />
94
- )}
95
- </React.Fragment>
96
- );
97
- return imageDisplayComp;
98
- };
99
-
100
- export const textFormatter = (formatter,value) => {
101
- let displayComponent = null;
102
- switch(formatter){
103
- case "TextInput" : {
104
- displayComponent = value;
105
- break;
106
- }
107
- case "Email" : {
108
- displayComponent = (<EmailDisplay value={value} displayText={value} variant="link" />);
109
- break;
110
- }
111
- case "Phone" : {
112
- displayComponent = (<PhoneDisplay value={value} variant="link" />);
113
- break;
114
- }
115
- case "URL" : {
116
- displayComponent = (<URLDisplay target="_blank" value={value} displayText={value} variant="link" />);
117
- break;
118
- }
119
- // no default
120
- }
121
- return displayComponent;
122
- };
123
-
124
- /**
125
- * Returns a URL display component based on the options
126
- * @function urlFormatter
127
- * @param {string} value value
128
- * @param {object} options options for formatting
129
- * { displayAs,tableDisplayAs,isTableFormatter,altText,altTextOfImage,propaltTextOfImage,urlLabelSelection, urlLabel,propUrlLabel, widthSel, customWidth}
130
- */
131
- export const urlFormatter = (value, options) => {
132
- const {
133
- displayAs,
134
- tableDisplayAs,
135
- isTableFormatter,
136
- altText,
137
- altTextOfImage,
138
- propaltTextOfImage,
139
- urlLabelSelection,
140
- urlLabel,
141
- propUrlLabel,
142
- widthSel,
143
- customWidth
144
- } = options;
145
-
146
- let urlFormatComp = null;
147
- if (
148
- (displayAs === 'labelText' || (isTableFormatter && tableDisplayAs === 'link')) &&
149
- (urlLabel !== '' || propUrlLabel !== '')
150
- ) {
151
- urlFormatComp = (
152
- <URLDisplay
153
- target='_blank'
154
- value={value}
155
- displayText={urlLabelSelection === 'constant' ? urlLabel : propUrlLabel}
156
- variant='link'
157
- />
158
- );
159
- } else if ((displayAs === 'Image' || tableDisplayAs === 'Image') && !!value) {
160
- if (isTableFormatter) {
161
- urlFormatComp = TableImage({
162
- value,
163
- altText,
164
- altTextOfImage,
165
- propaltTextOfImage,
166
- urlLabelSelection,
167
- urlLabel,
168
- propUrlLabel
169
- });
170
- } else {
171
- const width = widthSel === 'widthpx' ? customWidth : null;
172
- urlFormatComp = (
173
- <Image src={value} width={width} alt={altText === 'constant' ? altTextOfImage : propaltTextOfImage} />
174
- );
175
- }
176
- } else {
177
- urlFormatComp = <URLDisplay target='_blank' value={value} displayText={value} variant='link' />;
178
- }
179
- return urlFormatComp;
180
- };
181
-
182
-
183
12
 
184
13
  // Duplicated runtime code from Constellation Design System Component
185
14
 
@@ -0,0 +1,172 @@
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
+ };
@@ -3,7 +3,7 @@ import chalk from 'chalk';
3
3
 
4
4
  export const lintComponent = async (dirToLint) => {
5
5
  // console.log("in dx-component-builder-sdk: lintComponent - dirToLint: " + dirToLint);
6
- console.log(chalk.green(` linting ${dirToLint}`));
6
+ //console.log(chalk.green(` linting ${dirToLint}`));
7
7
 
8
8
  // 1. Create an instance.
9
9
  const eslint = new ESLint();
@@ -20,7 +20,7 @@ export const lintComponent = async (dirToLint) => {
20
20
  console.log(resultText);
21
21
 
22
22
  // Indicate linting is complete
23
- console.log(chalk.green(` linting complete...`));
23
+ //console.log(chalk.green(` linting complete...`));
24
24
  };
25
25
 
26
26
  // inpsired by https://eslint.org/docs/latest/developer-guide/nodejs-api
@@ -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`;