@pega/custom-dx-components 2.0.16 → 2.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +2 -2
- package/src/cli.js +18 -0
- package/src/tasks/authenticate/index.js +3 -1
- package/src/tasks/build/helper.js +123 -0
- package/src/tasks/build/index.js +54 -0
- package/src/tasks/{publish/bundle → bundle}/builder/index.js +0 -0
- package/src/tasks/{publish/bundle → bundle}/builder/modules.js +0 -0
- package/src/tasks/{publish/bundle → bundle}/builder/paths.js +0 -0
- package/src/tasks/{publish/bundle → bundle}/builder/webpack.config.js +0 -2
- package/src/tasks/{publish/bundle → bundle}/index.js +2 -2
- package/src/tasks/create/index.js +6 -3
- package/src/tasks/create/templates/Constellation/Field/Boolean/boolean-format.js.mustache +1 -1
- package/src/tasks/create/templates/Constellation/Field/Boolean/demo.stories.jsx.mustache +32 -16
- 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 +14 -29
- package/src/tasks/create/templates/Constellation/Template/DETAILS/mock.stories.js.mustache +179 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/utils.js.mustache +3 -77
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/StatusWork.jsx.mustache +26 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/demo.stories.jsx.mustache +118 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/index.jsx.mustache +14 -29
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/mock.stories.js.mustache +215 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/utils.js.mustache +3 -74
- package/src/tasks/create/templates/Constellation/Template/FORM/demo.stories.jsx.mustache +89 -0
- package/src/tasks/create/templates/Constellation/Template/FORM/index.jsx.mustache +6 -10
- package/src/tasks/create/templates/Constellation/Template/FORM/mock.stories.js.mustache +125 -0
- package/src/tasks/create/templates/Constellation/Template/FORM-region/demo.stories.jsx.mustache +100 -0
- package/src/tasks/create/templates/Constellation/Template/FORM-region/index.jsx.mustache +10 -8
- package/src/tasks/create/templates/Constellation/Template/FORM-region/mock.stories.js.mustache +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/index.jsx.mustache +8 -8
- package/src/tasks/create/templates/Constellation/Widget/PAGE/mock.stories.js.mustache +22 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE-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/delete/helper.js +4 -0
- package/src/tasks/delete/index.js +4 -0
- package/src/tasks/delete-all/helper.js +175 -0
- package/src/tasks/delete-all/index.js +49 -0
- package/src/tasks/index.js +3 -0
- package/src/tasks/init/index.js +1 -1
- package/src/tasks/init/template/.eslintignore +8 -0
- package/src/tasks/init/template/.eslintrc.json +186 -5
- package/src/tasks/init/template/README.md +75 -59
- package/src/tasks/init/template/package.json.mustache +20 -5
- package/src/tasks/init/template/tasks.config.json +1 -0
- package/src/tasks/linter/index.js +46 -0
- package/src/tasks/list/index.js +4 -0
- package/src/tasks/publish/index.js +14 -1
- package/src/tasks/publish-all/helper.js +139 -0
- package/src/tasks/publish-all/index.js +84 -0
- package/src/util.js +10 -0
- package/src/tasks/create/templates/Constellation/Field/Picklist/picklist.js.mustache +0 -43
- package/src/tasks/create/templates/Constellation/Field/Text-Email/text-email.js.mustache +0 -43
- package/src/tasks/create/templates/Constellation/Field/Text-Input/text-input.js.mustache +0 -43
- package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/text-paragraph.js.mustache +0 -43
- package/src/tasks/create/templates/Constellation/Field/Text-Phone/text-phone.js.mustache +0 -43
- package/src/tasks/create/templates/Constellation/Field/Text-URL/text-url.js.mustache +0 -172
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import {EmailDisplay, PhoneDisplay, URLDisplay } from "@pega/cosmos-react-core";
|
|
2
|
-
|
|
3
|
-
export const formatExists = (formatterVal) => {
|
|
4
|
-
const formatterValues = [
|
|
5
|
-
"TextInput",
|
|
6
|
-
"WorkStatus",
|
|
7
|
-
"RichText",
|
|
8
|
-
"Email",
|
|
9
|
-
"Phone",
|
|
10
|
-
"URL",
|
|
11
|
-
"Operator"
|
|
12
|
-
];
|
|
13
|
-
let isformatter = false;
|
|
14
|
-
if (formatterValues.includes(formatterVal)) {
|
|
15
|
-
isformatter = true;
|
|
16
|
-
}
|
|
17
|
-
return isformatter;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
export const textFormatter = (formatter,value) => {
|
|
22
|
-
let displayComponent = null;
|
|
23
|
-
switch(formatter){
|
|
24
|
-
case "TextInput" : {
|
|
25
|
-
displayComponent = value;
|
|
26
|
-
break;
|
|
27
|
-
}
|
|
28
|
-
case "Email" : {
|
|
29
|
-
displayComponent = (<EmailDisplay value={value} displayText={value} variant="link" />);
|
|
30
|
-
break;
|
|
31
|
-
}
|
|
32
|
-
case "Phone" : {
|
|
33
|
-
displayComponent = (<PhoneDisplay value={value} variant="link" />);
|
|
34
|
-
break;
|
|
35
|
-
}
|
|
36
|
-
case "URL" : {
|
|
37
|
-
displayComponent = (<URLDisplay target="_blank" value={value} displayText={value} variant="link" />);
|
|
38
|
-
break;
|
|
39
|
-
}
|
|
40
|
-
// no default
|
|
41
|
-
}
|
|
42
|
-
return displayComponent;
|
|
43
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import {EmailDisplay, PhoneDisplay, URLDisplay } from "@pega/cosmos-react-core";
|
|
2
|
-
|
|
3
|
-
export const formatExists = (formatterVal) => {
|
|
4
|
-
const formatterValues = [
|
|
5
|
-
"TextInput",
|
|
6
|
-
"WorkStatus",
|
|
7
|
-
"RichText",
|
|
8
|
-
"Email",
|
|
9
|
-
"Phone",
|
|
10
|
-
"URL",
|
|
11
|
-
"Operator"
|
|
12
|
-
];
|
|
13
|
-
let isformatter = false;
|
|
14
|
-
if (formatterValues.includes(formatterVal)) {
|
|
15
|
-
isformatter = true;
|
|
16
|
-
}
|
|
17
|
-
return isformatter;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
export const textFormatter = (formatter,value) => {
|
|
22
|
-
let displayComponent = null;
|
|
23
|
-
switch(formatter){
|
|
24
|
-
case "TextInput" : {
|
|
25
|
-
displayComponent = value;
|
|
26
|
-
break;
|
|
27
|
-
}
|
|
28
|
-
case "Email" : {
|
|
29
|
-
displayComponent = (<EmailDisplay value={value} displayText={value} variant="link" />);
|
|
30
|
-
break;
|
|
31
|
-
}
|
|
32
|
-
case "Phone" : {
|
|
33
|
-
displayComponent = (<PhoneDisplay value={value} variant="link" />);
|
|
34
|
-
break;
|
|
35
|
-
}
|
|
36
|
-
case "URL" : {
|
|
37
|
-
displayComponent = (<URLDisplay target="_blank" value={value} displayText={value} variant="link" />);
|
|
38
|
-
break;
|
|
39
|
-
}
|
|
40
|
-
// no default
|
|
41
|
-
}
|
|
42
|
-
return displayComponent;
|
|
43
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import {EmailDisplay, PhoneDisplay, URLDisplay } from "@pega/cosmos-react-core";
|
|
2
|
-
|
|
3
|
-
export const formatExists = (formatterVal) => {
|
|
4
|
-
const formatterValues = [
|
|
5
|
-
"TextInput",
|
|
6
|
-
"WorkStatus",
|
|
7
|
-
"RichText",
|
|
8
|
-
"Email",
|
|
9
|
-
"Phone",
|
|
10
|
-
"URL",
|
|
11
|
-
"Operator"
|
|
12
|
-
];
|
|
13
|
-
let isformatter = false;
|
|
14
|
-
if (formatterValues.includes(formatterVal)) {
|
|
15
|
-
isformatter = true;
|
|
16
|
-
}
|
|
17
|
-
return isformatter;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
export const textFormatter = (formatter,value) => {
|
|
22
|
-
let displayComponent = null;
|
|
23
|
-
switch(formatter){
|
|
24
|
-
case "TextInput" : {
|
|
25
|
-
displayComponent = value;
|
|
26
|
-
break;
|
|
27
|
-
}
|
|
28
|
-
case "Email" : {
|
|
29
|
-
displayComponent = (<EmailDisplay value={value} displayText={value} variant="link" />);
|
|
30
|
-
break;
|
|
31
|
-
}
|
|
32
|
-
case "Phone" : {
|
|
33
|
-
displayComponent = (<PhoneDisplay value={value} variant="link" />);
|
|
34
|
-
break;
|
|
35
|
-
}
|
|
36
|
-
case "URL" : {
|
|
37
|
-
displayComponent = (<URLDisplay target="_blank" value={value} displayText={value} variant="link" />);
|
|
38
|
-
break;
|
|
39
|
-
}
|
|
40
|
-
// no default
|
|
41
|
-
}
|
|
42
|
-
return displayComponent;
|
|
43
|
-
};
|
package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/text-paragraph.js.mustache
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import {EmailDisplay, PhoneDisplay, URLDisplay } from "@pega/cosmos-react-core";
|
|
2
|
-
|
|
3
|
-
export const formatExists = (formatterVal) => {
|
|
4
|
-
const formatterValues = [
|
|
5
|
-
"TextInput",
|
|
6
|
-
"WorkStatus",
|
|
7
|
-
"RichText",
|
|
8
|
-
"Email",
|
|
9
|
-
"Phone",
|
|
10
|
-
"URL",
|
|
11
|
-
"Operator"
|
|
12
|
-
];
|
|
13
|
-
let isformatter = false;
|
|
14
|
-
if (formatterValues.includes(formatterVal)) {
|
|
15
|
-
isformatter = true;
|
|
16
|
-
}
|
|
17
|
-
return isformatter;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
export const textFormatter = (formatter,value) => {
|
|
22
|
-
let displayComponent = null;
|
|
23
|
-
switch(formatter){
|
|
24
|
-
case "TextInput" : {
|
|
25
|
-
displayComponent = value;
|
|
26
|
-
break;
|
|
27
|
-
}
|
|
28
|
-
case "Email" : {
|
|
29
|
-
displayComponent = (<EmailDisplay value={value} displayText={value} variant="link" />);
|
|
30
|
-
break;
|
|
31
|
-
}
|
|
32
|
-
case "Phone" : {
|
|
33
|
-
displayComponent = (<PhoneDisplay value={value} variant="link" />);
|
|
34
|
-
break;
|
|
35
|
-
}
|
|
36
|
-
case "URL" : {
|
|
37
|
-
displayComponent = (<URLDisplay target="_blank" value={value} displayText={value} variant="link" />);
|
|
38
|
-
break;
|
|
39
|
-
}
|
|
40
|
-
// no default
|
|
41
|
-
}
|
|
42
|
-
return displayComponent;
|
|
43
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import {EmailDisplay, PhoneDisplay, URLDisplay } from "@pega/cosmos-react-core";
|
|
2
|
-
|
|
3
|
-
export const formatExists = (formatterVal) => {
|
|
4
|
-
const formatterValues = [
|
|
5
|
-
"TextInput",
|
|
6
|
-
"WorkStatus",
|
|
7
|
-
"RichText",
|
|
8
|
-
"Email",
|
|
9
|
-
"Phone",
|
|
10
|
-
"URL",
|
|
11
|
-
"Operator"
|
|
12
|
-
];
|
|
13
|
-
let isformatter = false;
|
|
14
|
-
if (formatterValues.includes(formatterVal)) {
|
|
15
|
-
isformatter = true;
|
|
16
|
-
}
|
|
17
|
-
return isformatter;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
export const textFormatter = (formatter,value) => {
|
|
22
|
-
let displayComponent = null;
|
|
23
|
-
switch(formatter){
|
|
24
|
-
case "TextInput" : {
|
|
25
|
-
displayComponent = value;
|
|
26
|
-
break;
|
|
27
|
-
}
|
|
28
|
-
case "Email" : {
|
|
29
|
-
displayComponent = (<EmailDisplay value={value} displayText={value} variant="link" />);
|
|
30
|
-
break;
|
|
31
|
-
}
|
|
32
|
-
case "Phone" : {
|
|
33
|
-
displayComponent = (<PhoneDisplay value={value} variant="link" />);
|
|
34
|
-
break;
|
|
35
|
-
}
|
|
36
|
-
case "URL" : {
|
|
37
|
-
displayComponent = (<URLDisplay target="_blank" value={value} displayText={value} variant="link" />);
|
|
38
|
-
break;
|
|
39
|
-
}
|
|
40
|
-
// no default
|
|
41
|
-
}
|
|
42
|
-
return displayComponent;
|
|
43
|
-
};
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
import {EmailDisplay, PhoneDisplay, URLDisplay } from "@pega/cosmos-react-core";
|
|
2
|
-
|
|
3
|
-
export const formatExists = (formatterVal) => {
|
|
4
|
-
const formatterValues = [
|
|
5
|
-
"TextInput",
|
|
6
|
-
"WorkStatus",
|
|
7
|
-
"RichText",
|
|
8
|
-
"Email",
|
|
9
|
-
"Phone",
|
|
10
|
-
"URL",
|
|
11
|
-
"Operator"
|
|
12
|
-
];
|
|
13
|
-
let isformatter = false;
|
|
14
|
-
if (formatterValues.includes(formatterVal)) {
|
|
15
|
-
isformatter = true;
|
|
16
|
-
}
|
|
17
|
-
return isformatter;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const urlLabelVal = (urlLabelSelection, btnVal, urlLabel, propUrlLabel) => {
|
|
21
|
-
if ((urlLabel !== '' || propUrlLabel !== '') && btnVal !== null) {
|
|
22
|
-
switch (urlLabelSelection) {
|
|
23
|
-
case 'constant': {
|
|
24
|
-
btnVal = urlLabel;
|
|
25
|
-
break;
|
|
26
|
-
}
|
|
27
|
-
case 'propertyRef': {
|
|
28
|
-
btnVal = propUrlLabel;
|
|
29
|
-
break;
|
|
30
|
-
}
|
|
31
|
-
// no default
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return btnVal;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
const isImage = (url) => /\.(jpg|jpeg|png|webp|avif|gif|svg)$/.test(url);
|
|
38
|
-
|
|
39
|
-
const TableImage = (imageProps) => {
|
|
40
|
-
const { value, altText, altTextOfImage, propaltTextOfImage, urlLabelSelection, urlLabel, propUrlLabel } = imageProps;
|
|
41
|
-
const demoButtonRef = useRef(null);
|
|
42
|
-
let imageDisplayComp = null;
|
|
43
|
-
const [images, setImages] = useState(null);
|
|
44
|
-
const imgDescription = {
|
|
45
|
-
id: 'url',
|
|
46
|
-
name: urlLabelSelection === 'constant' ? urlLabel : propUrlLabel,
|
|
47
|
-
description: altText === 'constant' ? altTextOfImage : propaltTextOfImage,
|
|
48
|
-
src: value
|
|
49
|
-
};
|
|
50
|
-
const onClick = () => {
|
|
51
|
-
setImages([imgDescription]);
|
|
52
|
-
};
|
|
53
|
-
const onItemDownload = async (id) => {
|
|
54
|
-
const a = document.createElement('a');
|
|
55
|
-
a.href = await fetch(images[0].src)
|
|
56
|
-
.then((response) => {
|
|
57
|
-
return response.blob();
|
|
58
|
-
})
|
|
59
|
-
.then((blob) => {
|
|
60
|
-
return URL.createObjectURL(blob);
|
|
61
|
-
});
|
|
62
|
-
a.download = images?.find((image) => image.id === id)?.name ?? id;
|
|
63
|
-
document.body.appendChild(a);
|
|
64
|
-
a.click();
|
|
65
|
-
document.body.removeChild(a);
|
|
66
|
-
};
|
|
67
|
-
let btnVal = value;
|
|
68
|
-
btnVal = urlLabelVal(urlLabelSelection, btnVal, urlLabel, propUrlLabel);
|
|
69
|
-
imageDisplayComp = (
|
|
70
|
-
<React.Fragment>
|
|
71
|
-
{btnVal !== null && (
|
|
72
|
-
<Button ref={demoButtonRef} variant='link' compact={false} onClick={onClick} autoFocus>
|
|
73
|
-
{btnVal}
|
|
74
|
-
</Button>
|
|
75
|
-
)}
|
|
76
|
-
{images && (
|
|
77
|
-
<Lightbox
|
|
78
|
-
items={images}
|
|
79
|
-
cycle={false}
|
|
80
|
-
onAfterClose={() => {
|
|
81
|
-
setImages(null);
|
|
82
|
-
demoButtonRef.current?.focus();
|
|
83
|
-
}}
|
|
84
|
-
onItemDownload={isImage(images[0].src) ? onItemDownload : undefined}
|
|
85
|
-
/>
|
|
86
|
-
)}
|
|
87
|
-
</React.Fragment>
|
|
88
|
-
);
|
|
89
|
-
return imageDisplayComp;
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
export const textFormatter = (formatter,value) => {
|
|
93
|
-
let displayComponent = null;
|
|
94
|
-
switch(formatter){
|
|
95
|
-
case "TextInput" : {
|
|
96
|
-
displayComponent = value;
|
|
97
|
-
break;
|
|
98
|
-
}
|
|
99
|
-
case "Email" : {
|
|
100
|
-
displayComponent = (<EmailDisplay value={value} displayText={value} variant="link" />);
|
|
101
|
-
break;
|
|
102
|
-
}
|
|
103
|
-
case "Phone" : {
|
|
104
|
-
displayComponent = (<PhoneDisplay value={value} variant="link" />);
|
|
105
|
-
break;
|
|
106
|
-
}
|
|
107
|
-
case "URL" : {
|
|
108
|
-
displayComponent = (<URLDisplay target="_blank" value={value} displayText={value} variant="link" />);
|
|
109
|
-
break;
|
|
110
|
-
}
|
|
111
|
-
// no default
|
|
112
|
-
}
|
|
113
|
-
return displayComponent;
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Returns a URL display component based on the options
|
|
118
|
-
* @function urlFormatter
|
|
119
|
-
* @param {string} value value
|
|
120
|
-
* @param {object} options options for formatting
|
|
121
|
-
* { displayAs,tableDisplayAs,isTableFormatter,altText,altTextOfImage,propaltTextOfImage,urlLabelSelection, urlLabel,propUrlLabel, widthSel, customWidth}
|
|
122
|
-
*/
|
|
123
|
-
export const urlFormatter = (value, options) => {
|
|
124
|
-
const {
|
|
125
|
-
displayAs,
|
|
126
|
-
tableDisplayAs,
|
|
127
|
-
isTableFormatter,
|
|
128
|
-
altText,
|
|
129
|
-
altTextOfImage,
|
|
130
|
-
propaltTextOfImage,
|
|
131
|
-
urlLabelSelection,
|
|
132
|
-
urlLabel,
|
|
133
|
-
propUrlLabel,
|
|
134
|
-
widthSel,
|
|
135
|
-
customWidth
|
|
136
|
-
} = options;
|
|
137
|
-
|
|
138
|
-
let urlFormatComp = null;
|
|
139
|
-
if (
|
|
140
|
-
(displayAs === 'labelText' || (isTableFormatter && tableDisplayAs === 'link')) &&
|
|
141
|
-
(urlLabel !== '' || propUrlLabel !== '')
|
|
142
|
-
) {
|
|
143
|
-
urlFormatComp = (
|
|
144
|
-
<URLDisplay
|
|
145
|
-
target='_blank'
|
|
146
|
-
value={value}
|
|
147
|
-
displayText={urlLabelSelection === 'constant' ? urlLabel : propUrlLabel}
|
|
148
|
-
variant='link'
|
|
149
|
-
/>
|
|
150
|
-
);
|
|
151
|
-
} else if ((displayAs === 'Image' || tableDisplayAs === 'Image') && !!value) {
|
|
152
|
-
if (isTableFormatter) {
|
|
153
|
-
urlFormatComp = TableImage({
|
|
154
|
-
value,
|
|
155
|
-
altText,
|
|
156
|
-
altTextOfImage,
|
|
157
|
-
propaltTextOfImage,
|
|
158
|
-
urlLabelSelection,
|
|
159
|
-
urlLabel,
|
|
160
|
-
propUrlLabel
|
|
161
|
-
});
|
|
162
|
-
} else {
|
|
163
|
-
const width = widthSel === 'widthpx' ? customWidth : null;
|
|
164
|
-
urlFormatComp = (
|
|
165
|
-
<Image src={value} width={width} alt={altText === 'constant' ? altTextOfImage : propaltTextOfImage} />
|
|
166
|
-
);
|
|
167
|
-
}
|
|
168
|
-
} else {
|
|
169
|
-
urlFormatComp = <URLDisplay target='_blank' value={value} displayText={value} variant='link' />;
|
|
170
|
-
}
|
|
171
|
-
return urlFormatComp;
|
|
172
|
-
};
|