@pega/custom-dx-components 2.0.16 → 2.0.17

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 (117) hide show
  1. package/package.json +2 -2
  2. package/src/cli.js +18 -0
  3. package/src/tasks/authenticate/index.js +3 -1
  4. package/src/tasks/build/helper.js +123 -0
  5. package/src/tasks/build/index.js +54 -0
  6. package/src/tasks/{publish/bundle → bundle}/builder/index.js +0 -0
  7. package/src/tasks/{publish/bundle → bundle}/builder/modules.js +0 -0
  8. package/src/tasks/{publish/bundle → bundle}/builder/paths.js +0 -0
  9. package/src/tasks/{publish/bundle → bundle}/builder/webpack.config.js +0 -2
  10. package/src/tasks/{publish/bundle → bundle}/index.js +2 -2
  11. package/src/tasks/create/index.js +6 -3
  12. package/src/tasks/create/templates/Constellation/Field/Boolean/boolean-format.js.mustache +1 -1
  13. package/src/tasks/create/templates/Constellation/Field/Boolean/demo.stories.jsx.mustache +29 -18
  14. package/src/tasks/create/templates/Constellation/Field/Boolean/index.jsx.mustache +1 -2
  15. package/src/tasks/create/templates/Constellation/Field/Boolean/mock.stories.js.mustache +21 -0
  16. package/src/tasks/create/templates/Constellation/Field/Date/DateFormatter.js.mustache +61 -0
  17. package/src/tasks/create/templates/Constellation/Field/Date/FormattedText.jsx.mustache +41 -0
  18. package/src/tasks/create/templates/Constellation/Field/Date/date.js.mustache +179 -67
  19. package/src/tasks/create/templates/Constellation/Field/Date/demo.stories.jsx.mustache +40 -16
  20. package/src/tasks/create/templates/Constellation/Field/Date/index.jsx.mustache +3 -1
  21. package/src/tasks/create/templates/Constellation/Field/Date/mock.stories.js.mustache +23 -0
  22. package/src/tasks/create/templates/Constellation/Field/DateTime/date-time.js.mustache +0 -1
  23. package/src/tasks/create/templates/Constellation/Field/DateTime/{date-utils.js → date-utils.js.mustache} +1 -0
  24. package/src/tasks/create/templates/Constellation/Field/DateTime/date.js.mustache +1 -0
  25. package/src/tasks/create/templates/Constellation/Field/DateTime/demo.stories.jsx.mustache +40 -15
  26. package/src/tasks/create/templates/Constellation/Field/DateTime/index.jsx.mustache +2 -0
  27. package/src/tasks/create/templates/Constellation/Field/DateTime/mock.stories.js.mustache +23 -0
  28. package/src/tasks/create/templates/Constellation/Field/Decimal/demo.stories.jsx.mustache +22 -17
  29. package/src/tasks/create/templates/Constellation/Field/Decimal/index.jsx.mustache +2 -1
  30. package/src/tasks/create/templates/Constellation/Field/Decimal/mock.stories.js.mustache +21 -0
  31. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/demo.stories.jsx.mustache +25 -17
  32. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/index.jsx.mustache +3 -4
  33. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/mock.stories.js.mustache +23 -0
  34. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/demo.stories.jsx.mustache +22 -17
  35. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/index.jsx.mustache +8 -2
  36. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/mock.stories.js.mustache +21 -0
  37. package/src/tasks/create/templates/Constellation/Field/Integer/demo.stories.jsx.mustache +22 -17
  38. package/src/tasks/create/templates/Constellation/Field/Integer/index.jsx.mustache +2 -1
  39. package/src/tasks/create/templates/Constellation/Field/Integer/mock.stories.js.mustache +21 -0
  40. package/src/tasks/create/templates/Constellation/Field/Picklist/demo.stories.jsx.mustache +42 -14
  41. package/src/tasks/create/templates/Constellation/Field/Picklist/index.jsx.mustache +44 -1
  42. package/src/tasks/create/templates/Constellation/Field/Picklist/mock.stories.js.mustache +67 -0
  43. package/src/tasks/create/templates/Constellation/Field/Text/demo.stories.jsx.mustache +21 -16
  44. package/src/tasks/create/templates/Constellation/Field/Text/mock.stories.js.mustache +13 -0
  45. package/src/tasks/create/templates/Constellation/Field/Text-Email/demo.stories.jsx.mustache +20 -16
  46. package/src/tasks/create/templates/Constellation/Field/Text-Email/index.jsx.mustache +44 -2
  47. package/src/tasks/create/templates/Constellation/Field/Text-Email/mock.stories.js.mustache +22 -0
  48. package/src/tasks/create/templates/Constellation/Field/Text-Input/{StatusWork.js → StatusWork.jsx} +0 -1
  49. package/src/tasks/create/templates/Constellation/Field/Text-Input/demo.stories.jsx.mustache +21 -17
  50. package/src/tasks/create/templates/Constellation/Field/Text-Input/index.jsx.mustache +46 -3
  51. package/src/tasks/create/templates/Constellation/Field/Text-Input/mock.stories.js.mustache +21 -0
  52. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/demo.stories.jsx.mustache +21 -17
  53. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/index.jsx.mustache +44 -2
  54. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/mock.stories.js.mustache +20 -0
  55. package/src/tasks/create/templates/Constellation/Field/Text-Phone/demo.stories.jsx.mustache +19 -17
  56. package/src/tasks/create/templates/Constellation/Field/Text-Phone/index.jsx.mustache +46 -2
  57. package/src/tasks/create/templates/Constellation/Field/Text-Phone/mock.stories.js.mustache +37 -0
  58. package/src/tasks/create/templates/Constellation/Field/Text-URL/demo.stories.jsx.mustache +19 -17
  59. package/src/tasks/create/templates/Constellation/Field/Text-URL/index.jsx.mustache +174 -3
  60. package/src/tasks/create/templates/Constellation/Field/Text-URL/mock.stories.js.mustache +22 -0
  61. package/src/tasks/create/templates/Constellation/Field/TimeofDay/demo.stories.jsx.mustache +24 -16
  62. package/src/tasks/create/templates/Constellation/Field/TimeofDay/mock.stories.js.mustache +20 -0
  63. package/src/tasks/create/templates/Constellation/Field/TimeofDay/time-of-day.js.mustache +1 -0
  64. package/src/tasks/create/templates/Constellation/Template/DETAILS/StatusWork.jsx.mustache +26 -0
  65. package/src/tasks/create/templates/Constellation/Template/DETAILS/demo.stories.jsx.mustache +110 -0
  66. package/src/tasks/create/templates/Constellation/Template/DETAILS/index.jsx.mustache +14 -29
  67. package/src/tasks/create/templates/Constellation/Template/DETAILS/mock.stories.js.mustache +179 -0
  68. package/src/tasks/create/templates/Constellation/Template/DETAILS/utils.js.mustache +3 -77
  69. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/StatusWork.jsx.mustache +26 -0
  70. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/demo.stories.jsx.mustache +118 -0
  71. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/index.jsx.mustache +14 -29
  72. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/mock.stories.js.mustache +215 -0
  73. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/utils.js.mustache +3 -74
  74. package/src/tasks/create/templates/Constellation/Template/FORM/demo.stories.jsx.mustache +89 -0
  75. package/src/tasks/create/templates/Constellation/Template/FORM/index.jsx.mustache +6 -10
  76. package/src/tasks/create/templates/Constellation/Template/FORM/mock.stories.js.mustache +125 -0
  77. package/src/tasks/create/templates/Constellation/Template/FORM-region/demo.stories.jsx.mustache +100 -0
  78. package/src/tasks/create/templates/Constellation/Template/FORM-region/index.jsx.mustache +10 -8
  79. package/src/tasks/create/templates/Constellation/Template/FORM-region/mock.stories.js.mustache +131 -0
  80. package/src/tasks/create/templates/Constellation/Template/PAGE/{GetNextWork.js.mustache → GetNextWork.jsx.mustache} +6 -0
  81. package/src/tasks/create/templates/Constellation/Template/PAGE/demo.stories.jsx.mustache +102 -0
  82. package/src/tasks/create/templates/Constellation/Template/PAGE/index.jsx.mustache +9 -7
  83. package/src/tasks/create/templates/Constellation/Template/PAGE/mock.stories.js.mustache +94 -0
  84. package/src/tasks/create/templates/Constellation/Template/PAGE/utils.js.mustache +4 -1
  85. package/src/tasks/create/templates/Constellation/Widget/CASE/demo.stories.jsx.mustache +78 -0
  86. package/src/tasks/create/templates/Constellation/Widget/CASE/index.jsx.mustache +1 -0
  87. package/src/tasks/create/templates/Constellation/Widget/CASE/mock.stories.js.mustache +389 -0
  88. package/src/tasks/create/templates/Constellation/Widget/PAGE/demo.stories.jsx.mustache +30 -0
  89. package/src/tasks/create/templates/Constellation/Widget/PAGE/index.jsx.mustache +8 -8
  90. package/src/tasks/create/templates/Constellation/Widget/PAGE/mock.stories.js.mustache +22 -0
  91. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/{Avatar.js.mustache → Avatar.jsx.mustache} +2 -0
  92. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/{Operator.js.mustache → Operator.jsx.mustache} +2 -1
  93. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/demo.stories.jsx.mustache +68 -0
  94. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/index.jsx.mustache +9 -9
  95. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/mock.stories.js.mustache +51 -0
  96. package/src/tasks/delete/helper.js +4 -0
  97. package/src/tasks/delete/index.js +4 -0
  98. package/src/tasks/delete-all/helper.js +175 -0
  99. package/src/tasks/delete-all/index.js +49 -0
  100. package/src/tasks/index.js +3 -0
  101. package/src/tasks/init/index.js +1 -1
  102. package/src/tasks/init/template/.eslintignore +8 -0
  103. package/src/tasks/init/template/.eslintrc.json +186 -5
  104. package/src/tasks/init/template/package.json.mustache +19 -4
  105. package/src/tasks/init/template/tasks.config.json +1 -0
  106. package/src/tasks/linter/index.js +46 -0
  107. package/src/tasks/list/index.js +4 -0
  108. package/src/tasks/publish/index.js +14 -1
  109. package/src/tasks/publish-all/helper.js +139 -0
  110. package/src/tasks/publish-all/index.js +84 -0
  111. package/src/util.js +10 -0
  112. package/src/tasks/create/templates/Constellation/Field/Picklist/picklist.js.mustache +0 -43
  113. package/src/tasks/create/templates/Constellation/Field/Text-Email/text-email.js.mustache +0 -43
  114. package/src/tasks/create/templates/Constellation/Field/Text-Input/text-input.js.mustache +0 -43
  115. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/text-paragraph.js.mustache +0 -43
  116. package/src/tasks/create/templates/Constellation/Field/Text-Phone/text-phone.js.mustache +0 -43
  117. package/src/tasks/create/templates/Constellation/Field/Text-URL/text-url.js.mustache +0 -172
@@ -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
- };