@pega/react-sdk-overrides 23.1.10 → 23.1.11

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 (228) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +17 -0
  3. package/SECURITY.md +10 -0
  4. package/lib/designSystemExtension/AlertBanner/AlertBanner.tsx +6 -14
  5. package/lib/designSystemExtension/Banner/Banner.tsx +14 -11
  6. package/lib/designSystemExtension/CaseSummaryFields/CaseSummaryFields.css +0 -1
  7. package/lib/designSystemExtension/CaseSummaryFields/CaseSummaryFields.tsx +27 -22
  8. package/lib/designSystemExtension/DetailsFields/DetailsFields.tsx +14 -20
  9. package/lib/designSystemExtension/DetailsFields/index.tsx +1 -1
  10. package/lib/designSystemExtension/FieldGroup/FieldGroup.tsx +44 -19
  11. package/lib/designSystemExtension/FieldGroupList/FieldGroupList.tsx +7 -12
  12. package/lib/designSystemExtension/FieldValueList/FieldValueList.tsx +12 -29
  13. package/lib/designSystemExtension/Operator/Operator.tsx +94 -82
  14. package/lib/designSystemExtension/Pulse/Pulse.tsx +14 -16
  15. package/lib/designSystemExtension/RichTextEditor/RichTextEditor.tsx +6 -5
  16. package/lib/designSystemExtension/WssQuickCreate/WssQuickCreate.tsx +14 -14
  17. package/lib/field/AutoComplete/AutoComplete.tsx +24 -26
  18. package/lib/field/AutoComplete/config-ext.json +2 -3
  19. package/lib/field/CancelAlert/CancelAlert.tsx +98 -84
  20. package/lib/field/CancelAlert/index.tsx +1 -1
  21. package/lib/field/Checkbox/Checkbox.tsx +23 -44
  22. package/lib/field/Checkbox/config-ext.json +2 -3
  23. package/lib/field/Currency/Currency.tsx +25 -50
  24. package/lib/field/Currency/config-ext.json +2 -3
  25. package/lib/field/Currency/currency-utils.ts +9 -16
  26. package/lib/field/Date/Date.tsx +15 -11
  27. package/lib/field/Date/config-ext.json +2 -3
  28. package/lib/field/DateTime/DateTime.tsx +9 -9
  29. package/lib/field/DateTime/config-ext.json +1 -2
  30. package/lib/field/Decimal/Decimal.tsx +23 -43
  31. package/lib/field/Decimal/config-ext.json +1 -2
  32. package/lib/field/Decimal/index.tsx +1 -1
  33. package/lib/field/Dropdown/Dropdown.tsx +122 -31
  34. package/lib/field/Dropdown/config-ext.json +1 -2
  35. package/lib/field/Email/Email.tsx +11 -10
  36. package/lib/field/Email/config-ext.json +1 -2
  37. package/lib/field/Email/index.tsx +1 -1
  38. package/lib/field/Group/Group.tsx +39 -0
  39. package/lib/field/Group/config-ext.json +7 -0
  40. package/lib/field/Group/index.tsx +1 -0
  41. package/lib/field/Integer/Integer.tsx +8 -7
  42. package/lib/field/Integer/config-ext.json +1 -2
  43. package/lib/field/Percentage/Percentage.tsx +46 -41
  44. package/lib/field/Percentage/config-ext.json +1 -2
  45. package/lib/field/Phone/Phone.tsx +13 -12
  46. package/lib/field/Phone/index.tsx +1 -1
  47. package/lib/field/RadioButtons/RadioButtons.tsx +20 -18
  48. package/lib/field/RadioButtons/config-ext.json +1 -2
  49. package/lib/field/RichText/RichText.tsx +7 -6
  50. package/lib/field/ScalarList/ScalarList.tsx +3 -13
  51. package/lib/field/ScalarList/config-ext.json +1 -2
  52. package/lib/field/SemanticLink/SemanticLink.tsx +7 -7
  53. package/lib/field/SemanticLink/config-ext.json +1 -2
  54. package/lib/field/SemanticLink/utils.ts +8 -11
  55. package/lib/field/TextArea/TextArea.tsx +7 -6
  56. package/lib/field/TextArea/config-ext.json +1 -2
  57. package/lib/field/TextContent/TextContent.tsx +4 -6
  58. package/lib/field/TextContent/config-ext.json +1 -2
  59. package/lib/field/TextInput/TextInput.tsx +9 -7
  60. package/lib/field/TextInput/config-ext.json +1 -2
  61. package/lib/field/TextInput/index.tsx +1 -1
  62. package/lib/field/Time/Time.tsx +11 -11
  63. package/lib/field/Time/config-ext.json +1 -2
  64. package/lib/field/URL/URL.tsx +9 -8
  65. package/lib/field/URL/config-ext.json +1 -2
  66. package/lib/field/URL/index.tsx +1 -1
  67. package/lib/field/UserReference/UserReference.tsx +18 -16
  68. package/lib/field/UserReference/UserReferenceUtils.ts +2 -2
  69. package/lib/field/UserReference/config-ext.json +1 -2
  70. package/lib/helpers/attachmentHelpers.ts +13 -8
  71. package/lib/helpers/case-utils.tsx +4 -8
  72. package/lib/helpers/common-utils.ts +5 -1
  73. package/lib/helpers/data_page.ts +3 -7
  74. package/lib/helpers/date-format-utils.ts +3 -3
  75. package/lib/helpers/event-utils.ts +3 -3
  76. package/lib/helpers/field-group-utils.ts +1 -1
  77. package/lib/helpers/formatters/Boolean.ts +9 -26
  78. package/lib/helpers/formatters/Currency.ts +15 -21
  79. package/lib/helpers/formatters/CurrencyMap.ts +505 -501
  80. package/lib/helpers/formatters/Date.ts +20 -26
  81. package/lib/helpers/formatters/common.ts +1 -2
  82. package/lib/helpers/formatters/index.ts +26 -19
  83. package/lib/helpers/reactContextHelpers.ts +2 -2
  84. package/lib/helpers/simpleTableHelpers.ts +59 -83
  85. package/lib/helpers/state-utils.tsx +5 -9
  86. package/lib/helpers/template-utils.ts +3 -6
  87. package/lib/helpers/utils.ts +5 -5
  88. package/lib/helpers/versionHelpers.ts +1 -4
  89. package/lib/infra/ActionButtons/ActionButtons.tsx +38 -29
  90. package/lib/infra/ActionButtons/index.tsx +1 -1
  91. package/lib/infra/Assignment/Assignment.tsx +99 -79
  92. package/lib/infra/Assignment/index.tsx +1 -1
  93. package/lib/infra/AssignmentCard/AssignmentCard.tsx +13 -16
  94. package/lib/infra/AssignmentCard/index.tsx +1 -1
  95. package/lib/infra/Containers/FlowContainer/FlowContainer.tsx +67 -213
  96. package/lib/infra/Containers/FlowContainer/helpers.ts +34 -45
  97. package/lib/infra/Containers/FlowContainer/index.tsx +1 -1
  98. package/lib/infra/Containers/ModalViewContainer/ListViewActionButtons/ListViewActionButtons.tsx +65 -0
  99. package/lib/infra/Containers/ModalViewContainer/ListViewActionButtons/index.tsx +1 -0
  100. package/lib/infra/Containers/ModalViewContainer/ModalViewContainer.tsx +227 -218
  101. package/lib/infra/Containers/ModalViewContainer/index.tsx +1 -1
  102. package/lib/infra/Containers/SimpleView/SimpleView.tsx +48 -0
  103. package/lib/infra/Containers/SimpleView/helper.ts +125 -0
  104. package/lib/infra/Containers/SimpleView/index.tsx +1 -0
  105. package/lib/infra/Containers/ViewContainer/ViewContainer.tsx +36 -46
  106. package/lib/infra/Containers/helpers.ts +6 -0
  107. package/lib/infra/DashboardFilter/DashboardFilter.tsx +21 -42
  108. package/lib/infra/DashboardFilter/filterUtils.tsx +12 -43
  109. package/lib/infra/DeferLoad/DeferLoad.tsx +22 -28
  110. package/lib/infra/DeferLoad/index.tsx +1 -1
  111. package/lib/infra/ErrorBoundary/ErrorBoundary.tsx +16 -30
  112. package/lib/infra/MultiStep/MultiStep.css +11 -15
  113. package/lib/infra/MultiStep/MultiStep.tsx +176 -212
  114. package/lib/infra/MultiStep/index.tsx +1 -1
  115. package/lib/infra/NavBar/NavBar.css +103 -105
  116. package/lib/infra/NavBar/NavBar.tsx +18 -30
  117. package/lib/infra/Reference/Reference.tsx +15 -17
  118. package/lib/infra/Region/Region.tsx +4 -6
  119. package/lib/infra/RootContainer/RootContainer.tsx +75 -111
  120. package/lib/infra/RootContainer/index.tsx +1 -1
  121. package/lib/infra/Stages/Stages.tsx +32 -39
  122. package/lib/infra/VerticalTabs/LeftAlignVerticalTabs/LeftAlignVerticalTabs.tsx +11 -11
  123. package/lib/infra/VerticalTabs/VerticalTabs/VerticalTabs.tsx +21 -28
  124. package/lib/infra/View/View.tsx +17 -21
  125. package/lib/template/AppShell/AppShell.css +22 -23
  126. package/lib/template/AppShell/AppShell.tsx +39 -74
  127. package/lib/template/BannerPage/BannerPage.tsx +12 -14
  128. package/lib/template/CaseSummary/CaseSummary.tsx +58 -18
  129. package/lib/template/CaseSummary/config-ext.json +1 -2
  130. package/lib/template/CaseView/CaseView.tsx +34 -63
  131. package/lib/template/CaseView/config-ext.json +1 -2
  132. package/lib/template/CaseViewActionsMenu/CaseViewActionsMenu.tsx +63 -19
  133. package/lib/template/Confirmation/Confirmation.tsx +12 -17
  134. package/lib/template/Confirmation/config-ext.json +1 -2
  135. package/lib/template/DataReference/DataReference.tsx +95 -121
  136. package/lib/template/DataReference/config-ext.json +1 -2
  137. package/lib/template/DefaultForm/DefaultForm.css +7 -3
  138. package/lib/template/DefaultForm/DefaultForm.tsx +13 -16
  139. package/lib/template/DefaultForm/config-ext.json +1 -2
  140. package/lib/template/Details/Details/Details.tsx +19 -22
  141. package/lib/template/Details/DetailsSubTabs/DetailsSubTabs.tsx +9 -13
  142. package/lib/template/Details/DetailsSubTabs/config-ext.json +1 -2
  143. package/lib/template/Details/DetailsThreeColumn/DetailsThreeColumn.tsx +19 -24
  144. package/lib/template/Details/DetailsThreeColumn/config-ext.json +1 -2
  145. package/lib/template/Details/DetailsTwoColumn/DetailsTwoColumn.tsx +19 -25
  146. package/lib/template/Details/DetailsTwoColumn/config-ext.json +1 -2
  147. package/lib/template/Details/DetailsTwoColumn/index.tsx +1 -1
  148. package/lib/template/Details/DynamicTabs/DynamicTabs.tsx +15 -14
  149. package/lib/template/FieldGroupTemplate/FieldGroupTemplate.tsx +15 -22
  150. package/lib/template/InlineDashboard/InlineDashboard.tsx +12 -14
  151. package/lib/template/InlineDashboardPage/InlineDashboardPage.tsx +12 -16
  152. package/lib/template/ListPage/ListPage.tsx +5 -10
  153. package/lib/template/ListPage/config-ext.json +1 -2
  154. package/lib/template/ListView/DefaultViewMeta.ts +1 -3
  155. package/lib/template/ListView/ListView.tsx +179 -169
  156. package/lib/template/ListView/config-ext.json +1 -2
  157. package/lib/template/ListView/hooks.ts +24 -26
  158. package/lib/template/ListView/utils.ts +51 -87
  159. package/lib/template/MultiReferenceReadOnly/MultiReferenceReadOnly.tsx +20 -20
  160. package/lib/template/NarrowWide/NarrowWide/NarrowWide.css +0 -2
  161. package/lib/template/NarrowWide/NarrowWide/NarrowWide.tsx +25 -38
  162. package/lib/template/NarrowWide/NarrowWideDetails/NarrowWideDetails.tsx +20 -25
  163. package/lib/template/NarrowWide/NarrowWideDetails/config-ext.json +1 -2
  164. package/lib/template/NarrowWide/NarrowWideForm/NarrowWideForm.css +0 -2
  165. package/lib/template/NarrowWide/NarrowWideForm/NarrowWideForm.tsx +14 -24
  166. package/lib/template/NarrowWide/NarrowWideForm/config-ext.json +1 -2
  167. package/lib/template/NarrowWide/NarrowWidePage/NarrowWidePage.tsx +9 -19
  168. package/lib/template/NarrowWide/NarrowWidePage/config-ext.json +1 -2
  169. package/lib/template/OneColumn/OneColumn/OneColumn.tsx +14 -15
  170. package/lib/template/OneColumn/OneColumn/config-ext.json +1 -2
  171. package/lib/template/OneColumn/OneColumnPage/OneColumnPage.tsx +3 -10
  172. package/lib/template/OneColumn/OneColumnPage/config-ext.json +1 -2
  173. package/lib/template/OneColumn/OneColumnTab/OneColumnTab.tsx +6 -10
  174. package/lib/template/OneColumn/OneColumnTab/config-ext.json +1 -2
  175. package/lib/template/PromotedFilters/PromotedFilters.css +1 -1
  176. package/lib/template/PromotedFilters/PromotedFilters.tsx +32 -28
  177. package/lib/template/SimpleTable/SimpleTable/SimpleTable.tsx +37 -33
  178. package/lib/template/SimpleTable/SimpleTable/config-ext.json +1 -2
  179. package/lib/template/SimpleTable/SimpleTableManual/SimpleTableManual.tsx +184 -118
  180. package/lib/template/SimpleTable/SimpleTableSelect/SimpleTableSelect.tsx +24 -25
  181. package/lib/template/SingleReferenceReadOnly/SingleReferenceReadOnly.tsx +30 -30
  182. package/lib/template/SubTabs/SubTabs.tsx +22 -40
  183. package/lib/template/SubTabs/config-ext.json +1 -2
  184. package/lib/template/SubTabs/tabUtils.ts +2 -5
  185. package/lib/template/TwoColumn/TwoColumn/TwoColumn.css +0 -1
  186. package/lib/template/TwoColumn/TwoColumn/TwoColumn.tsx +30 -28
  187. package/lib/template/TwoColumn/TwoColumn/config-ext.json +1 -2
  188. package/lib/template/TwoColumn/TwoColumnPage/TwoColumnPage.tsx +3 -10
  189. package/lib/template/TwoColumn/TwoColumnPage/config-ext.json +1 -2
  190. package/lib/template/TwoColumn/TwoColumnTab/TwoColumnTab.tsx +30 -28
  191. package/lib/template/TwoColumn/TwoColumnTab/config-ext.json +1 -2
  192. package/lib/template/WideNarrow/WideNarrow/WideNarrow.css +0 -2
  193. package/lib/template/WideNarrow/WideNarrow/WideNarrow.tsx +22 -34
  194. package/lib/template/WideNarrow/WideNarrowDetails/WideNarrowDetails.tsx +24 -28
  195. package/lib/template/WideNarrow/WideNarrowDetails/config-ext.json +1 -2
  196. package/lib/template/WideNarrow/WideNarrowForm/WideNarrowForm.css +0 -2
  197. package/lib/template/WideNarrow/WideNarrowForm/WideNarrowForm.tsx +13 -21
  198. package/lib/template/WideNarrow/WideNarrowForm/config-ext.json +1 -2
  199. package/lib/template/WideNarrow/WideNarrowPage/WideNarrowPage.tsx +8 -16
  200. package/lib/template/WideNarrow/WideNarrowPage/config-ext.json +1 -2
  201. package/lib/template/WideNarrow/WideNarrowPage/index.tsx +1 -1
  202. package/lib/template/WssNavBar/WssNavBar.tsx +18 -21
  203. package/lib/widget/AppAnnouncement/AppAnnouncement.tsx +29 -28
  204. package/lib/widget/AppAnnouncement/config-ext.json +1 -2
  205. package/lib/widget/Attachment/Attachment.css +60 -1
  206. package/lib/widget/Attachment/Attachment.tsx +378 -405
  207. package/lib/widget/Attachment/index.tsx +1 -1
  208. package/lib/widget/CaseHistory/CaseHistory.tsx +64 -66
  209. package/lib/widget/CaseHistory/config-ext.json +1 -2
  210. package/lib/widget/CaseHistory/index.tsx +1 -1
  211. package/lib/widget/FileUtility/ActionButtonsForFileUtil/ActionButtonsForFileUtil.tsx +16 -18
  212. package/lib/widget/FileUtility/FileUtility/FileUtility.css +2 -2
  213. package/lib/widget/FileUtility/FileUtility/FileUtility.tsx +310 -246
  214. package/lib/widget/FileUtility/FileUtility/config-ext.json +1 -2
  215. package/lib/widget/Followers/Followers.tsx +23 -20
  216. package/lib/widget/Followers/config-ext.json +1 -2
  217. package/lib/widget/QuickCreate/QuickCreate.tsx +68 -42
  218. package/lib/widget/SummaryItem/SummaryItem.css +9 -9
  219. package/lib/widget/SummaryItem/SummaryItem.tsx +58 -58
  220. package/lib/widget/SummaryItem/index.tsx +1 -1
  221. package/lib/widget/SummaryList/SummaryList.tsx +7 -10
  222. package/lib/widget/ToDo/ToDo.css +4 -4
  223. package/lib/widget/ToDo/ToDo.tsx +52 -53
  224. package/lib/widget/ToDo/config-ext.json +1 -2
  225. package/package.json +5 -2
  226. package/lib/helpers/auth.js +0 -834
  227. package/lib/helpers/authManager.ts +0 -933
  228. package/lib/helpers/config_access.js +0 -186
@@ -0,0 +1,48 @@
1
+ import { useMemo } from 'react';
2
+
3
+ import { getActiveContainerItemID, getActiveContainerRootViewElement, getPConnectOfActiveContainerItem, useContainerInitializer } from './helper';
4
+
5
+ const SimpleViewContainer = props => {
6
+ const { CONTAINER_TYPE } = PCore.getConstants();
7
+
8
+ const { getPConnect, mode = CONTAINER_TYPE.SINGLE, routingInfo: containerInfo, isAssignmentView, options = {} } = props;
9
+
10
+ const rootViewElement = useMemo(() => {
11
+ return getActiveContainerRootViewElement(containerInfo, {
12
+ isAssignmentView,
13
+ parentGetPConnect: getPConnect
14
+ });
15
+ }, [containerInfo, isAssignmentView, getPConnect]);
16
+
17
+ useContainerInitializer(getPConnect, options.mode || mode);
18
+
19
+ return rootViewElement;
20
+ };
21
+
22
+ export const withSimpleViewContainerRenderer =
23
+ (Component, options: any = {}) =>
24
+ props => {
25
+ const { CONTAINER_TYPE } = PCore.getConstants();
26
+
27
+ const { getPConnect, mode = CONTAINER_TYPE.SINGLE, routingInfo: containerInfo, isAssignmentView } = props;
28
+
29
+ const rootViewElement = <SimpleViewContainer {...props} options={options} />;
30
+ const activeContainerItemID = getActiveContainerItemID(containerInfo);
31
+ const getPConnectOfActiveItem = getPConnectOfActiveContainerItem(containerInfo, {
32
+ isAssignmentView,
33
+ parentGetPConnect: getPConnect
34
+ });
35
+
36
+ useContainerInitializer(getPConnect, options.mode || mode);
37
+
38
+ return (
39
+ <Component
40
+ {...props}
41
+ rootViewElement={rootViewElement}
42
+ activeContainerItemID={activeContainerItemID}
43
+ getPConnectOfActiveContainerItem={getPConnectOfActiveItem}
44
+ />
45
+ );
46
+ };
47
+
48
+ export default SimpleViewContainer;
@@ -0,0 +1,125 @@
1
+ import { useEffect, createElement } from 'react';
2
+
3
+ import createPConnectComponent from '@pega/react-sdk-components/lib/bridge/react_pconnect';
4
+ import { isContainerInitialized } from '@pega/react-sdk-components/lib/components/helpers';
5
+
6
+ const processRootViewDetails = (rootView, containerItem, options) => {
7
+ const {
8
+ config: { context: viewContext, name: viewName }
9
+ } = rootView;
10
+ const { context: containerContext } = containerItem;
11
+ const { parentGetPConnect } = options;
12
+ let resolvedViewName = viewName;
13
+ let resolvedViewContext = viewContext;
14
+
15
+ const isAnnotedViewName = PCore.getAnnotationUtils().isProperty(viewName);
16
+ const isAnnotedViewContext = PCore.getAnnotationUtils().isProperty(viewContext);
17
+
18
+ // resolving annoted view context
19
+ if (isAnnotedViewContext) {
20
+ const viewContextProperty = PCore.getAnnotationUtils().getPropertyName(viewContext);
21
+ resolvedViewContext = PCore.getStoreValue(
22
+ `.${viewContextProperty}`,
23
+ viewContextProperty.startsWith('.') ? parentGetPConnect().getPageReference() : '',
24
+ containerContext
25
+ );
26
+ }
27
+
28
+ if (!resolvedViewContext) {
29
+ resolvedViewContext = parentGetPConnect().getPageReference();
30
+ }
31
+
32
+ // resolving annoted view name
33
+ if (isAnnotedViewName) {
34
+ const viewNameProperty = PCore.getAnnotationUtils().getPropertyName(viewName);
35
+ resolvedViewName = PCore.getStoreValue(`.${viewNameProperty}`, resolvedViewContext, containerContext);
36
+ }
37
+
38
+ /* Special case where context and viewname are dynamic values
39
+ Use case - split for each shape
40
+
41
+ Ex - (caseInfo.content.SCRequestWorkQueues[1]):context --> .pyViewName:viewName
42
+ */
43
+ if (isAnnotedViewName && isAnnotedViewContext && resolvedViewName !== '') {
44
+ /* Allow context processor to resolve view and context when both are dynamic */
45
+ resolvedViewName = viewName;
46
+ resolvedViewContext = viewContext;
47
+ }
48
+
49
+ return {
50
+ viewName: resolvedViewName,
51
+ viewContext: resolvedViewContext
52
+ };
53
+ };
54
+
55
+ export const getPConnectOfActiveContainerItem = (containerInfo, options) => {
56
+ const { accessedOrder, items } = containerInfo;
57
+ const { isAssignmentView = false, parentGetPConnect } = options;
58
+ const containerName = parentGetPConnect().getContainerName();
59
+ const { CONTAINER_NAMES } = PCore.getContainerUtils();
60
+ const { CREATE_DETAILS_VIEW_NAME } = PCore.getConstants();
61
+
62
+ if (accessedOrder && items) {
63
+ const activeContainerItemKey = accessedOrder[accessedOrder.length - 1];
64
+
65
+ if (items[activeContainerItemKey] && items[activeContainerItemKey].view && Object.keys(items[activeContainerItemKey].view).length > 0) {
66
+ const activeContainerItem = items[activeContainerItemKey];
67
+ const target = activeContainerItemKey.substring(0, activeContainerItemKey.lastIndexOf('_'));
68
+
69
+ const { view: rootView, context } = activeContainerItem;
70
+ const { viewName, viewContext } = processRootViewDetails(rootView, activeContainerItem, { parentGetPConnect });
71
+
72
+ if (!viewName) return null;
73
+
74
+ const config = {
75
+ meta: rootView,
76
+ options: {
77
+ context,
78
+ pageReference: viewContext || parentGetPConnect().getPageReference(),
79
+ containerName,
80
+ containerItemID: activeContainerItemKey,
81
+ parentPageReference: parentGetPConnect().getPageReference(),
82
+ hasForm:
83
+ isAssignmentView ||
84
+ containerName === CONTAINER_NAMES.WORKAREA ||
85
+ containerName === CONTAINER_NAMES.MODAL ||
86
+ viewName === CREATE_DETAILS_VIEW_NAME,
87
+ target
88
+ }
89
+ };
90
+
91
+ return PCore.createPConnect(config).getPConnect;
92
+ }
93
+ }
94
+ return null;
95
+ };
96
+
97
+ export const getActiveContainerRootViewElement = (containerInfo, options) => {
98
+ const getPConnect = getPConnectOfActiveContainerItem(containerInfo, options);
99
+ if (getPConnect) {
100
+ return createElement(createPConnectComponent(), { getPConnect });
101
+ }
102
+ return null;
103
+ };
104
+
105
+ export const getActiveContainerItemID = containerInfo => {
106
+ const { accessedOrder } = containerInfo;
107
+ if (accessedOrder && accessedOrder.length > 0) {
108
+ return accessedOrder[accessedOrder.length - 1];
109
+ }
110
+ return '';
111
+ };
112
+
113
+ export const useContainerInitializer = (getPConnect, mode) => {
114
+ const pConnect = getPConnect();
115
+ const containerName = pConnect.getContainerName();
116
+ const containerManager = pConnect.getContainerManager();
117
+ useEffect(() => {
118
+ if (!isContainerInitialized(pConnect)) {
119
+ containerManager.initializeContainers({
120
+ type: mode,
121
+ name: containerName
122
+ });
123
+ }
124
+ });
125
+ };
@@ -0,0 +1 @@
1
+ export { default } from './SimpleView';
@@ -1,21 +1,20 @@
1
- import React, { useEffect, useState, useContext, createElement } from "react";
2
- import { Box, CircularProgress } from "@material-ui/core";
3
- import createPConnectComponent from "@pega/react-sdk-components/lib/bridge/react_pconnect";
4
- import StoreContext from "@pega/react-sdk-components/lib/bridge/Context/StoreContext";
5
- import { isEmptyObject } from '@pega/react-sdk-components/lib/components/helpers/common-utils';
1
+ import React, { createElement, useContext, useEffect, useState } from 'react';
2
+ import { Box, CircularProgress } from '@material-ui/core';
6
3
 
7
- import type { PConnProps } from '@pega/react-sdk-components/lib/types/PConnProps';
4
+ import createPConnectComponent from '@pega/react-sdk-components/lib/bridge/react_pconnect';
5
+ import StoreContext from '@pega/react-sdk-components/lib/bridge/Context/StoreContext';
6
+ import { isEmptyObject } from '@pega/react-sdk-components/lib/components/helpers/common-utils';
7
+ import { PConnProps } from '@pega/react-sdk-components/lib/types/PConnProps';
8
8
 
9
9
  interface ViewContainerProps extends PConnProps {
10
10
  // If any, enter additional props that only exist on this component
11
- name?: string,
12
- loadingInfo?: any, // can't be boolean until setDispatchObjState expects loadingInfo to be type null
13
- routingInfo?: any,
14
- mode?: string,
15
- limit?: number
11
+ name?: string;
12
+ loadingInfo?: any; // can't be boolean until setDispatchObjState expects loadingInfo to be type null
13
+ routingInfo?: any;
14
+ mode?: string;
15
+ limit?: number;
16
16
  }
17
17
 
18
-
19
18
  // ViewContainer can emit View
20
19
  // import View from '../View';
21
20
 
@@ -25,36 +24,33 @@ interface ViewContainerProps extends PConnProps {
25
24
  // is totally at your own risk.
26
25
  //
27
26
 
28
-
29
27
  export default function ViewContainer(props: ViewContainerProps) {
30
28
  // const { getPConnect, children, routingInfo, name } = props;
31
- const { getPConnect, name = '', mode = 'single', limit = 16, loadingInfo = false, routingInfo = null} = props;
29
+ const { getPConnect, name = '', mode = 'single', limit = 16, loadingInfo = false, routingInfo = null } = props;
32
30
 
33
31
  const { displayOnlyFA } = useContext<any>(StoreContext);
34
32
 
35
-
36
33
  const { CONTAINER_TYPE, APP } = PCore.getConstants();
37
34
  const pConn = getPConnect();
38
35
  const containerMgr: any = pConn.getContainerManager();
39
36
 
40
37
  const [dispatchObjState, setDispatchObjState] = useState({
41
- dispatchObject: {semanticURL: "", context: "", acName: ""},
38
+ dispatchObject: { semanticURL: '', context: '', acName: '' },
42
39
  visible: false,
43
40
  loadingInfo: null,
44
41
  isLoadingInfoChange: false
45
- }); // was this.state in class-based ViewContainer avoiding use of just "state" as the name
42
+ }); // was this.state in class-based ViewContainer avoiding use of just "state" as the name
46
43
 
47
44
  let root;
48
45
 
49
-
50
- const thePConn = ((typeof getPConnect) === 'function') ? getPConnect() : null;
46
+ const thePConn = typeof getPConnect === 'function' ? getPConnect() : null;
51
47
 
52
48
  // beginning of functions for use by ViewContainer
53
49
 
54
50
  function buildName() {
55
51
  const context = thePConn?.getContextName();
56
52
  let viewContainerName = name;
57
- if (!viewContainerName) viewContainerName = "";
53
+ if (!viewContainerName) viewContainerName = '';
58
54
  return `${context?.toUpperCase()}/${viewContainerName.toUpperCase()}`;
59
55
  }
60
56
 
@@ -63,11 +59,11 @@ export default function ViewContainer(props: ViewContainerProps) {
63
59
  // const { acName = "primary" } = pConn.getContainerName(); // doesn't work with 8.23 typings
64
60
  let acName = pConn.getContainerName();
65
61
  if (!acName) {
66
- acName = "primary";
62
+ acName = 'primary';
67
63
  }
68
64
 
69
65
  return {
70
- semanticURL: "",
66
+ semanticURL: '',
71
67
  context: baseContext,
72
68
  acName
73
69
  };
@@ -85,7 +81,6 @@ export default function ViewContainer(props: ViewContainerProps) {
85
81
 
86
82
  // set the root component that is retrieved by PConnectHOC
87
83
  function setRootComponent(configObject) {
88
-
89
84
  const { isLoadingInfoChange } = dispatchObjState;
90
85
  if (!isLoadingInfoChange) {
91
86
  root = createElement(createPConnectComponent(), configObject);
@@ -96,13 +91,9 @@ export default function ViewContainer(props: ViewContainerProps) {
96
91
 
97
92
  // useEffect on [] -> code that should be run once (as in old constructor and in componentDidMount)
98
93
  useEffect(() => {
99
-
100
94
  // This is adapted from the class-based ViewContainer constructor
101
95
  containerMgr.initializeContainers({
102
- type:
103
- mode === CONTAINER_TYPE.MULTIPLE
104
- ? CONTAINER_TYPE.MULTIPLE
105
- : CONTAINER_TYPE.SINGLE
96
+ type: mode === CONTAINER_TYPE.MULTIPLE ? CONTAINER_TYPE.MULTIPLE : CONTAINER_TYPE.SINGLE
106
97
  });
107
98
 
108
99
  if (mode === CONTAINER_TYPE.MULTIPLE && limit) {
@@ -111,7 +102,7 @@ export default function ViewContainer(props: ViewContainerProps) {
111
102
  }
112
103
 
113
104
  const dispatchObject = prepareDispatchObject();
114
- setDispatchObjState( {
105
+ setDispatchObjState({
115
106
  dispatchObject,
116
107
  // PCore is defined in pxBootstrapShell - eventually will be exported in place of constellationCore
117
108
  visible: !PCore.checkIfSemanticURL(),
@@ -132,9 +123,8 @@ export default function ViewContainer(props: ViewContainerProps) {
132
123
  }
133
124
 
134
125
  // Getting default view label
135
- const navPages = pConn.getValue("pyPortal.pyPrimaryNavPages", ''); // 2nd arg empty string until typedefs allow optional
136
- const defaultViewLabel =
137
- Array.isArray(navPages) && navPages[0] ? navPages[0].pyLabel : "";
126
+ const navPages = pConn.getValue('pyPortal.pyPrimaryNavPages', ''); // 2nd arg empty string until typedefs allow optional
127
+ const defaultViewLabel = Array.isArray(navPages) && navPages[0] ? navPages[0].pyLabel : '';
138
128
  // TODO: Plan is to rename window.constellationCore to window.pega (or similar)
139
129
  // And expose less via ui-bootstrap.js
140
130
  // PCore is defined in pxBootstrapShell - eventually will be exported in place of constellationCore
@@ -145,11 +135,8 @@ export default function ViewContainer(props: ViewContainerProps) {
145
135
  ...objectForAddContainer,
146
136
  defaultViewLabel
147
137
  });
148
-
149
138
  }
150
-
151
- },
152
- []);
139
+ }, []);
153
140
 
154
141
  // This code (that's run every time the ViewContainer is called) is adapted from the class-based ViewContainer's render
155
142
 
@@ -167,11 +154,7 @@ export default function ViewContainer(props: ViewContainerProps) {
167
154
  let componentVisible = accessedOrder.length > 0;
168
155
  const { visible } = dispatchObjState;
169
156
  componentVisible = visible || componentVisible;
170
- if (
171
- items[key] &&
172
- items[key].view &&
173
- !isEmptyObject(items[key].view)
174
- ) {
157
+ if (items[key] && items[key].view && !isEmptyObject(items[key].view)) {
175
158
  const latestItem = items[key];
176
159
  const rootView = latestItem.view;
177
160
  const { context, name: viewName } = rootView.config;
@@ -183,18 +166,22 @@ export default function ViewContainer(props: ViewContainerProps) {
183
166
  containerItemName: key,
184
167
  hasForm: viewName === CREATE_DETAILS_VIEW_NAME
185
168
  };
186
- const configObject = PCore.createPConnect(config);
169
+ const configObject: any = PCore.createPConnect(config);
187
170
 
188
171
  // Add in displayOnlyFA if prop is on ViewContainer
189
172
  if (displayOnlyFA) {
190
- configObject["displayOnlyFA"] = true;
173
+ configObject.displayOnlyFA = true;
191
174
  }
192
175
 
193
176
  setRootComponent(configObject);
194
177
  return (
195
178
  <React.Fragment key={theBuildName}>
196
179
  {componentVisible && root}
197
- {loadingInfo && <Box textAlign="center"><CircularProgress /></Box>}
180
+ {loadingInfo && (
181
+ <Box textAlign='center'>
182
+ <CircularProgress />
183
+ </Box>
184
+ )}
198
185
  </React.Fragment>
199
186
  );
200
187
  }
@@ -204,8 +191,11 @@ export default function ViewContainer(props: ViewContainerProps) {
204
191
  // fall through return if insufficient routingInfo
205
192
  return (
206
193
  <React.Fragment key={theBuildName}>
207
- {loadingInfo && <Box textAlign="center"><CircularProgress /></Box>}
194
+ {loadingInfo && (
195
+ <Box textAlign='center'>
196
+ <CircularProgress />
197
+ </Box>
198
+ )}
208
199
  </React.Fragment>
209
200
  );
210
-
211
201
  }
@@ -0,0 +1,6 @@
1
+ // eslint-disable-next-line import/prefer-default-export
2
+ export const isContainerInitialized = pConnect => {
3
+ const context = pConnect.getContextName();
4
+ const containerName = pConnect.getContainerName();
5
+ return PCore.getContainerUtils().isContainerInitialized(context, containerName);
6
+ };
@@ -1,30 +1,25 @@
1
- /* eslint-disable no-shadow */
2
1
  /* eslint-disable @typescript-eslint/no-shadow */
3
2
  /* eslint-disable operator-assignment */
4
- import { useRef, useEffect, useState, Fragment, forwardRef } from 'react';
3
+ import { forwardRef, PropsWithChildren, useEffect, useRef, useState } from 'react';
4
+ import { TextField } from '@material-ui/core';
5
5
  import { v4 as uuidv4 } from 'uuid';
6
6
  import { debounce } from 'throttle-debounce';
7
- import { createFilter, combineFilters, getFormattedDate } from './filterUtils';
8
- import { getFilterExpression } from './filterUtils';
9
- import { TextField } from '@material-ui/core';
10
- import React from 'react';
11
7
  import DatePicker from 'react-datepicker';
12
8
 
13
- import 'react-datepicker/dist/react-datepicker.css';
9
+ import { createFilter, combineFilters, getFormattedDate, getFilterExpression } from './filterUtils';
10
+ import { PConnProps } from '@pega/react-sdk-components/lib/types/PConnProps';
14
11
 
15
- import type { PConnProps } from '@pega/react-sdk-components/lib/types/PConnProps';
12
+ import 'react-datepicker/dist/react-datepicker.css';
16
13
 
17
14
  interface DashboardFilterProps extends PConnProps {
18
15
  // If any, enter additional props that only exist on this component
19
- children?: Array<any>,
20
- name: string,
21
- filterProp: string,
22
- type?: string,
23
- metadata?: any
16
+ name: string;
17
+ filterProp: string;
18
+ type?: string;
19
+ metadata?: any;
24
20
  }
25
21
 
26
-
27
- export default function DashboardFilter(props: DashboardFilterProps) {
22
+ export default function DashboardFilter(props: PropsWithChildren<DashboardFilterProps>) {
28
23
  const { children = [], name, filterProp, type = '', metadata = null, getPConnect } = props;
29
24
  const { current: filterId } = useRef(uuidv4());
30
25
 
@@ -74,10 +69,7 @@ export default function DashboardFilter(props: DashboardFilterProps) {
74
69
  filterExpression: getFilterExpression(filterValue, name, metadata)
75
70
  };
76
71
 
77
- PCore.getPubSubUtils().publish(
78
- PCore.getConstants().PUB_SUB_EVENTS.EVENT_DASHBOARD_FILTER_CHANGE,
79
- filterData
80
- );
72
+ PCore.getPubSubUtils().publish(PCore.getConstants().PUB_SUB_EVENTS.EVENT_DASHBOARD_FILTER_CHANGE, filterData);
81
73
  };
82
74
 
83
75
  const fireFilterChangeDebounced = debounce(500, fireFilterChange);
@@ -97,10 +89,7 @@ export default function DashboardFilter(props: DashboardFilterProps) {
97
89
  filterId,
98
90
  filterExpression: combineFilters([startFilter, endFilter], null)
99
91
  };
100
- PCore.getPubSubUtils().publish(
101
- PCore.getConstants().PUB_SUB_EVENTS.EVENT_DASHBOARD_FILTER_CHANGE,
102
- filterData
103
- );
92
+ PCore.getPubSubUtils().publish(PCore.getConstants().PUB_SUB_EVENTS.EVENT_DASHBOARD_FILTER_CHANGE, filterData);
104
93
  }
105
94
  };
106
95
 
@@ -108,8 +97,7 @@ export default function DashboardFilter(props: DashboardFilterProps) {
108
97
  metadata.config.onRecordChange = e => {
109
98
  fireFilterChange(e.id);
110
99
  };
111
- return getPConnect().createComponent(metadata,
112
- '', '', {}); // 2nd, 3rd, and 4th args empty string/object/null until typedef marked correctly as optional);
100
+ return getPConnect().createComponent(metadata, '', '', {}); // 2nd, 3rd, and 4th args empty string/object/null until typedef marked correctly as optional);
113
101
  };
114
102
 
115
103
  const onChange = dates => {
@@ -123,24 +111,15 @@ export default function DashboardFilter(props: DashboardFilterProps) {
123
111
 
124
112
  const label = metadata.config.label.substring(3);
125
113
 
126
- const CustomDateInput = forwardRef<HTMLInputElement, TextProps>(
127
- ({ value, onClick }, ref: any) => (
128
- <TextField
129
- label={label}
130
- variant='outlined'
131
- fullWidth
132
- value={value}
133
- size='small'
134
- onClick={onClick}
135
- ref={ref}
136
- >
137
- {value}
138
- </TextField>
139
- )
140
- );
114
+ // eslint-disable-next-line react/no-unstable-nested-components
115
+ const CustomDateInput = forwardRef<HTMLInputElement, TextProps>(({ value, onClick }, ref: any) => (
116
+ <TextField label={label} variant='outlined' fullWidth value={value} size='small' onClick={onClick} ref={ref}>
117
+ {value}
118
+ </TextField>
119
+ ));
141
120
 
142
121
  return (
143
- <Fragment>
122
+ <>
144
123
  {type === 'DateTime' && (
145
124
  <DatePicker
146
125
  onChange={onChange}
@@ -171,6 +150,6 @@ export default function DashboardFilter(props: DashboardFilterProps) {
171
150
  {children}
172
151
  </span>
173
152
  )}
174
- </Fragment>
153
+ </>
175
154
  );
176
155
  }
@@ -2,12 +2,8 @@
2
2
  /** This file contains various utility methods to generate filter components, regionLayout data, filter expressions, etc. */
3
3
 
4
4
  import { Grid, Link } from '@material-ui/core';
5
- import React from 'react';
6
- import DashboardFilter from './DashboardFilter';
7
-
8
- // Remove this and use "real" PCore type once .d.ts is fixed (currently shows 5 errors)
9
- declare const PCore: any;
10
5
 
6
+ import DashboardFilter from './DashboardFilter';
11
7
 
12
8
  export const createFilter = (value, fieldId, comparator = 'EQ') => {
13
9
  return {
@@ -48,11 +44,9 @@ export const createFilterComponent = (getPConnect, filterMeta, index) => {
48
44
  if (name.indexOf('.') !== -1) {
49
45
  cleanedName = name.substring(name.indexOf('.') + 1);
50
46
  }
51
- let propInfo = PCore.getMetadataUtils().getPropertyMetadata(
52
- cleanedName,
53
- filterMeta.config.ruleClass
54
- );
47
+ let propInfo: any = PCore.getMetadataUtils().getPropertyMetadata(cleanedName, filterMeta.config.ruleClass);
55
48
  if (!propInfo) {
49
+ // @ts-ignore - PCore.getMetadataUtils().getPropertyMetadata - An argument for 'currentClassID' was not provided.
56
50
  propInfo = PCore.getMetadataUtils().getPropertyMetadata(cleanedName);
57
51
  }
58
52
  const { type: propertyType } = propInfo || { type: 'Text' };
@@ -62,16 +56,7 @@ export const createFilterComponent = (getPConnect, filterMeta, index) => {
62
56
  const type = filterType || filterMeta.type;
63
57
  const filterProp = `.pyDashboardFilter${index}`;
64
58
  if (type === 'DateTime') {
65
- return (
66
- <DashboardFilter
67
- key={name}
68
- getPConnect={getPConnect}
69
- name={name}
70
- filterProp={filterProp}
71
- metadata={filterMeta}
72
- type={filterMeta.type}
73
- ></DashboardFilter>
74
- );
59
+ return <DashboardFilter key={name} getPConnect={getPConnect} name={name} filterProp={filterProp} metadata={filterMeta} type={filterMeta.type} />;
75
60
  }
76
61
  if (datasource && datasource.fields) {
77
62
  datasource.fields.key = datasource.fields.value;
@@ -83,33 +68,22 @@ export const createFilterComponent = (getPConnect, filterMeta, index) => {
83
68
  filterMeta.type = filterMeta.config.displayAs || type;
84
69
  filterMeta.config.placeholder = 'ALL';
85
70
  return (
86
- <DashboardFilter
87
- key={name}
88
- getPConnect={getPConnect}
89
- name={name}
90
- filterProp={filterProp}
91
- metadata={filterMeta}
92
- type={filterMeta.type}
93
- >
94
- {getPConnect().createComponent(filterMeta,
95
- '', '', {})}
71
+ <DashboardFilter key={name} getPConnect={getPConnect} name={name} filterProp={filterProp} metadata={filterMeta} type={filterMeta.type}>
72
+ {getPConnect().createComponent(filterMeta, '', '', {})}
96
73
  </DashboardFilter>
97
74
  );
98
75
  };
99
76
 
100
77
  export const buildFilterComponents = (getPConnect, allFilters) => {
101
- const filterComponents = allFilters.children.map((filter, index) =>
102
- createFilterComponent(getPConnect, filter, index)
103
- );
78
+ const filterComponents = allFilters.children.map((filter, index) => createFilterComponent(getPConnect, filter, index));
104
79
  if (filterComponents && filterComponents.length > 0) {
105
80
  filterComponents.push(
106
81
  <Grid>
107
82
  <Link
108
83
  style={{ cursor: 'pointer' }}
109
84
  onClick={() => {
110
- PCore.getPubSubUtils().publish(
111
- PCore.getConstants().PUB_SUB_EVENTS.EVENT_DASHBOARD_FILTER_CLEAR_ALL
112
- );
85
+ // @ts-ignore - second parameter “payload” for publish method should be optional
86
+ PCore.getPubSubUtils().publish(PCore.getConstants().PUB_SUB_EVENTS.EVENT_DASHBOARD_FILTER_CLEAR_ALL);
113
87
  }}
114
88
  >
115
89
  Clear All
@@ -137,7 +111,7 @@ export const getFilterExpression = (filterValue, name, metadata) => {
137
111
  if (metadata.config.filterType && metadata.config.filterType === 'RelativeDates') {
138
112
  const fieldSource = metadata.config.datasource.filter(source => source.key === filterValue)[0];
139
113
  const relativeDateExpression = JSON.parse(fieldSource.json);
140
- // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
114
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
141
115
  const fields = [
142
116
  {
143
117
  name: relativeDateExpression.condition.lhs.field,
@@ -168,9 +142,7 @@ export function getLayoutDataFromRegion(regionData) {
168
142
  const itemPConnect = item?.getPConnect();
169
143
 
170
144
  return {
171
- id: itemPConnect?.getComponentName()
172
- ? `${itemPConnect.getComponentName()}--${index}`
173
- : `item--${index}`,
145
+ id: itemPConnect?.getComponentName() ? `${itemPConnect.getComponentName()}--${index}` : `item--${index}`,
174
146
  content: itemPConnect?.getComponent(),
175
147
  layoutConfig: {
176
148
  ...defaultLayoutConfig,
@@ -184,8 +156,5 @@ export const getFormattedDate = date => {
184
156
  if (!date) {
185
157
  return date;
186
158
  }
187
- const formattedDate = `${date.getFullYear()}-${('0' + (date.getMonth() + 1)).slice(-2)}-${(
188
- '0' + date.getDate()
189
- ).slice(-2)}`;
190
- return formattedDate;
159
+ return `${date.getFullYear()}-${('0' + (date.getMonth() + 1)).slice(-2)}-${('0' + date.getDate()).slice(-2)}`;
191
160
  };