@pega/react-sdk-overrides 0.23.6

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 (220) hide show
  1. package/lib/designSystemExtensions/CaseSummaryFields/CaseSummaryFields.css +19 -0
  2. package/lib/designSystemExtensions/CaseSummaryFields/CaseSummaryFields.tsx +156 -0
  3. package/lib/designSystemExtensions/CaseSummaryFields/index.tsx +1 -0
  4. package/lib/designSystemExtensions/DetailsFields/DetailsFields.tsx +154 -0
  5. package/lib/designSystemExtensions/DetailsFields/index.tsx +1 -0
  6. package/lib/designSystemExtensions/FieldGroup/FieldGroup.tsx +113 -0
  7. package/lib/designSystemExtensions/FieldGroup/index.tsx +1 -0
  8. package/lib/designSystemExtensions/FieldGroupList/FieldGroupList.tsx +53 -0
  9. package/lib/designSystemExtensions/FieldGroupList/index.tsx +1 -0
  10. package/lib/designSystemExtensions/FieldValueList/FieldValueList.tsx +106 -0
  11. package/lib/designSystemExtensions/FieldValueList/index.tsx +1 -0
  12. package/lib/designSystemExtensions/Operator/Operator.tsx +195 -0
  13. package/lib/designSystemExtensions/Operator/index.tsx +1 -0
  14. package/lib/designSystemExtensions/Pulse/Pulse.tsx +31 -0
  15. package/lib/designSystemExtensions/Pulse/index.tsx +1 -0
  16. package/lib/forms/AutoComplete/AutoComplete.tsx +183 -0
  17. package/lib/forms/AutoComplete/index.tsx +1 -0
  18. package/lib/forms/CancelAlert/CancelAlert.css +24 -0
  19. package/lib/forms/CancelAlert/CancelAlert.tsx +126 -0
  20. package/lib/forms/CancelAlert/index.tsx +1 -0
  21. package/lib/forms/Checkbox/Checkbox.tsx +68 -0
  22. package/lib/forms/Checkbox/index.tsx +1 -0
  23. package/lib/forms/Currency/Currency.tsx +89 -0
  24. package/lib/forms/Currency/index.tsx +1 -0
  25. package/lib/forms/Date/Date.tsx +79 -0
  26. package/lib/forms/Date/index.tsx +1 -0
  27. package/lib/forms/DateTime/DateTime.tsx +75 -0
  28. package/lib/forms/DateTime/index.tsx +1 -0
  29. package/lib/forms/Decimal/Decimal.tsx +51 -0
  30. package/lib/forms/Decimal/index.tsx +1 -0
  31. package/lib/forms/Dropdown/Dropdown.tsx +82 -0
  32. package/lib/forms/Dropdown/index.tsx +1 -0
  33. package/lib/forms/Email/Email.tsx +68 -0
  34. package/lib/forms/Email/index.tsx +1 -0
  35. package/lib/forms/Integer/Integer.tsx +77 -0
  36. package/lib/forms/Integer/index.tsx +1 -0
  37. package/lib/forms/Percentage/Percentage.tsx +82 -0
  38. package/lib/forms/Percentage/index.tsx +1 -0
  39. package/lib/forms/Phone/Phone.tsx +90 -0
  40. package/lib/forms/Phone/index.tsx +1 -0
  41. package/lib/forms/RadioButtons/RadioButtons.tsx +73 -0
  42. package/lib/forms/RadioButtons/index.tsx +1 -0
  43. package/lib/forms/SemanticLink/SemanticLink.tsx +69 -0
  44. package/lib/forms/SemanticLink/index.tsx +1 -0
  45. package/lib/forms/SemanticLink/utils.ts +51 -0
  46. package/lib/forms/TextArea/TextArea.tsx +66 -0
  47. package/lib/forms/TextArea/index.tsx +1 -0
  48. package/lib/forms/TextContent/TextContent.tsx +40 -0
  49. package/lib/forms/TextContent/index.tsx +1 -0
  50. package/lib/forms/TextInput/TextInput.tsx +61 -0
  51. package/lib/forms/TextInput/index.tsx +1 -0
  52. package/lib/forms/Time/Time.tsx +71 -0
  53. package/lib/forms/Time/index.tsx +1 -0
  54. package/lib/forms/URL/URL.tsx +53 -0
  55. package/lib/forms/URL/index.tsx +1 -0
  56. package/lib/forms/UserReference/UserReference.tsx +197 -0
  57. package/lib/forms/UserReference/UserReferenceUtils.ts +13 -0
  58. package/lib/forms/UserReference/index.tsx +1 -0
  59. package/lib/helpers/auth.js +483 -0
  60. package/lib/helpers/authManager.js +630 -0
  61. package/lib/helpers/config_access.js +268 -0
  62. package/lib/helpers/data_page.ts +24 -0
  63. package/lib/helpers/event-utils.js +20 -0
  64. package/lib/helpers/field-group-utils.js +61 -0
  65. package/lib/helpers/formatters/Boolean.js +38 -0
  66. package/lib/helpers/formatters/Currency.js +74 -0
  67. package/lib/helpers/formatters/CurrencyMap.js +908 -0
  68. package/lib/helpers/formatters/Date.js +77 -0
  69. package/lib/helpers/formatters/common.js +10 -0
  70. package/lib/helpers/formatters/index.js +120 -0
  71. package/lib/helpers/utils.ts +334 -0
  72. package/lib/helpers/versionHelpers.ts +50 -0
  73. package/lib/infra/ActionButtons/ActionButtons.tsx +70 -0
  74. package/lib/infra/ActionButtons/index.tsx +1 -0
  75. package/lib/infra/Assignment/Assignment.tsx +301 -0
  76. package/lib/infra/Assignment/index.tsx +1 -0
  77. package/lib/infra/AssignmentCard/AssignmentCard.tsx +47 -0
  78. package/lib/infra/AssignmentCard/index.tsx +1 -0
  79. package/lib/infra/Attachment/Attachment.css +18 -0
  80. package/lib/infra/Attachment/Attachment.tsx +404 -0
  81. package/lib/infra/Attachment/AttachmentUtils.js +71 -0
  82. package/lib/infra/Attachment/index.tsx +1 -0
  83. package/lib/infra/Containers/FlowContainer/FlowContainer.tsx +511 -0
  84. package/lib/infra/Containers/FlowContainer/helpers.js +147 -0
  85. package/lib/infra/Containers/FlowContainer/index.tsx +1 -0
  86. package/lib/infra/Containers/ModalViewContainer/ModalViewContainer.tsx +320 -0
  87. package/lib/infra/Containers/ModalViewContainer/index.tsx +1 -0
  88. package/lib/infra/Containers/ViewContainer/ViewContainer.tsx +216 -0
  89. package/lib/infra/Containers/ViewContainer/index.tsx +1 -0
  90. package/lib/infra/DashboardFilter/DashboardFilter.tsx +180 -0
  91. package/lib/infra/DashboardFilter/filterUtils.tsx +188 -0
  92. package/lib/infra/DashboardFilter/index.tsx +1 -0
  93. package/lib/infra/DeferLoad/DeferLoad.tsx +175 -0
  94. package/lib/infra/DeferLoad/index.tsx +1 -0
  95. package/lib/infra/ErrorBoundary/ErrorBoundary.tsx +103 -0
  96. package/lib/infra/ErrorBoundary/index.tsx +1 -0
  97. package/lib/infra/MultiStep/MultiStep.css +261 -0
  98. package/lib/infra/MultiStep/MultiStep.tsx +225 -0
  99. package/lib/infra/MultiStep/index.tsx +1 -0
  100. package/lib/infra/NavBar/NavBar.css +170 -0
  101. package/lib/infra/NavBar/NavBar.tsx +393 -0
  102. package/lib/infra/NavBar/index.tsx +1 -0
  103. package/lib/infra/Reference/Reference.tsx +58 -0
  104. package/lib/infra/Reference/index.tsx +1 -0
  105. package/lib/infra/Region/Region.tsx +17 -0
  106. package/lib/infra/Region/index.tsx +1 -0
  107. package/lib/infra/RootContainer/RootContainer.tsx +336 -0
  108. package/lib/infra/RootContainer/index.tsx +1 -0
  109. package/lib/infra/Stages/Stages.tsx +120 -0
  110. package/lib/infra/Stages/index.tsx +1 -0
  111. package/lib/infra/ToDo/ToDo.css +87 -0
  112. package/lib/infra/ToDo/ToDo.tsx +285 -0
  113. package/lib/infra/ToDo/index.tsx +1 -0
  114. package/lib/infra/VerticalTabs/LeftAlignVerticalTab.tsx +27 -0
  115. package/lib/infra/VerticalTabs/VerticalTabs.tsx +75 -0
  116. package/lib/infra/VerticalTabs/index.tsx +1 -0
  117. package/lib/infra/View/View.css +8 -0
  118. package/lib/infra/View/View.tsx +175 -0
  119. package/lib/infra/View/index.tsx +1 -0
  120. package/lib/templates/AppShell/AppShell.css +40 -0
  121. package/lib/templates/AppShell/AppShell.tsx +439 -0
  122. package/lib/templates/AppShell/index.tsx +1 -0
  123. package/lib/templates/CaseSummary/CaseSummary.tsx +50 -0
  124. package/lib/templates/CaseSummary/index.tsx +1 -0
  125. package/lib/templates/CaseView/CaseView.tsx +261 -0
  126. package/lib/templates/CaseView/CaseViewActionsMenu.tsx +73 -0
  127. package/lib/templates/CaseView/index.tsx +1 -0
  128. package/lib/templates/DataReference/DataReference.tsx +290 -0
  129. package/lib/templates/DataReference/index.tsx +1 -0
  130. package/lib/templates/DefaultForm/DefaultForm.css +25 -0
  131. package/lib/templates/DefaultForm/DefaultForm.tsx +52 -0
  132. package/lib/templates/DefaultForm/index.tsx +1 -0
  133. package/lib/templates/Details/Details/Details.tsx +35 -0
  134. package/lib/templates/Details/Details/index.tsx +1 -0
  135. package/lib/templates/Details/DetailsSubTabs/DetailsSubTabs.tsx +65 -0
  136. package/lib/templates/Details/DetailsSubTabs/index.tsx +1 -0
  137. package/lib/templates/Details/DetailsThreeColumn/DetailsThreeColumn.tsx +45 -0
  138. package/lib/templates/Details/DetailsThreeColumn/index.tsx +1 -0
  139. package/lib/templates/Details/DetailsTwoColumn/DetailsTwoColumn.tsx +43 -0
  140. package/lib/templates/Details/DetailsTwoColumn/index.tsx +1 -0
  141. package/lib/templates/FieldGroupTemplate/FieldGroupTemplate.tsx +94 -0
  142. package/lib/templates/FieldGroupTemplate/index.tsx +1 -0
  143. package/lib/templates/InlineDashboard/InlineDashboard.tsx +72 -0
  144. package/lib/templates/InlineDashboard/index.tsx +1 -0
  145. package/lib/templates/InlineDashboardPage/InlineDashboardPage.tsx +41 -0
  146. package/lib/templates/InlineDashboardPage/index.tsx +1 -0
  147. package/lib/templates/ListPage/ListPage.tsx +20 -0
  148. package/lib/templates/ListPage/index.tsx +1 -0
  149. package/lib/templates/ListView/ListView.css +10 -0
  150. package/lib/templates/ListView/ListView.tsx +1230 -0
  151. package/lib/templates/ListView/index.tsx +1 -0
  152. package/lib/templates/MultiReferenceReadOnly/MultiReferenceReadOnly.tsx +42 -0
  153. package/lib/templates/MultiReferenceReadOnly/index.tsx +1 -0
  154. package/lib/templates/NarrowWide/NarrowWide/NarrowWide.css +21 -0
  155. package/lib/templates/NarrowWide/NarrowWide/NarrowWide.tsx +35 -0
  156. package/lib/templates/NarrowWide/NarrowWide/index.tsx +1 -0
  157. package/lib/templates/NarrowWide/NarrowWideDetails/NarrowWideDetails.tsx +53 -0
  158. package/lib/templates/NarrowWide/NarrowWideDetails/index.tsx +1 -0
  159. package/lib/templates/NarrowWide/NarrowWideForm/NarrowWideForm.css +21 -0
  160. package/lib/templates/NarrowWide/NarrowWideForm/NarrowWideForm.tsx +24 -0
  161. package/lib/templates/NarrowWide/NarrowWideForm/index.tsx +1 -0
  162. package/lib/templates/NarrowWide/NarrowWidePage/NarrowWidePage.tsx +38 -0
  163. package/lib/templates/NarrowWide/NarrowWidePage/index.tsx +1 -0
  164. package/lib/templates/OneColumn/OneColumn/OneColumn.tsx +32 -0
  165. package/lib/templates/OneColumn/OneColumn/index.tsx +1 -0
  166. package/lib/templates/OneColumn/OneColumnPage/OneColumnPage.tsx +24 -0
  167. package/lib/templates/OneColumn/OneColumnPage/index.tsx +1 -0
  168. package/lib/templates/OneColumn/OneColumnTab/OneColumnTab.tsx +17 -0
  169. package/lib/templates/OneColumn/OneColumnTab/index.tsx +1 -0
  170. package/lib/templates/PromotedFilters/PromotedFilters.css +7 -0
  171. package/lib/templates/PromotedFilters/PromotedFilters.tsx +160 -0
  172. package/lib/templates/PromotedFilters/index.tsx +1 -0
  173. package/lib/templates/SimpleTable/SimpleTable/SimpleTable.tsx +28 -0
  174. package/lib/templates/SimpleTable/SimpleTable/index.tsx +1 -0
  175. package/lib/templates/SimpleTable/SimpleTableManual/SimpleTableManual.tsx +719 -0
  176. package/lib/templates/SimpleTable/SimpleTableManual/index.tsx +1 -0
  177. package/lib/templates/SimpleTable/SimpleTableSelect/SimpleTableSelect.tsx +129 -0
  178. package/lib/templates/SimpleTable/SimpleTableSelect/index.tsx +1 -0
  179. package/lib/templates/SimpleTable/helpers.ts +360 -0
  180. package/lib/templates/SingleReferenceReadOnly/SingleReferenceReadOnly.tsx +66 -0
  181. package/lib/templates/SingleReferenceReadOnly/index.tsx +1 -0
  182. package/lib/templates/SubTabs/SubTabs.tsx +65 -0
  183. package/lib/templates/SubTabs/index.tsx +1 -0
  184. package/lib/templates/SubTabs/tabUtils.ts +73 -0
  185. package/lib/templates/TwoColumn/TwoColumn/TwoColumn.css +13 -0
  186. package/lib/templates/TwoColumn/TwoColumn/TwoColumn.tsx +58 -0
  187. package/lib/templates/TwoColumn/TwoColumn/index.tsx +1 -0
  188. package/lib/templates/TwoColumn/TwoColumnPage/TwoColumnPage.tsx +25 -0
  189. package/lib/templates/TwoColumn/TwoColumnPage/index.tsx +1 -0
  190. package/lib/templates/TwoColumn/TwoColumnTab/TwoColumnTab.css +12 -0
  191. package/lib/templates/TwoColumn/TwoColumnTab/TwoColumnTab.tsx +55 -0
  192. package/lib/templates/TwoColumn/TwoColumnTab/index.tsx +1 -0
  193. package/lib/templates/WideNarrow/WideNarrow/WideNarrow.css +21 -0
  194. package/lib/templates/WideNarrow/WideNarrow/WideNarrow.tsx +35 -0
  195. package/lib/templates/WideNarrow/WideNarrow/index.tsx +1 -0
  196. package/lib/templates/WideNarrow/WideNarrowDetails/WideNarrowDetails.tsx +54 -0
  197. package/lib/templates/WideNarrow/WideNarrowDetails/index.tsx +1 -0
  198. package/lib/templates/WideNarrow/WideNarrowForm/WideNarrowForm.css +21 -0
  199. package/lib/templates/WideNarrow/WideNarrowForm/WideNarrowForm.tsx +24 -0
  200. package/lib/templates/WideNarrow/WideNarrowForm/index.tsx +1 -0
  201. package/lib/templates/WideNarrow/WideNarrowPage/WideNarrowPage.tsx +38 -0
  202. package/lib/templates/WideNarrow/WideNarrowPage/index.tsx +1 -0
  203. package/lib/templates/utils.ts +23 -0
  204. package/lib/widgets/AppAnnouncement/AppAnnouncement.tsx +67 -0
  205. package/lib/widgets/AppAnnouncement/index.tsx +1 -0
  206. package/lib/widgets/CaseHistory/CaseHistory.tsx +169 -0
  207. package/lib/widgets/CaseHistory/index.tsx +1 -0
  208. package/lib/widgets/FileUtility/ActionButtonsForFileUtil.css +27 -0
  209. package/lib/widgets/FileUtility/ActionButtonsForFileUtil.tsx +22 -0
  210. package/lib/widgets/FileUtility/FileUtility.css +117 -0
  211. package/lib/widgets/FileUtility/FileUtility.tsx +567 -0
  212. package/lib/widgets/FileUtility/index.tsx +0 -0
  213. package/lib/widgets/Followers/Followers.tsx +43 -0
  214. package/lib/widgets/Followers/index.tsx +1 -0
  215. package/lib/widgets/SummaryItem/SummaryItem.css +78 -0
  216. package/lib/widgets/SummaryItem/SummaryItem.tsx +80 -0
  217. package/lib/widgets/SummaryItem/index.tsx +1 -0
  218. package/lib/widgets/SummaryList/SummaryList.tsx +12 -0
  219. package/lib/widgets/SummaryList/index.tsx +1 -0
  220. package/package.json +14 -0
@@ -0,0 +1,180 @@
1
+ /* eslint-disable no-shadow */
2
+ /* eslint-disable @typescript-eslint/no-shadow */
3
+ /* eslint-disable operator-assignment */
4
+ import { useRef, useEffect, useState, Fragment, forwardRef } from 'react';
5
+ import PropTypes from 'prop-types';
6
+ import { v4 as uuidv4 } from 'uuid';
7
+ import { debounce } from 'throttle-debounce';
8
+ import { createFilter, combineFilters, getFormattedDate } from './filterUtils';
9
+ import { getFilterExpression } from './filterUtils';
10
+ import { TextField } from '@material-ui/core';
11
+ import React from 'react';
12
+ import DatePicker from 'react-datepicker';
13
+ import 'react-datepicker/dist/react-datepicker.css';
14
+
15
+ declare const PCore: any;
16
+
17
+ export default function DashboardFilter(props) {
18
+ const { children, name, filterProp, type, metadata, getPConnect } = props;
19
+ const { current: filterId } = useRef(uuidv4());
20
+
21
+ const [startDate, setStartDate] = useState(null);
22
+ const [endDate, setEndDate] = useState(null);
23
+
24
+ useEffect(() => {
25
+ PCore.getPubSubUtils().subscribe(
26
+ PCore.getConstants().PUB_SUB_EVENTS.EVENT_DASHBOARD_FILTER_CLEAR_ALL,
27
+ () => {
28
+ if (type === 'Dropdown') {
29
+ getPConnect().getActionsApi().updateFieldValue(filterProp, '');
30
+ } else if (type === 'RadioButtons') {
31
+ const reference = getPConnect().getFullReference() + filterProp;
32
+ const radList = document.getElementsByName(reference);
33
+ for (let i = 0; i < radList.length; i = i + 1) {
34
+ if ((radList[i] as HTMLInputElement).value === '') {
35
+ (radList[i] as HTMLInputElement).checked = true;
36
+ } else {
37
+ (radList[i] as HTMLInputElement).checked = false;
38
+ }
39
+ }
40
+ } else {
41
+ getPConnect().getActionsApi().updateFieldValue(filterProp, undefined);
42
+ if (type === 'DateTime') {
43
+ setStartDate(null);
44
+ setEndDate(null);
45
+ }
46
+ }
47
+ },
48
+ filterId,
49
+ false,
50
+ getPConnect().getContextName()
51
+ );
52
+ return function cleanup() {
53
+ PCore.getPubSubUtils().unsubscribe(
54
+ PCore.getConstants().PUB_SUB_EVENTS.EVENT_DASHBOARD_FILTER_CLEAR_ALL,
55
+ filterId,
56
+ getPConnect().getContextName()
57
+ );
58
+ };
59
+ });
60
+
61
+ const fireFilterChange = filterValue => {
62
+ const filterData = {
63
+ filterId,
64
+ filterExpression: getFilterExpression(filterValue, name, metadata)
65
+ };
66
+
67
+ PCore.getPubSubUtils().publish(
68
+ PCore.getConstants().PUB_SUB_EVENTS.EVENT_DASHBOARD_FILTER_CHANGE,
69
+ filterData
70
+ );
71
+ };
72
+
73
+ const fireFilterChangeDebounced = debounce(500, fireFilterChange);
74
+ const dateRangeChangeHandler = value => {
75
+ const { start, end } = value;
76
+
77
+ let startDate = getFormattedDate(start);
78
+ let endDate = getFormattedDate(end);
79
+
80
+ if (startDate && endDate) {
81
+ startDate = `${startDate}T00:00:00`;
82
+ endDate = `${endDate}T00:00:00`;
83
+ const startFilter = createFilter(startDate, name, 'GT');
84
+ const endFilter = createFilter(endDate, name, 'LT');
85
+
86
+ const filterData = {
87
+ filterId,
88
+ filterExpression: combineFilters([startFilter, endFilter], null)
89
+ };
90
+ PCore.getPubSubUtils().publish(
91
+ PCore.getConstants().PUB_SUB_EVENTS.EVENT_DASHBOARD_FILTER_CHANGE,
92
+ filterData
93
+ );
94
+ }
95
+ };
96
+
97
+ const renderAutoComplete = () => {
98
+ metadata.config.onRecordChange = e => {
99
+ fireFilterChange(e.id);
100
+ };
101
+ return getPConnect().createComponent(metadata);
102
+ };
103
+
104
+ const onChange = dates => {
105
+ const [start, end] = dates;
106
+ setStartDate(start);
107
+ setEndDate(end);
108
+ dateRangeChangeHandler({ start, end });
109
+ };
110
+
111
+ type TextProps = React.HTMLProps<HTMLInputElement>;
112
+
113
+ const label = metadata.config.label.substring(3);
114
+
115
+ const CustomDateInput = forwardRef<HTMLInputElement, TextProps>(
116
+ ({ value, onClick }, ref: any) => (
117
+ <TextField
118
+ label={label}
119
+ variant='outlined'
120
+ fullWidth
121
+ value={value}
122
+ size='small'
123
+ onClick={onClick}
124
+ ref={ref}
125
+ >
126
+ {value}
127
+ </TextField>
128
+ )
129
+ );
130
+
131
+ return (
132
+ <Fragment>
133
+ {type === 'DateTime' && (
134
+ <DatePicker
135
+ onChange={onChange}
136
+ startDate={startDate}
137
+ endDate={endDate}
138
+ selectsRange
139
+ enableTabLoop={false}
140
+ customInput={<CustomDateInput />}
141
+ />
142
+ )}
143
+ {type === 'AutoComplete' && (
144
+ <span
145
+ onChange={event => {
146
+ if (event && event.target && !(event.target as HTMLInputElement).value) {
147
+ fireFilterChange('ALL');
148
+ }
149
+ }}
150
+ >
151
+ {renderAutoComplete()}
152
+ </span>
153
+ )}
154
+ {children && (
155
+ <span
156
+ onChange={event => {
157
+ fireFilterChangeDebounced((event.target as HTMLInputElement).value);
158
+ }}
159
+ >
160
+ {children}
161
+ </span>
162
+ )}
163
+ </Fragment>
164
+ );
165
+ }
166
+
167
+ DashboardFilter.defaultProps = {
168
+ children: null,
169
+ type: null,
170
+ metadata: null
171
+ };
172
+
173
+ DashboardFilter.propTypes = {
174
+ getPConnect: PropTypes.func.isRequired,
175
+ children: PropTypes.object,
176
+ name: PropTypes.string.isRequired,
177
+ filterProp: PropTypes.string.isRequired,
178
+ type: PropTypes.string,
179
+ metadata: PropTypes.objectOf(PropTypes.any)
180
+ };
@@ -0,0 +1,188 @@
1
+ /* eslint-disable prefer-template */
2
+ /** This file contains various utility methods to generate filter components, regionLayout data, filter expressions, etc. */
3
+
4
+ import { Grid, Link } from '@material-ui/core';
5
+ import React from 'react';
6
+ import DashboardFilter from './DashboardFilter';
7
+
8
+ declare const PCore: any;
9
+
10
+ export const createFilter = (value, fieldId, comparator = 'EQ') => {
11
+ return {
12
+ condition: {
13
+ lhs: {
14
+ field: fieldId
15
+ },
16
+ comparator,
17
+ rhs: {
18
+ value
19
+ }
20
+ }
21
+ };
22
+ };
23
+
24
+ export const combineFilters = (filterList, existingFilters) => {
25
+ if (filterList && filterList.length) {
26
+ // Need to combine them
27
+ if (existingFilters) {
28
+ return { AND: [existingFilters, ...filterList] };
29
+ }
30
+
31
+ // No existing, just return the one(s) from the list
32
+ if (filterList.length > 1) {
33
+ return { AND: [...filterList] };
34
+ }
35
+
36
+ return filterList[0];
37
+ }
38
+
39
+ // No filter list,
40
+ return existingFilters;
41
+ };
42
+
43
+ export const createFilterComponent = (getPConnect, filterMeta, index) => {
44
+ const name = filterMeta.config.value.substring(4);
45
+ let cleanedName = name;
46
+ if (name.indexOf('.') !== -1) {
47
+ cleanedName = name.substring(name.indexOf('.') + 1);
48
+ }
49
+ let propInfo = PCore.getMetadataUtils().getPropertyMetadata(
50
+ cleanedName,
51
+ filterMeta.config.ruleClass
52
+ );
53
+ if (!propInfo) {
54
+ propInfo = PCore.getMetadataUtils().getPropertyMetadata(cleanedName);
55
+ }
56
+ const { type: propertyType } = propInfo || { type: 'Text' };
57
+ const isNumber = propertyType && (propertyType === 'Decimal' || propertyType === 'Integer');
58
+ filterMeta.isNumber = isNumber;
59
+ const { filterType, datasource } = filterMeta.config;
60
+ const type = filterType || filterMeta.type;
61
+ const filterProp = `.pyDashboardFilter${index}`;
62
+ if (type === 'DateTime') {
63
+ return (
64
+ <DashboardFilter
65
+ key={name}
66
+ getPConnect={getPConnect}
67
+ name={name}
68
+ filterProp={filterProp}
69
+ metadata={filterMeta}
70
+ type={filterMeta.type}
71
+ ></DashboardFilter>
72
+ );
73
+ }
74
+ if (datasource && datasource.fields) {
75
+ datasource.fields.key = datasource.fields.value;
76
+ }
77
+ if (filterMeta.config.listType === 'associated' && propInfo && propInfo.datasource) {
78
+ filterMeta.config.datasource = propInfo.datasource.records;
79
+ }
80
+ filterMeta.config.value = `@P ${filterProp}`;
81
+ filterMeta.type = filterMeta.config.displayAs || type;
82
+ filterMeta.config.placeholder = 'ALL';
83
+ return (
84
+ <DashboardFilter
85
+ key={name}
86
+ getPConnect={getPConnect}
87
+ name={name}
88
+ filterProp={filterProp}
89
+ metadata={filterMeta}
90
+ type={filterMeta.type}
91
+ >
92
+ {getPConnect().createComponent(filterMeta)}
93
+ </DashboardFilter>
94
+ );
95
+ };
96
+
97
+ export const buildFilterComponents = (getPConnect, allFilters) => {
98
+ const filterComponents = allFilters.children.map((filter, index) =>
99
+ createFilterComponent(getPConnect, filter, index)
100
+ );
101
+ if (filterComponents && filterComponents.length > 0) {
102
+ filterComponents.push(
103
+ <Grid>
104
+ <Link
105
+ style={{ cursor: 'pointer' }}
106
+ onClick={() => {
107
+ PCore.getPubSubUtils().publish(
108
+ PCore.getConstants().PUB_SUB_EVENTS.EVENT_DASHBOARD_FILTER_CLEAR_ALL
109
+ );
110
+ }}
111
+ >
112
+ Clear All
113
+ </Link>
114
+ </Grid>
115
+ );
116
+ }
117
+ return filterComponents;
118
+ };
119
+
120
+ export const convertDateToGMT = value => {
121
+ const { valueAsISOString: date } = value;
122
+ return date ? date.substring(0, date.indexOf('T')) : date;
123
+ };
124
+
125
+ export const getFilterExpression = (filterValue, name, metadata) => {
126
+ if (filterValue === '') {
127
+ return null;
128
+ }
129
+ let comparator = 'EQ';
130
+ if (metadata.type === 'TextInput' && !metadata.isNumber) {
131
+ comparator = 'CONTAINS';
132
+ }
133
+
134
+ if (metadata.config.filterType && metadata.config.filterType === 'RelativeDates') {
135
+ const fieldSource = metadata.config.datasource.filter(source => source.key === filterValue)[0];
136
+ const relativeDateExpression = JSON.parse(fieldSource.json);
137
+ // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
138
+ const fields = [
139
+ {
140
+ name: relativeDateExpression.condition.lhs.field,
141
+ type: 'DATE_TIME'
142
+ }
143
+ ];
144
+ return '';
145
+ }
146
+
147
+ return createFilter(filterValue, name, comparator);
148
+ };
149
+
150
+ /**
151
+ * Returns ConfigurableLayout mapped content. With pre-populated default layout configs.
152
+ * @returns {object[]} ConfigurableLayout content.
153
+ */
154
+ export function getLayoutDataFromRegion(regionData) {
155
+ const defaultLayoutConfig = {
156
+ width: 'full',
157
+ fillAvailable: true,
158
+ minWidth: [300, 'px']
159
+ };
160
+
161
+ return regionData.props
162
+ ?.getPConnect()
163
+ ?.getChildren()
164
+ ?.map((item, index) => {
165
+ const itemPConnect = item?.getPConnect();
166
+
167
+ return {
168
+ id: itemPConnect?.getComponentName()
169
+ ? `${itemPConnect.getComponentName()}--${index}`
170
+ : `item--${index}`,
171
+ content: itemPConnect?.getComponent(),
172
+ layoutConfig: {
173
+ ...defaultLayoutConfig,
174
+ ...itemPConnect?.getConfigProps().layoutConfig
175
+ }
176
+ };
177
+ });
178
+ }
179
+
180
+ export const getFormattedDate = date => {
181
+ if (!date) {
182
+ return date;
183
+ }
184
+ const formattedDate = `${date.getFullYear()}-${('0' + (date.getMonth() + 1)).slice(-2)}-${(
185
+ '0' + date.getDate()
186
+ ).slice(-2)}`;
187
+ return formattedDate;
188
+ };
@@ -0,0 +1 @@
1
+ export { default } from './DashboardFilter';
@@ -0,0 +1,175 @@
1
+ import React, { useState, useEffect, createElement } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { Box, Card, CircularProgress } from '@material-ui/core';
4
+ import { makeStyles } from '@material-ui/core/styles';
5
+
6
+ import createPConnectComponent from '@pega/react-sdk-components/lib/bridge/react_pconnect';
7
+
8
+ declare const PCore;
9
+
10
+ //
11
+ // WARNING: It is not expected that this file should be modified. It is part of infrastructure code that works with
12
+ // Redux and creation/update of Redux containers and PConnect. Modifying this code could have undesireable results and
13
+ // is totally at your own risk.
14
+ //
15
+
16
+ const useStyles = makeStyles(theme => ({
17
+ root: {
18
+ paddingRight: theme.spacing(1),
19
+ paddingLeft: theme.spacing(1),
20
+ paddingTop: theme.spacing(1),
21
+ paddingBottom: theme.spacing(1),
22
+ marginRight: theme.spacing(1),
23
+ marginLeft: theme.spacing(1),
24
+ marginTop: theme.spacing(1),
25
+ marginBottom: theme.spacing(1)
26
+ }
27
+ }));
28
+
29
+ export default function DeferLoad(props) {
30
+ const { getPConnect, name, deferLoadId, isTab } = props;
31
+ const [content, setContent] = useState<any>(null);
32
+ const [isLoading, setLoading] = useState(true);
33
+ const [currentLoadedAssignment, setCurrentLoadedAssignment] = useState("");
34
+
35
+ const classes = useStyles();
36
+
37
+ const pConnect = getPConnect();
38
+ const constants = PCore.getConstants();
39
+
40
+ const theRequestedAssignment = pConnect.getValue( PCore.getConstants().CASE_INFO.ASSIGNMENT_LABEL);
41
+ if (theRequestedAssignment !== currentLoadedAssignment) {
42
+ // console.log(`DeferLoad: currentLoadedAssignment about to change from ${currentLoadedAssignment} to ${theRequestedAssignment}`);
43
+ setCurrentLoadedAssignment(theRequestedAssignment);
44
+ }
45
+
46
+ const { CASE, PAGE, DATA } = constants.RESOURCE_TYPES;
47
+ const loadViewCaseID =
48
+ pConnect.getValue(constants.PZINSKEY) || pConnect.getValue(constants.CASE_INFO.CASE_INFO_ID);
49
+ let containerName;
50
+ let containerItemData;
51
+ const targetName = pConnect.getTarget();
52
+ if (targetName) {
53
+ containerName = PCore.getContainerUtils().getActiveContainerItemName(targetName);
54
+
55
+ containerItemData = PCore.getContainerUtils().getContainerItemData(targetName, containerName);
56
+ }
57
+
58
+ const { resourceType = CASE } = containerItemData || {
59
+ resourceType: loadViewCaseID ? CASE : PAGE
60
+ };
61
+ const isContainerPreview = /preview_[0-9]*/g.test(pConnect.getContextName());
62
+
63
+ const getViewOptions = () => ({
64
+ viewContext: resourceType,
65
+ pageClass: loadViewCaseID ? '' : pConnect.getDataObject().pyPortal.classID,
66
+ container: isContainerPreview ? 'preview' : null,
67
+ containerName: isContainerPreview ? 'preview' : null,
68
+ updateData: isContainerPreview
69
+ });
70
+
71
+ const onResponse = data => {
72
+ setLoading(false);
73
+ if (deferLoadId) {
74
+ PCore.getDeferLoadManager().start(
75
+ name,
76
+ getPConnect().getCaseInfo().getKey(),
77
+ getPConnect().getPageReference().replace('caseInfo.content', ''),
78
+ getPConnect().getContextName(),
79
+ deferLoadId
80
+ );
81
+ }
82
+
83
+ if (data && !(data.type && data.type === 'error')) {
84
+ const config = {
85
+ meta: data,
86
+ options: {
87
+ context: pConnect.getContextName(),
88
+ pageReference: pConnect.getPageReference()
89
+ }
90
+ };
91
+ const configObject = PCore.createPConnect(config);
92
+ configObject.getPConnect().setInheritedProp('displayMode', 'LABELS_LEFT');
93
+ setContent(createElement(createPConnectComponent(), configObject));
94
+ if (deferLoadId) {
95
+ PCore.getDeferLoadManager().stop(deferLoadId, getPConnect().getContextName());
96
+ }
97
+ }
98
+ };
99
+
100
+ useEffect(() => {
101
+ if (resourceType === DATA) {
102
+ // Rendering defer loaded tabs in data context
103
+ if (containerName) {
104
+ const dataContext = PCore.getStoreValue('.dataContext', 'dataInfo', containerName);
105
+ const dataContextParameters = PCore.getStoreValue(
106
+ '.dataContextParameters',
107
+ 'dataInfo',
108
+ containerName
109
+ );
110
+
111
+ getPConnect()
112
+ .getActionsApi()
113
+ .showData(name, dataContext, dataContextParameters, {
114
+ skipSemanticUrl: true,
115
+ isDeferLoaded: true
116
+ })
117
+ .then(data => {
118
+ onResponse(data);
119
+ });
120
+ } else {
121
+ // eslint-disable-next-line no-console
122
+ console.error('Cannot load the defer loaded view without container information');
123
+ }
124
+ } else if (resourceType === PAGE) {
125
+ // Rendering defer loaded tabs in case/ page context
126
+ getPConnect()
127
+ .getActionsApi()
128
+ .loadView(encodeURI(loadViewCaseID), name, getViewOptions())
129
+ .then(data => {
130
+ onResponse(data);
131
+ });
132
+ } else {
133
+ getPConnect()
134
+ .getActionsApi()
135
+ .refreshCaseView(encodeURI(loadViewCaseID), name)
136
+ .then(data => {
137
+ onResponse(data.root);
138
+ });
139
+ }
140
+ }, [name, getPConnect, currentLoadedAssignment]);
141
+ /* TODO Cosmos need to handle for now added a wrapper div with pos relative */
142
+ let deferLoadContent;
143
+ if (isLoading) {
144
+ deferLoadContent = (
145
+ <div style={{ position: 'relative', height: '100px' }}>
146
+ <Box textAlign='center'>
147
+ <CircularProgress />
148
+ </Box>
149
+ </div>
150
+ );
151
+ } else {
152
+ deferLoadContent = !isTab ? (
153
+ <div className={classes.root}>
154
+ <React.Fragment>{content}</React.Fragment>
155
+ </div>
156
+ ) : (
157
+ <Card id='DeferLoad' className={classes.root}>
158
+ <React.Fragment>{content}</React.Fragment>
159
+ </Card>
160
+ );
161
+ }
162
+
163
+ return deferLoadContent;
164
+ }
165
+
166
+ DeferLoad.defaultProps = {
167
+ isChildDeferLoad: false
168
+ };
169
+
170
+ DeferLoad.propTypes = {
171
+ getPConnect: PropTypes.func.isRequired,
172
+ name: PropTypes.string.isRequired,
173
+ isChildDeferLoad: PropTypes.bool,
174
+ isTab: PropTypes.bool
175
+ };
@@ -0,0 +1 @@
1
+ export { default } from './DeferLoad';
@@ -0,0 +1,103 @@
1
+ // Adapted from nebula ErrorBoundary (remove Cosmos dependencies)
2
+
3
+ import React from "react";
4
+ import PropTypes from "prop-types";
5
+
6
+ declare const PCore;
7
+
8
+ function ErrorBoundary(props) {
9
+ const ERROR_TEXT = PCore.getErrorHandler().getGenericFailedMessage();
10
+ const WORK_AREA = "workarea";
11
+ const ERROR_WHILE_RENDERING = "ERROR_WHILE_RENDERING";
12
+ const { getPConnect, isInternalError } = props;
13
+
14
+ const theErrorDiv = <div>{ERROR_TEXT}</div>
15
+
16
+ if (!getPConnect) {
17
+ return (
18
+ theErrorDiv
19
+ // <Flex
20
+ // container={{
21
+ // alignItems: "center",
22
+ // justify: "center",
23
+ // itemGap: 1
24
+ // }}
25
+ // >
26
+ // <Text status="error">
27
+ // <Icon name="warn-solid" />
28
+ // </Text>
29
+ // <Text data-testid="errorText">{ERROR_TEXT}</Text>
30
+ // </Flex>
31
+ );
32
+ }
33
+
34
+ const pConn = getPConnect();
35
+
36
+ if (!isInternalError) {
37
+ // eslint-disable-next-line no-console
38
+ console.error(`Unable to load the component ${pConn.getComponentName()}
39
+ This might be due to the view meta data getting corrupted or the component file missing.
40
+ Raw meta data for the component: ${JSON.stringify(pConn.getRawMetadata())}`);
41
+ }
42
+
43
+ if (pConn.getConfigProps().type === "page") {
44
+ return (
45
+ theErrorDiv
46
+ // <Banner
47
+ // data-testid="errorBanner"
48
+ // variant="urgent"
49
+ // heading="Error"
50
+ // messages={[ERROR_TEXT]}
51
+ // />
52
+ );
53
+ }
54
+
55
+ if (
56
+ pConn.getContainerName() === WORK_AREA ||
57
+ pConn.isInsideList() === true ||
58
+ pConn.getContainerName() === "modal"
59
+ ) {
60
+ const { publish } = PCore.getPubSubUtils();
61
+ publish(ERROR_WHILE_RENDERING);
62
+ return null;
63
+ }
64
+
65
+ return (
66
+ theErrorDiv
67
+ // <Card>
68
+ // <CardHeader>
69
+ // <Text variant="h3">
70
+ // {pConn.getConfigProps().label || pConn.getComponentName()}
71
+ // </Text>
72
+ // </CardHeader>
73
+ // <CardContent
74
+ // direction="row"
75
+ // style={{ minHeight: "5rem", justifyContent: "center" }}
76
+ // >
77
+ // <Flex
78
+ // container={{
79
+ // alignItems: "center",
80
+ // justify: "center",
81
+ // itemGap: 1
82
+ // }}
83
+ // >
84
+ // <Text status="error">
85
+ // <Icon name="warn-solid" />
86
+ // </Text>
87
+ // <Text>{ERROR_TEXT}</Text>
88
+ // </Flex>
89
+ // </CardContent>
90
+ // </Card>
91
+ );
92
+ }
93
+ ErrorBoundary.propTypes = {
94
+ getPConnect: PropTypes.func,
95
+ isInternalError: PropTypes.bool
96
+ };
97
+
98
+ ErrorBoundary.defaultProps = {
99
+ getPConnect: null,
100
+ isInternalError: false
101
+ };
102
+
103
+ export default ErrorBoundary;
@@ -0,0 +1 @@
1
+ export { default } from './ErrorBoundary';