@pega/react-sdk-overrides 0.23.25 → 0.23.27

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 (240) 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 +39 -0
  5. package/lib/designSystemExtension/AlertBanner/index.tsx +1 -0
  6. package/lib/designSystemExtension/Banner/Banner.css +4 -0
  7. package/lib/designSystemExtension/Banner/Banner.tsx +33 -16
  8. package/lib/designSystemExtension/CaseSummaryFields/CaseSummaryFields.css +0 -1
  9. package/lib/designSystemExtension/CaseSummaryFields/CaseSummaryFields.tsx +36 -26
  10. package/lib/designSystemExtension/DetailsFields/DetailsFields.tsx +21 -28
  11. package/lib/designSystemExtension/DetailsFields/index.tsx +1 -1
  12. package/lib/designSystemExtension/FieldGroup/FieldGroup.tsx +50 -18
  13. package/lib/designSystemExtension/FieldGroupList/FieldGroupList.tsx +13 -12
  14. package/lib/designSystemExtension/FieldValueList/FieldValueList.tsx +18 -27
  15. package/lib/designSystemExtension/Operator/Operator.tsx +106 -87
  16. package/lib/designSystemExtension/Pulse/Pulse.tsx +21 -19
  17. package/lib/designSystemExtension/RichTextEditor/RichTextEditor.tsx +122 -0
  18. package/lib/designSystemExtension/RichTextEditor/index.tsx +1 -0
  19. package/lib/designSystemExtension/WssQuickCreate/WssQuickCreate.css +6 -2
  20. package/lib/designSystemExtension/WssQuickCreate/WssQuickCreate.tsx +21 -12
  21. package/lib/field/AutoComplete/AutoComplete.tsx +33 -16
  22. package/lib/field/AutoComplete/config-ext.json +2 -3
  23. package/lib/field/CancelAlert/CancelAlert.tsx +21 -15
  24. package/lib/field/CancelAlert/index.tsx +1 -1
  25. package/lib/field/Checkbox/Checkbox.tsx +29 -19
  26. package/lib/field/Checkbox/config-ext.json +2 -3
  27. package/lib/field/Currency/Currency.tsx +27 -38
  28. package/lib/field/Currency/config-ext.json +2 -3
  29. package/lib/field/Currency/currency-utils.ts +10 -18
  30. package/lib/field/Date/Date.tsx +33 -15
  31. package/lib/field/Date/config-ext.json +2 -3
  32. package/lib/field/DateTime/DateTime.tsx +22 -11
  33. package/lib/field/DateTime/config-ext.json +1 -2
  34. package/lib/field/Decimal/Decimal.tsx +64 -17
  35. package/lib/field/Decimal/config-ext.json +1 -2
  36. package/lib/field/Decimal/index.tsx +1 -1
  37. package/lib/field/Dropdown/Dropdown.tsx +154 -18
  38. package/lib/field/Dropdown/config-ext.json +1 -2
  39. package/lib/field/Email/Email.tsx +16 -7
  40. package/lib/field/Email/config-ext.json +1 -2
  41. package/lib/field/Email/index.tsx +1 -1
  42. package/lib/field/Group/Group.tsx +37 -0
  43. package/lib/field/Group/config-ext.json +7 -0
  44. package/lib/field/Group/index.tsx +1 -0
  45. package/lib/field/Integer/Integer.tsx +15 -6
  46. package/lib/field/Integer/config-ext.json +1 -2
  47. package/lib/field/Percentage/Percentage.tsx +14 -6
  48. package/lib/field/Percentage/config-ext.json +1 -2
  49. package/lib/field/Phone/Phone.tsx +17 -7
  50. package/lib/field/Phone/index.tsx +1 -1
  51. package/lib/field/RadioButtons/RadioButtons.tsx +55 -24
  52. package/lib/field/RadioButtons/config-ext.json +1 -2
  53. package/lib/field/RichText/RichText.tsx +96 -0
  54. package/lib/field/RichText/index.tsx +1 -0
  55. package/lib/field/ScalarList/ScalarList.tsx +63 -0
  56. package/lib/field/ScalarList/config-ext.json +7 -0
  57. package/lib/field/ScalarList/index.tsx +1 -0
  58. package/lib/field/SemanticLink/SemanticLink.tsx +26 -25
  59. package/lib/field/SemanticLink/config-ext.json +1 -2
  60. package/lib/field/SemanticLink/utils.ts +8 -10
  61. package/lib/field/TextArea/TextArea.tsx +15 -5
  62. package/lib/field/TextArea/config-ext.json +1 -2
  63. package/lib/field/TextContent/TextContent.tsx +9 -2
  64. package/lib/field/TextContent/config-ext.json +1 -2
  65. package/lib/field/TextInput/TextInput.tsx +41 -10
  66. package/lib/field/TextInput/config-ext.json +1 -2
  67. package/lib/field/TextInput/index.tsx +1 -1
  68. package/lib/field/Time/Time.tsx +21 -18
  69. package/lib/field/Time/config-ext.json +1 -2
  70. package/lib/field/URL/URL.tsx +23 -6
  71. package/lib/field/URL/config-ext.json +1 -2
  72. package/lib/field/URL/index.tsx +1 -1
  73. package/lib/field/UserReference/UserReference.tsx +52 -58
  74. package/lib/field/UserReference/UserReferenceUtils.ts +2 -2
  75. package/lib/field/UserReference/config-ext.json +1 -2
  76. package/lib/helpers/{attachmentHelpers.js → attachmentHelpers.ts} +16 -11
  77. package/lib/helpers/case-utils.tsx +99 -0
  78. package/lib/helpers/common-utils.ts +8 -0
  79. package/lib/helpers/data_page.ts +3 -6
  80. package/lib/helpers/date-format-utils.ts +29 -19
  81. package/lib/helpers/{event-utils.js → event-utils.ts} +4 -4
  82. package/lib/helpers/{field-group-utils.js → field-group-utils.ts} +9 -10
  83. package/lib/helpers/formatters/Boolean.ts +21 -0
  84. package/lib/helpers/formatters/{Currency.js → Currency.ts} +22 -27
  85. package/lib/helpers/formatters/CurrencyMap.ts +915 -0
  86. package/lib/helpers/formatters/{Date.js → Date.ts} +20 -26
  87. package/lib/helpers/formatters/{common.js → common.ts} +3 -4
  88. package/lib/helpers/formatters/{index.js → index.ts} +22 -22
  89. package/lib/helpers/{reactContextHelpers.js → reactContextHelpers.ts} +2 -2
  90. package/lib/helpers/simpleTableHelpers.ts +65 -85
  91. package/lib/helpers/state-utils.tsx +43 -0
  92. package/lib/helpers/template-utils.ts +4 -8
  93. package/lib/helpers/utils.ts +16 -8
  94. package/lib/helpers/versionHelpers.ts +1 -5
  95. package/lib/infra/ActionButtons/ActionButtons.tsx +46 -42
  96. package/lib/infra/ActionButtons/index.tsx +1 -1
  97. package/lib/infra/Assignment/Assignment.tsx +99 -84
  98. package/lib/infra/Assignment/index.tsx +1 -1
  99. package/lib/infra/AssignmentCard/AssignmentCard.tsx +19 -26
  100. package/lib/infra/AssignmentCard/index.tsx +1 -1
  101. package/lib/infra/Containers/FlowContainer/FlowContainer.tsx +98 -232
  102. package/lib/infra/Containers/FlowContainer/helpers.ts +138 -0
  103. package/lib/infra/Containers/FlowContainer/index.tsx +1 -1
  104. package/lib/infra/Containers/ModalViewContainer/ListViewActionButtons/ListViewActionButtons.tsx +66 -0
  105. package/lib/infra/Containers/ModalViewContainer/ListViewActionButtons/index.tsx +1 -0
  106. package/lib/infra/Containers/ModalViewContainer/ModalViewContainer.tsx +105 -70
  107. package/lib/infra/Containers/ModalViewContainer/index.tsx +1 -1
  108. package/lib/infra/Containers/SimpleView/SimpleView.tsx +48 -0
  109. package/lib/infra/Containers/SimpleView/helper.ts +125 -0
  110. package/lib/infra/Containers/SimpleView/index.tsx +1 -0
  111. package/lib/infra/Containers/ViewContainer/ViewContainer.tsx +49 -64
  112. package/lib/infra/Containers/helpers.ts +6 -0
  113. package/lib/infra/DashboardFilter/DashboardFilter.tsx +26 -51
  114. package/lib/infra/DashboardFilter/filterUtils.tsx +12 -40
  115. package/lib/infra/DeferLoad/DeferLoad.tsx +22 -31
  116. package/lib/infra/DeferLoad/index.tsx +1 -1
  117. package/lib/infra/ErrorBoundary/ErrorBoundary.tsx +25 -38
  118. package/lib/infra/MultiStep/MultiStep.css +11 -15
  119. package/lib/infra/MultiStep/MultiStep.tsx +180 -216
  120. package/lib/infra/MultiStep/index.tsx +1 -1
  121. package/lib/infra/NavBar/NavBar.css +103 -105
  122. package/lib/infra/NavBar/NavBar.tsx +28 -43
  123. package/lib/infra/Reference/Reference.tsx +16 -22
  124. package/lib/infra/Region/Region.tsx +9 -9
  125. package/lib/infra/RootContainer/RootContainer.tsx +82 -125
  126. package/lib/infra/RootContainer/index.tsx +1 -1
  127. package/lib/infra/Stages/Stages.tsx +38 -39
  128. package/lib/infra/VerticalTabs/LeftAlignVerticalTabs/LeftAlignVerticalTabs.tsx +17 -10
  129. package/lib/infra/VerticalTabs/VerticalTabs/VerticalTabs.tsx +29 -36
  130. package/lib/infra/View/View.tsx +34 -65
  131. package/lib/template/AppShell/AppShell.css +22 -23
  132. package/lib/template/AppShell/AppShell.tsx +51 -69
  133. package/lib/template/BannerPage/BannerPage.tsx +26 -33
  134. package/lib/template/CaseSummary/CaseSummary.tsx +23 -18
  135. package/lib/template/CaseSummary/config-ext.json +1 -2
  136. package/lib/template/CaseView/CaseView.tsx +122 -114
  137. package/lib/template/CaseView/config-ext.json +1 -2
  138. package/lib/template/CaseViewActionsMenu/CaseViewActionsMenu.tsx +46 -35
  139. package/lib/template/Confirmation/Confirmation.tsx +25 -53
  140. package/lib/template/Confirmation/config-ext.json +1 -2
  141. package/lib/template/DataReference/DataReference.tsx +112 -140
  142. package/lib/template/DataReference/config-ext.json +1 -2
  143. package/lib/template/DefaultForm/DefaultForm.css +7 -3
  144. package/lib/template/DefaultForm/DefaultForm.tsx +26 -20
  145. package/lib/template/DefaultForm/config-ext.json +1 -2
  146. package/lib/template/DefaultForm/utils/index.ts +33 -0
  147. package/lib/template/Details/Details/Details.tsx +24 -28
  148. package/lib/template/Details/DetailsSubTabs/DetailsSubTabs.tsx +15 -22
  149. package/lib/template/Details/DetailsSubTabs/config-ext.json +1 -2
  150. package/lib/template/Details/DetailsThreeColumn/DetailsThreeColumn.tsx +25 -29
  151. package/lib/template/Details/DetailsThreeColumn/config-ext.json +1 -2
  152. package/lib/template/Details/DetailsTwoColumn/DetailsTwoColumn.tsx +25 -29
  153. package/lib/template/Details/DetailsTwoColumn/config-ext.json +1 -2
  154. package/lib/template/Details/DetailsTwoColumn/index.tsx +1 -1
  155. package/lib/template/Details/DynamicTabs/DynamicTabs.tsx +79 -0
  156. package/lib/template/Details/DynamicTabs/config.json +36 -0
  157. package/lib/template/Details/DynamicTabs/index.tsx +1 -0
  158. package/lib/template/FieldGroupTemplate/FieldGroupTemplate.tsx +24 -34
  159. package/lib/template/InlineDashboard/InlineDashboard.tsx +16 -14
  160. package/lib/template/InlineDashboardPage/InlineDashboardPage.tsx +19 -21
  161. package/lib/template/ListPage/ListPage.tsx +12 -16
  162. package/lib/template/ListPage/config-ext.json +1 -2
  163. package/lib/template/ListView/{DefaultViewMeta.js → DefaultViewMeta.ts} +1 -3
  164. package/lib/template/ListView/ListView.tsx +245 -306
  165. package/lib/template/ListView/config-ext.json +1 -2
  166. package/lib/template/ListView/{hooks.js → hooks.ts} +24 -24
  167. package/lib/template/ListView/{utils.js → utils.ts} +202 -91
  168. package/lib/template/MultiReferenceReadOnly/MultiReferenceReadOnly.tsx +25 -30
  169. package/lib/template/NarrowWide/NarrowWide/NarrowWide.css +0 -2
  170. package/lib/template/NarrowWide/NarrowWide/NarrowWide.tsx +31 -29
  171. package/lib/template/NarrowWide/NarrowWideDetails/NarrowWideDetails.tsx +27 -31
  172. package/lib/template/NarrowWide/NarrowWideDetails/config-ext.json +1 -2
  173. package/lib/template/NarrowWide/NarrowWideForm/NarrowWideForm.css +0 -2
  174. package/lib/template/NarrowWide/NarrowWideForm/NarrowWideForm.tsx +17 -19
  175. package/lib/template/NarrowWide/NarrowWideForm/config-ext.json +1 -2
  176. package/lib/template/NarrowWide/NarrowWidePage/NarrowWidePage.tsx +16 -26
  177. package/lib/template/NarrowWide/NarrowWidePage/config-ext.json +1 -2
  178. package/lib/template/OneColumn/OneColumn/OneColumn.tsx +17 -17
  179. package/lib/template/OneColumn/OneColumn/config-ext.json +1 -2
  180. package/lib/template/OneColumn/OneColumnPage/OneColumnPage.tsx +9 -16
  181. package/lib/template/OneColumn/OneColumnPage/config-ext.json +1 -2
  182. package/lib/template/OneColumn/OneColumnTab/OneColumnTab.tsx +8 -14
  183. package/lib/template/OneColumn/OneColumnTab/config-ext.json +1 -2
  184. package/lib/template/PromotedFilters/PromotedFilters.css +1 -1
  185. package/lib/template/PromotedFilters/PromotedFilters.tsx +44 -34
  186. package/lib/template/SimpleTable/SimpleTable/SimpleTable.tsx +115 -14
  187. package/lib/template/SimpleTable/SimpleTable/config-ext.json +1 -2
  188. package/lib/template/SimpleTable/SimpleTableManual/SimpleTableManual.tsx +171 -100
  189. package/lib/template/SimpleTable/SimpleTableSelect/SimpleTableSelect.tsx +34 -40
  190. package/lib/template/SingleReferenceReadOnly/SingleReferenceReadOnly.tsx +45 -48
  191. package/lib/template/SubTabs/SubTabs.tsx +26 -45
  192. package/lib/template/SubTabs/config-ext.json +1 -2
  193. package/lib/template/SubTabs/tabUtils.ts +2 -7
  194. package/lib/template/TwoColumn/TwoColumn/TwoColumn.css +0 -1
  195. package/lib/template/TwoColumn/TwoColumn/TwoColumn.tsx +33 -36
  196. package/lib/template/TwoColumn/TwoColumn/config-ext.json +1 -2
  197. package/lib/template/TwoColumn/TwoColumnPage/TwoColumnPage.tsx +9 -16
  198. package/lib/template/TwoColumn/TwoColumnPage/config-ext.json +1 -2
  199. package/lib/template/TwoColumn/TwoColumnTab/TwoColumnTab.tsx +33 -33
  200. package/lib/template/TwoColumn/TwoColumnTab/config-ext.json +1 -2
  201. package/lib/template/WideNarrow/WideNarrow/WideNarrow.css +0 -2
  202. package/lib/template/WideNarrow/WideNarrow/WideNarrow.tsx +29 -27
  203. package/lib/template/WideNarrow/WideNarrowDetails/WideNarrowDetails.tsx +39 -33
  204. package/lib/template/WideNarrow/WideNarrowDetails/config-ext.json +1 -2
  205. package/lib/template/WideNarrow/WideNarrowForm/WideNarrowForm.css +0 -2
  206. package/lib/template/WideNarrow/WideNarrowForm/WideNarrowForm.tsx +16 -18
  207. package/lib/template/WideNarrow/WideNarrowForm/config-ext.json +1 -2
  208. package/lib/template/WideNarrow/WideNarrowPage/WideNarrowPage.tsx +15 -25
  209. package/lib/template/WideNarrow/WideNarrowPage/config-ext.json +1 -2
  210. package/lib/template/WideNarrow/WideNarrowPage/index.tsx +1 -1
  211. package/lib/template/WssNavBar/WssNavBar.tsx +33 -17
  212. package/lib/widget/AppAnnouncement/AppAnnouncement.tsx +34 -41
  213. package/lib/widget/AppAnnouncement/config-ext.json +1 -2
  214. package/lib/widget/Attachment/Attachment.css +75 -4
  215. package/lib/widget/Attachment/Attachment.tsx +370 -388
  216. package/lib/widget/Attachment/index.tsx +1 -1
  217. package/lib/widget/CaseHistory/CaseHistory.tsx +67 -67
  218. package/lib/widget/CaseHistory/config-ext.json +1 -2
  219. package/lib/widget/CaseHistory/index.tsx +1 -1
  220. package/lib/widget/FileUtility/ActionButtonsForFileUtil/ActionButtonsForFileUtil.tsx +19 -9
  221. package/lib/widget/FileUtility/FileUtility/FileUtility.css +2 -2
  222. package/lib/widget/FileUtility/FileUtility/FileUtility.tsx +324 -246
  223. package/lib/widget/FileUtility/FileUtility/config-ext.json +1 -2
  224. package/lib/widget/Followers/Followers.tsx +27 -25
  225. package/lib/widget/Followers/config-ext.json +1 -2
  226. package/lib/widget/QuickCreate/QuickCreate.tsx +24 -16
  227. package/lib/widget/SummaryItem/SummaryItem.css +9 -9
  228. package/lib/widget/SummaryItem/SummaryItem.tsx +62 -54
  229. package/lib/widget/SummaryItem/index.tsx +1 -1
  230. package/lib/widget/SummaryList/SummaryList.tsx +15 -4
  231. package/lib/widget/ToDo/ToDo.css +4 -4
  232. package/lib/widget/ToDo/ToDo.tsx +80 -116
  233. package/lib/widget/ToDo/config-ext.json +1 -2
  234. package/package.json +5 -2
  235. package/lib/helpers/auth.js +0 -483
  236. package/lib/helpers/authManager.js +0 -631
  237. package/lib/helpers/config_access.js +0 -268
  238. package/lib/helpers/formatters/Boolean.js +0 -38
  239. package/lib/helpers/formatters/CurrencyMap.js +0 -908
  240. package/lib/infra/Containers/FlowContainer/helpers.js +0 -147
@@ -1,21 +1,18 @@
1
- import dayjs from "dayjs";
2
- import relativeTime from "dayjs/plugin/relativeTime";
3
- import localizedFormat from "dayjs/plugin/localizedFormat";
4
- import utc from "dayjs/plugin/utc";
5
- import tzone from "dayjs/plugin/timezone";
1
+ import dayjs from 'dayjs';
2
+ import relativeTime from 'dayjs/plugin/relativeTime';
3
+ import localizedFormat from 'dayjs/plugin/localizedFormat';
4
+ import utc from 'dayjs/plugin/utc';
5
+ import tzone from 'dayjs/plugin/timezone';
6
6
 
7
7
  dayjs.extend(relativeTime);
8
8
  dayjs.extend(localizedFormat);
9
9
  dayjs.extend(utc);
10
10
  dayjs.extend(tzone);
11
11
 
12
- const types = ["fromNow", "customFormat"];
12
+ const types = ['fromNow', 'customFormat'];
13
13
 
14
14
  // value should be in ISO 8601 format.
15
- function DateFormatter(
16
- value,
17
- { type = types[1], format = "DD/MM/YYYY", timezone } = {}
18
- ) {
15
+ function DateFormatter(value: string, { type = types[1], format = 'DD/MM/YYYY', timezone = 'America/New_York' } = {}) {
19
16
  if (!value) return value;
20
17
  switch (type) {
21
18
  case types[1]:
@@ -30,7 +27,7 @@ function DateFormatter(
30
27
  // value should be in hh:mm:ss format (00:00:00 - 23:59:59).
31
28
  function TimeFormatter(value, options) {
32
29
  if (!value) return value;
33
- const { locale = "en-US" } = options;
30
+ const { locale = 'en-US' } = options;
34
31
  const timeOnlyRegex = /^(?:[01]\d|2[0123]):(?:[012345]\d):(?:[012345]\d)$/;
35
32
  if (value.length === 8 && timeOnlyRegex.test(value)) {
36
33
  const tempDate = new Date();
@@ -46,32 +43,29 @@ function TimeFormatter(value, options) {
46
43
  }
47
44
 
48
45
  export default {
49
- "DateTime-Long": (value, options) =>
50
- DateFormatter(value, { ...options, type: "customFormat", format: "LLL" }),
51
- "DateTime-Short": (value, options) =>
46
+ 'DateTime-Long': (value, options) => DateFormatter(value, { ...options, type: 'customFormat', format: 'LLL' }),
47
+ 'DateTime-Short': (value, options) =>
52
48
  DateFormatter(value, {
53
49
  ...options,
54
- type: "customFormat",
55
- format: "MMM DD, YYYY"
50
+ type: 'customFormat',
51
+ format: 'MMM DD, YYYY'
56
52
  }),
57
- "DateTime-Since": (value) => DateFormatter(value, { type: "fromNow" }),
58
- "Time-Only": (value, options) =>
53
+ 'DateTime-Since': value => DateFormatter(value, { type: 'fromNow' }),
54
+ 'Time-Only': (value, options) =>
59
55
  TimeFormatter(value, {
60
56
  ...options,
61
- type: "customFormat",
62
- format: "hh:mm:ss A"
57
+ type: 'customFormat',
58
+ format: 'hh:mm:ss A'
63
59
  }),
64
60
  convertToTimezone: (value, options) => {
65
61
  return value && options && options.timezone
66
62
  ? DateFormatter(value, {
67
63
  ...options,
68
- type: "customFormat",
69
- format: "YYYY-MM-DDTHH:mm:ss"
64
+ type: 'customFormat',
65
+ format: 'YYYY-MM-DDTHH:mm:ss'
70
66
  })
71
67
  : value;
72
68
  },
73
- convertFromTimezone: (value, timezone) =>
74
- value && timezone ? dayjs.tz(value, timezone).utc().format() : value,
75
- Date: (value, options) =>
76
- DateFormatter(value, { type: "customFormat", ...options })
69
+ convertFromTimezone: (value, timezone) => (value && timezone ? dayjs.tz(value, timezone).utc().format() : value),
70
+ Date: (value, options) => DateFormatter(value, { type: 'customFormat', ...options })
77
71
  };
@@ -1,14 +1,13 @@
1
- export function getLocale(locale) {
1
+ export function getLocale(locale: string = '') {
2
2
  // use locale if specified
3
3
  if (locale) return locale;
4
4
  // otherwise, use operator locale if it's defined
5
- if (window.PCore.getEnvironmentInfo().getUseLocale()) return window.PCore.getEnvironmentInfo().getUseLocale();
5
+ if (PCore.getEnvironmentInfo().getLocale()) return PCore.getEnvironmentInfo().getLocale();
6
6
  // fallback
7
7
  return Intl.DateTimeFormat().resolvedOptions().locale;
8
8
  }
9
9
 
10
- export function getCurrentTimezone(timezone) {
10
+ export function getCurrentTimezone(timezone: string = 'America/New_York') {
11
11
  if (timezone) return timezone;
12
- // eslint-disable-next-line no-undef
13
12
  return PCore?.getLocaleUtils?.().getTimeZoneInUse?.();
14
13
  }
@@ -1,7 +1,7 @@
1
- import Boolean from "./Boolean";
2
- import Currency from "./Currency";
3
- import DateFormatter from "./Date";
4
- import { getCurrentTimezone, getLocale } from "./common";
1
+ import Boolean from './Boolean';
2
+ import Currency from './Currency';
3
+ import DateFormatter from './Date';
4
+ import { getCurrentTimezone, getLocale } from './common';
5
5
 
6
6
  export default {
7
7
  ...Boolean,
@@ -9,10 +9,10 @@ export default {
9
9
  ...DateFormatter
10
10
  };
11
11
 
12
- function getDateObject(text) {
12
+ function getDateObject(text): Date {
13
13
  // TODO - cleanup formatters util functions as DX APIs are returning values per ISO std now.
14
- const timeStamp = text.replace(/-/g, "");
15
- const isDateTime = timeStamp.indexOf("GMT") !== -1;
14
+ const timeStamp = text.replace(/-/g, '');
15
+ const isDateTime = timeStamp.indexOf('GMT') !== -1;
16
16
  const year = parseInt(timeStamp.substr(0, 4), 10);
17
17
  const month = parseInt(timeStamp.substr(4, 2), 10) - 1;
18
18
  const day = parseInt(timeStamp.substr(6, 2), 10);
@@ -44,7 +44,7 @@ function isIsoDate(str) {
44
44
  }
45
45
 
46
46
  function parseDateInISO(value) {
47
- const isMilliSeconds = new RegExp("^[0-9]+$").exec(value);
47
+ const isMilliSeconds = /^[0-9]+$/.exec(value);
48
48
  if (isMilliSeconds) {
49
49
  const date = new Date(parseInt(value, 10));
50
50
  return date.toISOString();
@@ -58,14 +58,14 @@ function parseDateInISO(value) {
58
58
  return value ? getDateObject(value).toISOString() : value;
59
59
  }
60
60
 
61
- export function format(value, type, options = {}) {
62
- let formattedValue;
61
+ export function format(value, type, options = {}): string {
62
+ let formattedValue: string;
63
63
 
64
64
  switch (type?.toLowerCase()) {
65
- case "currency": {
65
+ case 'currency': {
66
66
  const defaultOptions = {
67
67
  locale: getLocale(),
68
- position: "before",
68
+ position: 'before',
69
69
  decPlaces: 2
70
70
  };
71
71
  const params = { ...defaultOptions, ...options };
@@ -73,23 +73,23 @@ export function format(value, type, options = {}) {
73
73
  break;
74
74
  }
75
75
 
76
- case "decimal": {
76
+ case 'decimal': {
77
77
  const defaultOptions = { locale: getLocale(), decPlaces: 2 };
78
78
  const params = { ...defaultOptions, ...options };
79
79
  formattedValue = Currency.Decimal(value, params);
80
80
  break;
81
81
  }
82
82
 
83
- case "integer": {
83
+ case 'integer': {
84
84
  const defaultOptions = { locale: getLocale() };
85
85
  const params = { ...defaultOptions, ...options };
86
86
  formattedValue = Currency.Integer(value, params);
87
87
  break;
88
88
  }
89
89
 
90
- case "date": {
90
+ case 'date': {
91
91
  const defaultOptions = {
92
- format: "MMM DD, YYYY",
92
+ format: 'MMM DD, YYYY',
93
93
  timezone: getCurrentTimezone()
94
94
  };
95
95
  const params = { ...defaultOptions, ...options };
@@ -97,9 +97,9 @@ export function format(value, type, options = {}) {
97
97
  break;
98
98
  }
99
99
 
100
- case "datetime": {
100
+ case 'datetime': {
101
101
  const defaultOptions = {
102
- format: "MMM DD, YYYY h:mm A",
102
+ format: 'MMM DD, YYYY h:mm A',
103
103
  timezone: getCurrentTimezone()
104
104
  };
105
105
  const params = { ...defaultOptions, ...options };
@@ -107,13 +107,13 @@ export function format(value, type, options = {}) {
107
107
  break;
108
108
  }
109
109
 
110
- case "boolean":
111
- case "checkbox": {
112
- formattedValue = Boolean.TrueFalse(value, { allowEmpty: false });
110
+ case 'boolean':
111
+ case 'checkbox': {
112
+ formattedValue = Boolean.TrueFalse(value, { allowEmpty: false, ...options });
113
113
  break;
114
114
  }
115
115
 
116
- case "userreference": {
116
+ case 'userreference': {
117
117
  formattedValue = value.userName;
118
118
  break;
119
119
  }
@@ -1,4 +1,4 @@
1
- import { createContext, useContext } from "react";
1
+ import { createContext, useContext } from 'react';
2
2
 
3
3
  // This file contains a shared access point for any React contexts that may need to be
4
4
  // defined/used across various components.
@@ -6,5 +6,5 @@ import { createContext, useContext } from "react";
6
6
  // For example, the AppShell wants to use a NavContext that interacts with
7
7
  // that context's consumption in the NavBar to handle clicks for opening/closing
8
8
  // aspects of the NavBar
9
- export const NavContext = createContext({open: false, setOpen: f => f});
9
+ export const NavContext = createContext({ open: false, setOpen: f => f });
10
10
  export const useNavBar = () => useContext(NavContext);
@@ -1,38 +1,36 @@
1
1
  import { Utils } from './utils';
2
2
 
3
- declare const PCore;
4
-
5
- export const TABLE_CELL = "SdkRenderer";
6
- export const DELETE_ICON = "DeleteIcon";
3
+ export const TABLE_CELL = 'SdkRenderer';
4
+ export const DELETE_ICON = 'DeleteIcon';
7
5
 
8
6
  // BUG-615253: Workaround for autosize in table with lazy loading components
9
7
  /* istanbul ignore next */
10
8
  function getFieldWidth(field, label) {
11
- let width;
9
+ let width: number;
12
10
  switch (field.type) {
13
- case "Time":
11
+ case 'Time':
14
12
  width = 150;
15
13
  break;
16
- case "Date":
14
+ case 'Date':
17
15
  width = 160;
18
16
  break;
19
- case "DateTime":
17
+ case 'DateTime':
20
18
  width = 205;
21
19
  break;
22
- case "AutoComplete":
23
- case "TextArea":
20
+ case 'AutoComplete':
21
+ case 'TextArea':
24
22
  width = 190;
25
23
  break;
26
- case "Currency":
27
- case "TextInput":
24
+ case 'Currency':
25
+ case 'TextInput':
28
26
  width = 182;
29
27
  break;
30
- case "Checkbox":
28
+ case 'Checkbox':
31
29
  // eslint-disable-next-line no-case-declarations
32
- const text = document.createElement("span");
30
+ const text = document.createElement('span');
33
31
  document.body.appendChild(text);
34
- text.style.fontSize = "13px";
35
- text.style.position = "absolute";
32
+ text.style.fontSize = '13px';
33
+ text.style.position = 'absolute';
36
34
  text.innerHTML = label;
37
35
  width = Math.ceil(text.clientWidth) + 30;
38
36
  document.body.removeChild(text);
@@ -43,19 +41,18 @@ function getFieldWidth(field, label) {
43
41
  return width;
44
42
  }
45
43
 
46
- export const getContext = (thePConn) => {
44
+ export const getContext = thePConn => {
47
45
  const contextName = thePConn.getContextName();
48
46
  const pageReference = thePConn.getPageReference();
49
- let { referenceList } = thePConn.getStateProps().config;
50
- const pageReferenceForRows = referenceList.startsWith(".")
51
- ? `${pageReference}.${referenceList.substring(1)}`
52
- : referenceList;
47
+ const { referenceList } = thePConn.getStateProps()?.config || thePConn.getStateProps();
48
+ const pageReferenceForRows = referenceList.startsWith('.') ? `${pageReference}.${referenceList.substring(1)}` : referenceList;
53
49
 
54
50
  // removing "caseInfo.content" prefix to avoid setting it as a target while preparing pageInstructions
55
- referenceList = pageReferenceForRows.replace(
56
- PCore.getConstants().CASE_INFO.CASE_INFO_CONTENT,
57
- ""
58
- );
51
+ // skipping the removal as StateMachine itself is removing this case info prefix while preparing pageInstructions
52
+ // referenceList = pageReferenceForRows.replace(
53
+ // PCore.getConstants().CASE_INFO.CASE_INFO_CONTENT,
54
+ // ""
55
+ // );
59
56
 
60
57
  return {
61
58
  contextName,
@@ -64,8 +61,8 @@ export const getContext = (thePConn) => {
64
61
  };
65
62
  };
66
63
 
67
- export const populateRowKey = (rawData) => {
68
- return rawData.map((row, index) => {
64
+ export const populateRowKey = rawData => {
65
+ return rawData.map((row: any, index: number) => {
69
66
  return { ...row, index };
70
67
  });
71
68
  };
@@ -73,7 +70,7 @@ export const populateRowKey = (rawData) => {
73
70
  export const getApiContext = (processedData, pConnect, reorderCB) => {
74
71
  return {
75
72
  fetchData: () => {
76
- return new Promise((resolve) => {
73
+ return new Promise(resolve => {
77
74
  resolve({
78
75
  data: processedData,
79
76
  filteredRecordCount: processedData.length,
@@ -87,24 +84,12 @@ export const getApiContext = (processedData, pConnect, reorderCB) => {
87
84
  applyRowReorder: (sourceKey, destinationKey) => {
88
85
  // indexes are keys for simple table so, it should work.
89
86
  reorderCB();
90
- return Promise.resolve(
91
- pConnect
92
- .getListActions()
93
- .reorder(parseInt(sourceKey, 10), parseInt(destinationKey, 10))
94
- );
87
+ return Promise.resolve(pConnect.getListActions().reorder(parseInt(sourceKey, 10), parseInt(destinationKey, 10)));
95
88
  }
96
89
  };
97
90
  };
98
91
 
99
- export const buildMetaForListView = (
100
- fieldMetadata,
101
- fields,
102
- type,
103
- ruleClass,
104
- name,
105
- propertyLabel,
106
- parameters
107
- ) => {
92
+ export const buildMetaForListView = (fieldMetadata, fields, type, ruleClass, name, propertyLabel, isDataObject, parameters) => {
108
93
  return {
109
94
  name,
110
95
  config: {
@@ -112,26 +97,28 @@ export const buildMetaForListView = (
112
97
  referenceList: fieldMetadata.datasource.name,
113
98
  parameters: parameters ?? fieldMetadata.datasource.parameters,
114
99
  personalization: false,
100
+ isDataObject,
115
101
  grouping: true,
116
102
  globalSearch: true,
117
103
  reorderFields: true,
118
104
  toggleFieldVisibility: true,
119
- personalizationId: "" /* TODO */,
120
- template: "ListView",
105
+ title: propertyLabel,
106
+ personalizationId: '' /* TODO */,
107
+ template: 'ListView',
121
108
  presets: [
122
109
  {
123
- name: "presets",
124
- template: "Table",
110
+ name: 'presets',
111
+ template: 'Table',
125
112
  config: {},
126
113
  children: [
127
114
  {
128
- name: "Columns",
129
- type: "Region",
115
+ name: 'Columns',
116
+ type: 'Region',
130
117
  children: fields
131
118
  }
132
119
  ],
133
120
  label: propertyLabel,
134
- id: "P_" /* TODO */
121
+ id: 'P_' /* TODO */
135
122
  }
136
123
  ],
137
124
  ruleClass
@@ -142,7 +129,7 @@ export const buildMetaForListView = (
142
129
  export const buildFieldsForTable = (configFields, fields, showDeleteButton) => {
143
130
  const fieldDefs = configFields.map((field, index) => {
144
131
  return {
145
- type: "text",
132
+ type: 'text',
146
133
  label: fields[index].config.label || fields[index].config.caption,
147
134
  fillAvailableSpace: !!field.config.fillAvailableSpace,
148
135
  id: index,
@@ -162,7 +149,7 @@ export const buildFieldsForTable = (configFields, fields, showDeleteButton) => {
162
149
  // ONLY add DELETE_ICON to fields when the table is requested as EDITABLE
163
150
  if (showDeleteButton) {
164
151
  fieldDefs.push({
165
- type: "text",
152
+ type: 'text',
166
153
  id: fieldDefs.length,
167
154
  cellRenderer: DELETE_ICON,
168
155
  sort: false,
@@ -179,17 +166,17 @@ export const buildFieldsForTable = (configFields, fields, showDeleteButton) => {
179
166
  export const createMetaForTable = (fields, renderMode) => {
180
167
  return {
181
168
  height: {
182
- minHeight: "auto",
183
- fitHeightToElement: "fitHeightToElement",
184
- deltaAdjustment: "deltaAdjustment",
169
+ minHeight: 'auto',
170
+ fitHeightToElement: 'fitHeightToElement',
171
+ deltaAdjustment: 'deltaAdjustment',
185
172
  autoSize: true
186
173
  },
187
174
  fieldDefs: fields,
188
- itemKey: "index",
175
+ itemKey: 'index',
189
176
  grouping: false,
190
177
  reorderFields: false,
191
- reorderItems: renderMode === "Editable",
192
- dragHandle: renderMode === "Editable",
178
+ reorderItems: renderMode === 'Editable',
179
+ dragHandle: renderMode === 'Editable',
193
180
  globalSearch: false,
194
181
  personalization: false,
195
182
  toggleFieldVisibility: false,
@@ -207,7 +194,7 @@ export const createMetaForTable = (fields, renderMode) => {
207
194
  * @param {number} index - index of the page list to add
208
195
  */
209
196
  export const getAddRowCallback = (pConnect, index) => {
210
- return () => pConnect.getListActions().insert({}, index);
197
+ return () => pConnect.getListActions().insert({}, index, ''); // 3rd arg null until typedef marked correctly as optional
211
198
  };
212
199
 
213
200
  /**
@@ -216,7 +203,9 @@ export const getAddRowCallback = (pConnect, index) => {
216
203
  * @param {string} referenceList - referenceList
217
204
  * @param {string} pageReference - pageReference
218
205
  */
219
- export const createPConnect = (contextName, referenceList, pageReference) => {
206
+ // NOTE: use of type "any" is required since TypeScript doesn't allow private/protected properties
207
+ // to be exported from a class (TS4094 error)
208
+ export function createPConnect(contextName, referenceList, pageReference): any {
220
209
  const options = {
221
210
  context: contextName,
222
211
  pageReference,
@@ -228,17 +217,13 @@ export const createPConnect = (contextName, referenceList, pageReference) => {
228
217
  const { getPConnect } = PCore.createPConnect(config);
229
218
 
230
219
  return getPConnect();
231
- };
220
+ }
232
221
 
233
- export const filterData = (filterByColumns) => {
222
+ export const filterData = filterByColumns => {
234
223
  return function filteringData(item) {
235
224
  let bKeep = true;
236
225
  for (const filterObj of filterByColumns) {
237
- if (
238
- filterObj.containsFilterValue !== '' ||
239
- filterObj.containsFilter === 'null' ||
240
- filterObj.containsFilter === 'notnull'
241
- ) {
226
+ if (filterObj.containsFilterValue !== '' || filterObj.containsFilter === 'null' || filterObj.containsFilter === 'notnull') {
242
227
  let value: any;
243
228
  let filterValue: any;
244
229
 
@@ -246,14 +231,9 @@ export const filterData = (filterByColumns) => {
246
231
  case 'Date':
247
232
  case 'DateTime':
248
233
  case 'Time':
249
- value =
250
- item[filterObj.ref] !== null ?? item[filterObj.ref] !== ''
251
- ? Utils.getSeconds(item[filterObj.ref])
252
- : null;
234
+ value = item[filterObj.ref] !== null ?? item[filterObj.ref] !== '' ? Utils.getSeconds(item[filterObj.ref]) : null;
253
235
  filterValue =
254
- filterObj.containsFilterValue !== null && filterObj.containsFilterValue !== ''
255
- ? Utils.getSeconds(filterObj.containsFilterValue)
256
- : null;
236
+ filterObj.containsFilterValue !== null && filterObj.containsFilterValue !== '' ? Utils.getSeconds(filterObj.containsFilterValue) : null;
257
237
 
258
238
  // eslint-disable-next-line sonarjs/no-nested-switch
259
239
  switch (filterObj.containsFilter) {
@@ -274,20 +254,20 @@ export const filterData = (filterByColumns) => {
274
254
  break;
275
255
 
276
256
  case 'equal':
277
- // becasue filterValue is in minutes, need to have a range of less than 60 secons
257
+ // becasue filterValue is in minutes, need to have a range of less than 60 secons
278
258
 
279
- if (value !== null && filterValue !== null) {
280
- // get rid of milliseconds
281
- value /= 1000;
282
- filterValue /= 1000;
259
+ if (value !== null && filterValue !== null) {
260
+ // get rid of milliseconds
261
+ value /= 1000;
262
+ filterValue /= 1000;
283
263
 
284
- const diff = value - filterValue;
285
- if (diff !== 0) {
286
- bKeep = false;
287
- }
264
+ const diff = value - filterValue;
265
+ if (diff !== 0) {
266
+ bKeep = false;
288
267
  }
268
+ }
289
269
 
290
- break;
270
+ break;
291
271
 
292
272
  case 'after':
293
273
  if (value < filterValue) {
@@ -356,5 +336,5 @@ export const filterData = (filterByColumns) => {
356
336
  }
357
337
  }
358
338
  return bKeep;
359
- }
360
- }
339
+ };
340
+ };
@@ -0,0 +1,43 @@
1
+ import { useContext } from 'react';
2
+ import { connect, Provider, shallowEqual } from 'react-redux';
3
+
4
+ import ReactReduxContext from '@pega/react-sdk-components/lib/bridge/Context/StoreContext';
5
+
6
+ const connectToState = (mapStateToProps = () => {}) => {
7
+ return (Component: any) => {
8
+ const ConnectedComponent = connect(mapStateToProps, null, null, {
9
+ areStatePropsEqual: (next, prev: any) => {
10
+ // Compare visibility
11
+ const prevWasVisible = prev.visibility !== false;
12
+ if (next.visibility !== undefined && next.visibility !== prevWasVisible) {
13
+ return false;
14
+ }
15
+ // Compare start props
16
+ const c11nEnv = next.getPConnect();
17
+ const allStateProps = c11nEnv.getStateProps();
18
+ for (const key of Object.keys(allStateProps)) {
19
+ if (!shallowEqual(next[key], prev[key]) || (next.routingInfo && !PCore.isDeepEqual(next.routingInfo, prev.routingInfo))) {
20
+ return false;
21
+ }
22
+ }
23
+ /* TODO For some rawConfig we are not getting routingInfo under allStateProps */
24
+ return !(
25
+ 'routingInfo' in next &&
26
+ (!shallowEqual(next.routingInfo, prev.routingInfo) || !PCore.isDeepEqual(next.routingInfo, prev.routingInfo))
27
+ );
28
+ }
29
+ })(Component);
30
+
31
+ return (ownProps = {}) => {
32
+ const { store } = useContext<any>(ReactReduxContext);
33
+
34
+ return (
35
+ <Provider store={store}>
36
+ <ConnectedComponent {...ownProps} />
37
+ </Provider>
38
+ );
39
+ };
40
+ };
41
+ };
42
+
43
+ export default connectToState;
@@ -1,10 +1,8 @@
1
1
  // This file is adapted from React DX components/template/utils.js
2
2
 
3
- declare const PCore: any;
4
-
5
3
  export function getAllFields(pConnect: any) {
6
4
  const metadata = pConnect.getRawMetadata();
7
- let allFields = [];
5
+ let allFields: any[] = [];
8
6
  if (metadata.children && metadata.children.map) {
9
7
  allFields = metadata.children.map(fields => {
10
8
  const children = fields.children instanceof Array ? fields.children : [];
@@ -14,7 +12,7 @@ export function getAllFields(pConnect: any) {
14
12
  return allFields;
15
13
  }
16
14
 
17
- export function filterForFieldValueList(fields: any) {
15
+ export function filterForFieldValueList(fields: any[]) {
18
16
  return fields
19
17
  .filter(({ visibility }) => visibility !== false)
20
18
  .map(({ value, label }) => ({
@@ -47,10 +45,8 @@ export function getIsAssignmentView(pConnect) {
47
45
  * @param {Function} pConnect PConnect object for the component
48
46
  * @param {string} [instructions="casestep"] 'casestep', 'none', or the html content of a Rule-UI-Paragraph rule (processed via core's paragraph annotation handler)
49
47
  */
50
- export function getInstructions(pConnect, instructions = 'casestep') {
51
- const caseStepInstructions =
52
- PCore.getConstants().CASE_INFO.INSTRUCTIONS &&
53
- pConnect.getValue(PCore.getConstants().CASE_INFO.INSTRUCTIONS);
48
+ export function getInstructions(pConnect, instructions: string = 'casestep'): string | undefined {
49
+ const caseStepInstructions = PCore.getConstants().CASE_INFO.INSTRUCTIONS && pConnect.getValue(PCore.getConstants().CASE_INFO.INSTRUCTIONS);
54
50
 
55
51
  // Determine if this view is the current assignment/step view
56
52
  const isCurrentAssignmentView = getIsAssignmentView(pConnect);
@@ -2,13 +2,25 @@ import dayjs from 'dayjs';
2
2
  import customParseFormat from 'dayjs/plugin/customParseFormat';
3
3
  import localizedFormat from 'dayjs/plugin/localizedFormat';
4
4
  import relativeTime from 'dayjs/plugin/relativeTime';
5
+ import { SdkConfigAccess } from '@pega/auth/lib/sdk-auth-manager';
5
6
 
6
7
  dayjs.extend(customParseFormat);
7
8
  dayjs.extend(localizedFormat);
8
9
  dayjs.extend(relativeTime);
9
10
 
10
11
  export class Utils {
11
- static lastControlID: number = 0;
12
+ static lastControlID = 0;
13
+
14
+ static getSDKStaticConentUrl() {
15
+ const sdkConfigServer = SdkConfigAccess.getSdkConfigServer();
16
+
17
+ // NOTE: Needs a trailing slash! So add one if not provided
18
+ if (!sdkConfigServer.sdkContentServerUrl.endsWith('/')) {
19
+ sdkConfigServer.sdkContentServerUrl = `${sdkConfigServer.sdkContentServerUrl}/`;
20
+ }
21
+
22
+ return `${sdkConfigServer.sdkContentServerUrl}constellation/`;
23
+ }
12
24
 
13
25
  static getUniqueControlID(): string {
14
26
  const sPrefix = 'control-';
@@ -18,9 +30,9 @@ export class Utils {
18
30
  return sPrefix + this.lastControlID.toString();
19
31
  }
20
32
 
21
- static getOptionList(configProps: any, dataObject: any): Array<any> {
33
+ static getOptionList(configProps: any, dataObject: any): any[] {
22
34
  const listType = configProps.listType;
23
- let arReturn: Array<any> = [];
35
+ let arReturn: any[] = [];
24
36
 
25
37
  if (listType) {
26
38
  switch (listType.toLowerCase()) {
@@ -35,7 +47,7 @@ export class Utils {
35
47
  // get data page
36
48
  // eslint-disable-next-line no-case-declarations
37
49
  const dataPage = configProps.datasource;
38
- if (dataObject[dataPage]) {
50
+ if (typeof dataPage === 'string' && dataObject[dataPage]) {
39
51
  // eslint-disable-next-line no-alert
40
52
  alert('need to handle data page');
41
53
  } else {
@@ -322,10 +334,6 @@ export class Utils {
322
334
  return text.charAt(text.length - 1);
323
335
  }
324
336
 
325
- static isEmptyObject(obj: Object): Boolean {
326
- return Object.keys(obj).length === 0;
327
- }
328
-
329
337
  static isObject(objValue) {
330
338
  return objValue && typeof objValue === 'object' && objValue.constructor === Object;
331
339
  }