@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
@@ -0,0 +1,99 @@
1
+ import { getComponentFromMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
2
+
3
+ /**
4
+ * Function that accepts array of messages as input and group them by their type and returns the resulting object
5
+ * @param {Array} inputMessages
6
+ * Eg: [
7
+ * {message: 'First Name is required', type: 'error'},
8
+ * {message: 'Last Name is required', type: 'error'},
9
+ * {message: 'Address field should be clear and precise', type: 'info'}
10
+ * ]
11
+ *
12
+ * @returns {object}
13
+ *
14
+ * Eg: {
15
+ * error: ['First Name is required', 'Last Name is required'],
16
+ * info: ['Address field should be clear and precise']
17
+ * }
18
+ */
19
+
20
+ function getMessagesGrouped(inputMessages) {
21
+ const messages = {};
22
+
23
+ if (inputMessages && inputMessages instanceof Array && inputMessages.length > 0) {
24
+ inputMessages.forEach(item => {
25
+ const { message, type } = item;
26
+ messages[type] = [...(messages[type] || []), message];
27
+ });
28
+ }
29
+ return messages;
30
+ }
31
+
32
+ /**
33
+ * Function accepts a error type and variant of the banner
34
+ * @param {string} type
35
+ * Eg: 'error'
36
+ * @returns {string}
37
+ * Eg: 'urgent'
38
+ */
39
+ function getVariant(type) {
40
+ const { BANNER_VARIANT_SUCCESS, BANNER_VARIANT_INFO, BANNER_VARIANT_URGENT, MESSAGES } = PCore.getConstants();
41
+ const { MESSAGES_TYPE_ERROR, MESSAGES_TYPE_INFO, MESSAGES_TYPE_SUCCESS } = MESSAGES;
42
+
43
+ let variant;
44
+ switch (type) {
45
+ case MESSAGES_TYPE_ERROR:
46
+ variant = BANNER_VARIANT_URGENT;
47
+ break;
48
+ case MESSAGES_TYPE_INFO:
49
+ variant = BANNER_VARIANT_INFO;
50
+ break;
51
+ case MESSAGES_TYPE_SUCCESS:
52
+ variant = BANNER_VARIANT_SUCCESS;
53
+ break;
54
+ default:
55
+ variant = '';
56
+ }
57
+ return variant;
58
+ }
59
+
60
+ function getBanners(config) {
61
+ const AlertBanner = getComponentFromMap('AlertBanner');
62
+ const { target, pageMessages, httpMessages } = config;
63
+ const { PAGE } = PCore.getConstants();
64
+ const { clearMessages } = PCore.getMessageManager();
65
+ const banners: any = [];
66
+ const groupedPageMessages = getMessagesGrouped(pageMessages);
67
+
68
+ Object.keys(groupedPageMessages).forEach(type => {
69
+ const messagesByType = groupedPageMessages[type];
70
+ const variant = getVariant(type);
71
+ const pageMessagesBannerID = `${target}_${PAGE}_${type}`.toLowerCase().replace('/', '_');
72
+ banners.push(
73
+ <AlertBanner
74
+ id={pageMessagesBannerID}
75
+ variant={variant}
76
+ messages={messagesByType}
77
+ onDismiss={
78
+ variant === 'urgent'
79
+ ? ''
80
+ : () => {
81
+ clearMessages({
82
+ category: PAGE,
83
+ type,
84
+ context: target
85
+ } as any);
86
+ }
87
+ }
88
+ />
89
+ );
90
+ });
91
+
92
+ if (httpMessages && httpMessages.length > 0) {
93
+ banners.push(<AlertBanner id='modalViewContainerBanner' variant='urgent' messages={httpMessages} />);
94
+ }
95
+
96
+ return banners;
97
+ }
98
+
99
+ export { getMessagesGrouped, getBanners };
@@ -0,0 +1,8 @@
1
+ export function isEmptyObject(obj: Object): boolean {
2
+ return Object.keys(obj).length === 0;
3
+ }
4
+
5
+ export function isInfinity23OrHigher() {
6
+ const pCoreVersion = PCore.getPCoreVersion();
7
+ return ['8.23.0', '23.1.1'].includes(pCoreVersion);
8
+ }
@@ -1,16 +1,13 @@
1
- declare const PCore;
2
-
3
1
  // eslint-disable-next-line import/prefer-default-export
4
2
  export const getDataPage = (dataPageName, parameters, context) => {
5
3
  let dataViewParams;
6
- if(parameters){
4
+ if (parameters) {
7
5
  dataViewParams = {
8
- 'dataViewParameters': parameters
6
+ dataViewParameters: parameters
9
7
  };
10
8
  }
11
9
  return new Promise((resolve, reject) => {
12
- PCore.getDataApiUtils()
13
- .getData(dataPageName, dataViewParams, context)
10
+ (PCore.getDataApiUtils().getData(dataPageName, dataViewParams, context) as any)
14
11
  .then(response => {
15
12
  resolve(response.data.data);
16
13
  })
@@ -1,16 +1,17 @@
1
1
  import { getLocale } from './formatters/common';
2
2
 
3
-
4
3
  export const dateFormatInfoDefault = {
5
- dateFormatString: "MM/DD/YYYY",
6
- dateFormatStringLong: "MMM DD, YYYY",
7
- dateFormatStringLC: "mm/dd/yyyy",
8
- dateFormatMask: "__/__/____"
9
- }
4
+ dateFormatString: 'MM/DD/YYYY',
5
+ dateFormatStringLong: 'MMM DD, YYYY',
6
+ dateFormatStringLC: 'mm/dd/yyyy',
7
+ dateFormatMask: '__/__/____'
8
+ };
10
9
 
11
- export const getDateFormatInfo = () => {
10
+ export const getDateFormatInfo = (): typeof dateFormatInfoDefault => {
11
+ const localizedVal = PCore.getLocaleUtils().getLocaleValue;
12
+ const localeCategory = 'CosmosFields';
12
13
  const theDateFormatInfo = dateFormatInfoDefault;
13
- const theLocale = getLocale(); // PCore.getEnvironmentInfo().getUseLocale() || "US-en";
14
+ const theLocale = getLocale();
14
15
 
15
16
  // NOTE: this date was chosen since it has a day larger than 12. If you change it,
16
17
  // you'll need to change the indexOf values below!
@@ -25,29 +26,38 @@ export const getDateFormatInfo = () => {
25
26
  const locDD = theTestDateLocaleString.indexOf('30');
26
27
  const locYYYY = theTestDateLocaleString.indexOf('2023');
27
28
 
29
+ // If localized placeholder exists for one of day/month/year then show it otherwise fall back to ddmmyyyy
30
+ const localizedPlaceholderExists =
31
+ localizedVal('month_placeholder', localeCategory) !== 'month_placeholder' ||
32
+ localizedVal('day_placeholder', localeCategory) !== 'day_placeholder' ||
33
+ localizedVal('year_placeholder', localeCategory) !== 'year_placeholder';
34
+
28
35
  const arrPieces = [
29
36
  {
30
37
  loc: locMM,
31
38
  format: 'MM',
32
39
  longFormat: 'MMM',
33
- placeholder: 'mm',
34
- mask: '__'
40
+ placeholder: localizedPlaceholderExists ? localizedVal('month_placeholder', localeCategory) : 'mm',
41
+ mask: '__',
42
+ separator: theTestDateLocaleString[locMM + 2]
35
43
  },
36
44
  {
37
45
  loc: locDD,
38
46
  format: 'DD',
39
47
  longFormat: 'DD',
40
- placeholder: 'dd',
41
- mask: '__'
48
+ placeholder: localizedPlaceholderExists ? localizedVal('day_placeholder', localeCategory) : 'dd',
49
+ mask: '__',
50
+ separator: theTestDateLocaleString[locDD + 2]
42
51
  },
43
52
  {
44
53
  loc: locYYYY,
45
54
  format: 'YYYY',
46
55
  longFormat: 'YYYY',
47
- placeholder: 'yyyy',
48
- mask: '____'
56
+ placeholder: localizedPlaceholderExists ? localizedVal('year_placeholder', localeCategory) : 'yyyy',
57
+ mask: '____',
58
+ separator: theTestDateLocaleString[locYYYY + 4]
49
59
  }
50
- ];
60
+ ];
51
61
 
52
62
  // Sort the associative array by order of appearance (loc) of each piece
53
63
  arrPieces.sort((a, b) => {
@@ -57,10 +67,10 @@ export const getDateFormatInfo = () => {
57
67
  });
58
68
 
59
69
  // Construct the structure to return...
60
- theDateFormatInfo.dateFormatString = `${arrPieces[0].format}/${arrPieces[1].format}/${arrPieces[2].format}`;
70
+ theDateFormatInfo.dateFormatString = `${arrPieces[0].format}${arrPieces[0].separator}${arrPieces[1].format}${arrPieces[1].separator}${arrPieces[2].format}`;
61
71
  theDateFormatInfo.dateFormatStringLong = `${arrPieces[0].longFormat} ${arrPieces[1].longFormat}, ${arrPieces[2].longFormat}`;
62
- theDateFormatInfo.dateFormatStringLC = `${arrPieces[0].placeholder}/${arrPieces[1].placeholder}/${arrPieces[2].placeholder}`;
63
- theDateFormatInfo.dateFormatMask = `${arrPieces[0].mask}/${arrPieces[1].mask}/${arrPieces[2].mask}`;
72
+ theDateFormatInfo.dateFormatStringLC = `${arrPieces[0].placeholder}${arrPieces[0].separator}${arrPieces[1].placeholder}${arrPieces[1].separator}${arrPieces[2].placeholder}`;
73
+ theDateFormatInfo.dateFormatMask = `${arrPieces[0].mask}${arrPieces[0].separator}${arrPieces[1].mask}${arrPieces[1].separator}${arrPieces[2].mask}`;
64
74
 
65
75
  return theDateFormatInfo;
66
- }
76
+ };
@@ -1,14 +1,14 @@
1
1
  // From DX Components src/utils/event-utils.js
2
2
 
3
- const handleEvent = (actions, eventType, propName, value) => {
3
+ const handleEvent = (actions: any, eventType: string, propName: string, value: string) => {
4
4
  switch (eventType) {
5
- case "change":
5
+ case 'change':
6
6
  actions.updateFieldValue(propName, value);
7
7
  break;
8
- case "blur":
8
+ case 'blur':
9
9
  actions.triggerFieldChange(propName, value);
10
10
  break;
11
- case "changeNblur":
11
+ case 'changeNblur':
12
12
  actions.updateFieldValue(propName, value);
13
13
  actions.triggerFieldChange(propName, value);
14
14
  break;
@@ -1,4 +1,4 @@
1
- import { createElement } from 'react';
1
+ import { createElement, ReactElement } from 'react';
2
2
 
3
3
  import createPConnectComponent from '@pega/react-sdk-components/lib/bridge/react_pconnect';
4
4
 
@@ -28,17 +28,16 @@ export const getReferenceList = pConn => {
28
28
  * @param {*} viewConfigPath - boolean value to check for children in config
29
29
  * @returns {*} - return the react element of the view
30
30
  */
31
- export const buildView = (pConn, index, viewConfigPath) => {
31
+ export function buildView(pConn, index, viewConfigPath): ReactElement {
32
32
  const context = pConn.getContextName();
33
33
  const referenceList = getReferenceList(pConn);
34
34
 
35
35
  const isDatapage = referenceList.startsWith('D_');
36
- const pageReference = isDatapage
37
- ? `${referenceList}[${index}]`
38
- : `${pConn.getPageReference()}${referenceList}[${index}]`;
39
- const meta = viewConfigPath
40
- ? pConn.getRawMetadata().children[0].children[0]
41
- : pConn.getRawMetadata().children[0];
36
+ const pageReference = isDatapage ? `${referenceList}[${index}]` : `${pConn.getPageReference()}${referenceList}[${index}]`;
37
+ const meta = viewConfigPath ? pConn.getRawMetadata().children[0].children[0] : pConn.getRawMetadata().children[0];
38
+
39
+ delete meta?.config?.ruleClass;
40
+
42
41
  const config = {
43
42
  meta,
44
43
  options: {
@@ -48,10 +47,10 @@ export const buildView = (pConn, index, viewConfigPath) => {
48
47
  hasForm: true
49
48
  }
50
49
  };
51
- // eslint-disable-next-line no-undef
50
+
52
51
  const view = PCore.createPConnect(config);
53
52
  if (pConn.getConfigProps()?.displayMode === 'LABELS_LEFT') {
54
53
  view.getPConnect()?.setInheritedProp('displayMode', 'LABELS_LEFT');
55
54
  }
56
55
  return createElement(createPConnectComponent(), view);
57
- };
56
+ }
@@ -0,0 +1,21 @@
1
+ function Boolean(value, { allowEmpty = true, tick = '', cross = '' } = {}) {
2
+ if ((!allowEmpty && !value) || value === false || value?.toString()?.toLowerCase() === 'false' || value === 0 || value === '0') {
3
+ return cross || '';
4
+ }
5
+ if (value === true || value?.toString()?.toLowerCase() === 'true' || value === 1 || value === '1') {
6
+ return tick || '';
7
+ }
8
+ if (allowEmpty && (value === 'null' || value === '' || value === null || typeof value === 'undefined')) {
9
+ return '- -';
10
+ }
11
+ return value;
12
+ }
13
+
14
+ export default {
15
+ TrueFalse: (value, options) =>
16
+ Boolean(value, {
17
+ ...options,
18
+ tick: options.trueLabel || 'True',
19
+ cross: options.falseLabel || 'False'
20
+ })
21
+ };
@@ -1,8 +1,9 @@
1
- import { getLocale } from "./common";
2
- import CurrencyMap from "./CurrencyMap";
1
+ import { getLocale } from './common';
2
+ import CurrencyMap from './CurrencyMap';
3
3
 
4
- function NumberFormatter(value, { locale, decPlaces = 2 } = {}) {
5
- const currentLocale = getLocale(locale);
4
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
5
+ function NumberFormatter(value, { locale = 'en-US', decPlaces = 2, style = '', currency = 'USD' } = {}): string {
6
+ const currentLocale: string | undefined = getLocale(locale);
6
7
  if (value !== null && value !== undefined) {
7
8
  return Number(value).toLocaleString(currentLocale, {
8
9
  minimumFractionDigits: decPlaces,
@@ -13,11 +14,11 @@ function NumberFormatter(value, { locale, decPlaces = 2 } = {}) {
13
14
  }
14
15
 
15
16
  function CurrencyFormatter(
16
- value,
17
- { symbol = true, position, locale, decPlaces = 2, style = "currency", currency = "USD" } = {}
18
- ) {
19
- const currentLocale = getLocale(locale);
20
- let formattedValue = value;
17
+ value: string,
18
+ { symbol = true, position = 'before', locale = 'en-US', decPlaces = 2, style = 'currency', currency = 'USD' } = {}
19
+ ): string {
20
+ const currentLocale: string | undefined = getLocale(locale);
21
+ let formattedValue: string = value;
21
22
  if (value !== null && value !== undefined && value !== '') {
22
23
  formattedValue = NumberFormatter(value, {
23
24
  locale: currentLocale,
@@ -26,14 +27,14 @@ function CurrencyFormatter(
26
27
  currency
27
28
  });
28
29
 
29
- let countryCode = currentLocale.split("-")[1].toUpperCase();
30
+ let countryCode: string | undefined = currentLocale?.split('-')[1].toUpperCase();
30
31
 
31
32
  // If countryCode is still undefined, setting it as US
32
- if( !countryCode ){
33
+ if (!countryCode) {
33
34
  countryCode = 'US';
34
35
  }
35
36
 
36
- let code;
37
+ let code: string;
37
38
  if (symbol) {
38
39
  code = CurrencyMap[countryCode]?.symbolFormat;
39
40
  } else {
@@ -42,22 +43,19 @@ function CurrencyFormatter(
42
43
 
43
44
  // if position is provided, change placeholder accordingly.
44
45
  if (position && code) {
45
- if (position.toLowerCase() === "before" && code.indexOf("{#}") === 0) {
46
+ if (position.toLowerCase() === 'before' && code.startsWith('{#}')) {
46
47
  code = code.slice(3) + code.slice(0, 3);
47
- } else if (
48
- position.toLowerCase() === "after" &&
49
- code.indexOf("{#}") === code.length - 3
50
- ) {
48
+ } else if (position.toLowerCase() === 'after' && code.indexOf('{#}') === code.length - 3) {
51
49
  code = code.slice(-3) + code.slice(0, -3);
52
50
  }
53
51
  }
54
- return code?.replace("{#}", formattedValue) || formattedValue;
52
+ return code?.replace('{#}', formattedValue) || formattedValue;
55
53
  }
56
54
  return formattedValue;
57
55
  }
58
56
 
59
- function SymbolFormatter(value, { symbol, suffix = true, locale } = {}) {
60
- let formattedValue = value;
57
+ function SymbolFormatter(value, { symbol = '$', suffix = true, locale = 'en-US' } = {}): string {
58
+ let formattedValue: string = value;
61
59
  if (value !== null && value !== undefined) {
62
60
  formattedValue = NumberFormatter(value, { locale });
63
61
  return suffix ? `${formattedValue}${symbol}` : `${symbol}${formattedValue}`;
@@ -67,16 +65,13 @@ function SymbolFormatter(value, { symbol, suffix = true, locale } = {}) {
67
65
 
68
66
  export default {
69
67
  Currency: (value, options) => CurrencyFormatter(value, options),
70
- "Currency-Code": (value, options) =>
71
- CurrencyFormatter(value, { ...options, symbol: false }),
68
+ 'Currency-Code': (value, options) => CurrencyFormatter(value, { ...options, symbol: false }),
72
69
  Decimal: (value, options) => NumberFormatter(value, options),
73
- "Decimal-Auto": (value, options) =>
70
+ 'Decimal-Auto': (value, options) =>
74
71
  NumberFormatter(value, {
75
72
  ...options,
76
73
  decPlaces: Number.isInteger(value) ? 0 : 2
77
74
  }),
78
- Integer: (value, options) =>
79
- NumberFormatter(value, { ...options, decPlaces: 0 }),
80
- Percentage: (value, options) =>
81
- SymbolFormatter(value, { ...options, symbol: "%" })
75
+ Integer: (value, options) => NumberFormatter(value, { ...options, decPlaces: 0 }),
76
+ Percentage: (value, options) => SymbolFormatter(value, { ...options, symbol: '%' })
82
77
  };