@pega/react-sdk-overrides 8.23.10 → 23.1.10

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 (142) hide show
  1. package/lib/designSystemExtension/AlertBanner/AlertBanner.tsx +47 -0
  2. package/lib/designSystemExtension/AlertBanner/index.tsx +1 -0
  3. package/lib/designSystemExtension/Banner/Banner.tsx +12 -1
  4. package/lib/designSystemExtension/CaseSummaryFields/CaseSummaryFields.tsx +15 -10
  5. package/lib/designSystemExtension/DetailsFields/DetailsFields.tsx +10 -11
  6. package/lib/designSystemExtension/FieldGroup/FieldGroup.tsx +10 -3
  7. package/lib/designSystemExtension/FieldGroupList/FieldGroupList.tsx +11 -5
  8. package/lib/designSystemExtension/FieldValueList/FieldValueList.tsx +11 -3
  9. package/lib/designSystemExtension/Operator/Operator.tsx +30 -21
  10. package/lib/designSystemExtension/Pulse/Pulse.tsx +11 -7
  11. package/lib/designSystemExtension/RichTextEditor/RichTextEditor.tsx +121 -0
  12. package/lib/designSystemExtension/RichTextEditor/index.tsx +1 -0
  13. package/lib/designSystemExtension/WssQuickCreate/WssQuickCreate.tsx +12 -3
  14. package/lib/field/AutoComplete/AutoComplete.tsx +38 -19
  15. package/lib/field/CancelAlert/CancelAlert.tsx +21 -12
  16. package/lib/field/Checkbox/Checkbox.tsx +42 -9
  17. package/lib/field/Currency/Currency.tsx +24 -16
  18. package/lib/field/Currency/currency-utils.ts +1 -2
  19. package/lib/field/Date/Date.tsx +32 -18
  20. package/lib/field/DateTime/DateTime.tsx +27 -16
  21. package/lib/field/Decimal/Decimal.tsx +82 -19
  22. package/lib/field/Dropdown/Dropdown.tsx +60 -15
  23. package/lib/field/Email/Email.tsx +17 -9
  24. package/lib/field/Integer/Integer.tsx +15 -7
  25. package/lib/field/Percentage/Percentage.tsx +15 -7
  26. package/lib/field/Phone/Phone.tsx +21 -12
  27. package/lib/field/RadioButtons/RadioButtons.tsx +57 -28
  28. package/lib/field/RichText/RichText.tsx +95 -0
  29. package/lib/field/RichText/index.tsx +1 -0
  30. package/lib/field/ScalarList/ScalarList.tsx +73 -0
  31. package/lib/field/ScalarList/config-ext.json +8 -0
  32. package/lib/field/ScalarList/index.tsx +1 -0
  33. package/lib/field/SemanticLink/SemanticLink.tsx +26 -25
  34. package/lib/field/SemanticLink/utils.ts +2 -1
  35. package/lib/field/TextArea/TextArea.tsx +14 -5
  36. package/lib/field/TextContent/TextContent.tsx +10 -1
  37. package/lib/field/TextInput/TextInput.tsx +40 -11
  38. package/lib/field/Time/Time.tsx +29 -26
  39. package/lib/field/URL/URL.tsx +24 -8
  40. package/lib/field/UserReference/UserReference.tsx +52 -60
  41. package/lib/helpers/{attachmentHelpers.js → attachmentHelpers.ts} +5 -5
  42. package/lib/helpers/auth.js +752 -401
  43. package/lib/helpers/authManager.ts +933 -0
  44. package/lib/helpers/case-utils.tsx +103 -0
  45. package/lib/helpers/common-utils.ts +4 -0
  46. package/lib/helpers/config_access.js +63 -145
  47. package/lib/helpers/data_page.ts +2 -1
  48. package/lib/helpers/date-format-utils.ts +29 -19
  49. package/lib/helpers/{event-utils.js → event-utils.ts} +1 -1
  50. package/lib/helpers/{field-group-utils.js → field-group-utils.ts} +10 -11
  51. package/lib/helpers/formatters/{Currency.js → Currency.ts} +13 -12
  52. package/lib/helpers/formatters/{CurrencyMap.js → CurrencyMap.ts} +8 -5
  53. package/lib/helpers/formatters/{Date.js → Date.ts} +2 -2
  54. package/lib/helpers/formatters/{common.js → common.ts} +4 -4
  55. package/lib/helpers/formatters/{index.js → index.ts} +3 -3
  56. package/lib/helpers/simpleTableHelpers.ts +10 -6
  57. package/lib/helpers/state-utils.tsx +47 -0
  58. package/lib/helpers/template-utils.ts +3 -4
  59. package/lib/helpers/utils.ts +12 -4
  60. package/lib/helpers/versionHelpers.ts +0 -1
  61. package/lib/infra/ActionButtons/ActionButtons.tsx +13 -18
  62. package/lib/infra/Assignment/Assignment.tsx +44 -35
  63. package/lib/infra/AssignmentCard/AssignmentCard.tsx +15 -19
  64. package/lib/infra/Containers/FlowContainer/FlowContainer.tsx +76 -64
  65. package/lib/infra/Containers/FlowContainer/{helpers.js → helpers.ts} +18 -16
  66. package/lib/infra/Containers/ModalViewContainer/ModalViewContainer.tsx +41 -25
  67. package/lib/infra/Containers/ViewContainer/ViewContainer.tsx +25 -30
  68. package/lib/infra/DashboardFilter/DashboardFilter.tsx +16 -20
  69. package/lib/infra/DashboardFilter/filterUtils.tsx +4 -1
  70. package/lib/infra/DeferLoad/DeferLoad.tsx +16 -19
  71. package/lib/infra/ErrorBoundary/ErrorBoundary.tsx +21 -20
  72. package/lib/infra/MultiStep/MultiStep.tsx +24 -24
  73. package/lib/infra/NavBar/NavBar.tsx +23 -24
  74. package/lib/infra/Reference/Reference.tsx +14 -18
  75. package/lib/infra/Region/Region.tsx +8 -6
  76. package/lib/infra/RootContainer/RootContainer.tsx +32 -39
  77. package/lib/infra/Stages/Stages.tsx +15 -9
  78. package/lib/infra/VerticalTabs/LeftAlignVerticalTabs/LeftAlignVerticalTabs.tsx +8 -1
  79. package/lib/infra/VerticalTabs/VerticalTabs/VerticalTabs.tsx +12 -12
  80. package/lib/infra/View/View.tsx +30 -57
  81. package/lib/template/AppShell/AppShell.tsx +51 -34
  82. package/lib/template/BannerPage/BannerPage.tsx +26 -31
  83. package/lib/template/CaseSummary/CaseSummary.tsx +15 -8
  84. package/lib/template/CaseView/CaseView.tsx +137 -100
  85. package/lib/template/CaseViewActionsMenu/CaseViewActionsMenu.tsx +27 -27
  86. package/lib/template/Confirmation/Confirmation.tsx +29 -52
  87. package/lib/template/DataReference/DataReference.tsx +51 -53
  88. package/lib/template/DefaultForm/DefaultForm.tsx +29 -20
  89. package/lib/template/DefaultForm/utils/index.ts +33 -0
  90. package/lib/template/Details/Details/Details.tsx +16 -17
  91. package/lib/template/Details/DetailsSubTabs/DetailsSubTabs.tsx +13 -16
  92. package/lib/template/Details/DetailsThreeColumn/DetailsThreeColumn.tsx +19 -18
  93. package/lib/template/Details/DetailsTwoColumn/DetailsTwoColumn.tsx +20 -18
  94. package/lib/template/Details/DynamicTabs/DynamicTabs.tsx +78 -0
  95. package/lib/template/Details/DynamicTabs/config.json +36 -0
  96. package/lib/template/Details/DynamicTabs/index.tsx +1 -0
  97. package/lib/template/FieldGroupTemplate/FieldGroupTemplate.tsx +24 -27
  98. package/lib/template/InlineDashboard/InlineDashboard.tsx +11 -7
  99. package/lib/template/InlineDashboardPage/InlineDashboardPage.tsx +20 -18
  100. package/lib/template/ListPage/ListPage.tsx +14 -13
  101. package/lib/template/ListView/ListView.tsx +244 -314
  102. package/lib/template/ListView/{hooks.js → hooks.ts} +3 -1
  103. package/lib/template/ListView/{utils.js → utils.ts} +172 -23
  104. package/lib/template/MultiReferenceReadOnly/MultiReferenceReadOnly.tsx +12 -17
  105. package/lib/template/NarrowWide/NarrowWide/NarrowWide.tsx +16 -1
  106. package/lib/template/NarrowWide/NarrowWideDetails/NarrowWideDetails.tsx +19 -18
  107. package/lib/template/NarrowWide/NarrowWideForm/NarrowWideForm.tsx +9 -1
  108. package/lib/template/NarrowWide/NarrowWidePage/NarrowWidePage.tsx +17 -17
  109. package/lib/template/OneColumn/OneColumn/OneColumn.tsx +8 -7
  110. package/lib/template/OneColumn/OneColumnPage/OneColumnPage.tsx +10 -10
  111. package/lib/template/OneColumn/OneColumnTab/OneColumnTab.tsx +5 -7
  112. package/lib/template/PromotedFilters/PromotedFilters.tsx +23 -17
  113. package/lib/template/SimpleTable/SimpleTable/SimpleTable.tsx +103 -6
  114. package/lib/template/SimpleTable/SimpleTableManual/SimpleTableManual.tsx +29 -8
  115. package/lib/template/SimpleTable/SimpleTableSelect/SimpleTableSelect.tsx +26 -31
  116. package/lib/template/SingleReferenceReadOnly/SingleReferenceReadOnly.tsx +33 -36
  117. package/lib/template/SubTabs/SubTabs.tsx +10 -11
  118. package/lib/template/SubTabs/tabUtils.ts +0 -2
  119. package/lib/template/TwoColumn/TwoColumn/TwoColumn.tsx +10 -15
  120. package/lib/template/TwoColumn/TwoColumnPage/TwoColumnPage.tsx +10 -10
  121. package/lib/template/TwoColumn/TwoColumnTab/TwoColumnTab.tsx +10 -12
  122. package/lib/template/WideNarrow/WideNarrow/WideNarrow.tsx +17 -3
  123. package/lib/template/WideNarrow/WideNarrowDetails/WideNarrowDetails.tsx +35 -25
  124. package/lib/template/WideNarrow/WideNarrowForm/WideNarrowForm.tsx +7 -1
  125. package/lib/template/WideNarrow/WideNarrowPage/WideNarrowPage.tsx +15 -17
  126. package/lib/template/WssNavBar/WssNavBar.tsx +20 -3
  127. package/lib/widget/AppAnnouncement/AppAnnouncement.tsx +13 -21
  128. package/lib/widget/Attachment/Attachment.css +15 -3
  129. package/lib/widget/Attachment/Attachment.tsx +51 -32
  130. package/lib/widget/CaseHistory/CaseHistory.tsx +13 -11
  131. package/lib/widget/FileUtility/ActionButtonsForFileUtil/ActionButtonsForFileUtil.tsx +13 -1
  132. package/lib/widget/FileUtility/FileUtility/FileUtility.tsx +40 -26
  133. package/lib/widget/Followers/Followers.tsx +10 -11
  134. package/lib/widget/QuickCreate/QuickCreate.tsx +15 -6
  135. package/lib/widget/SummaryItem/SummaryItem.tsx +12 -4
  136. package/lib/widget/SummaryList/SummaryList.tsx +17 -3
  137. package/lib/widget/ToDo/ToDo.tsx +69 -104
  138. package/package.json +1 -1
  139. package/lib/helpers/authManager.js +0 -631
  140. /package/lib/helpers/formatters/{Boolean.js → Boolean.ts} +0 -0
  141. /package/lib/helpers/{reactContextHelpers.js → reactContextHelpers.ts} +0 -0
  142. /package/lib/template/ListView/{DefaultViewMeta.js → DefaultViewMeta.ts} +0 -0
@@ -1,53 +1,116 @@
1
- import React from 'react';
2
- import { TextField } from '@material-ui/core';
3
- import TextInput from '@pega/react-sdk-components/lib/components/field/TextInput';
4
- import FieldValueList from '@pega/react-sdk-components/lib/components/designSystemExtension/FieldValueList';
1
+ import React, { useState, useEffect } from 'react';
2
+ import CurrencyTextField from '@unicef/material-ui-currency-textfield';
3
+ import { getCurrencyCharacters, getCurrencyOptions } from '@pega/react-sdk-components/lib/components/field/Currency/currency-utils';
4
+ import handleEvent from '@pega/react-sdk-components/lib/components/helpers/event-utils';
5
+ import { format } from '@pega/react-sdk-components/lib/components/helpers/formatters';
6
+ import { getComponentFromMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
7
+ import type { PConnFieldProps } from '@pega/react-sdk-components/lib/types/PConnProps';
8
+
9
+ // Using control from: https://github.com/unicef/material-ui-currency-textfield
10
+
11
+ interface DecimalProps extends PConnFieldProps {
12
+ // If any, enter additional props that only exist on Decimal here
13
+ currencyISOCode?: string;
14
+ decimalPrecision?: number;
15
+ showGroupSeparators?: string;
16
+ }
17
+
18
+ export default function Decimal(props: DecimalProps) {
19
+ // Get emitted components from map (so we can get any override that may exist)
20
+ const FieldValueList = getComponentFromMap('FieldValueList');
5
21
 
6
- export default function Decimal(props) {
7
22
  const {
23
+ getPConnect,
8
24
  label,
9
25
  required,
10
26
  disabled,
11
27
  value = '',
12
28
  validatemessage,
13
29
  status,
14
- onChange,
15
- onBlur,
30
+ /* onChange, onBlur, */
16
31
  readOnly,
17
32
  helperText,
18
33
  displayMode,
19
- hideLabel
34
+ hideLabel,
35
+ currencyISOCode = 'USD',
36
+ decimalPrecision = 2,
37
+ showGroupSeparators = true,
38
+ testId
20
39
  } = props;
40
+
41
+ const pConn = getPConnect();
42
+ const actions = pConn.getActionsApi();
43
+ const propName = pConn.getStateProps()["value"];
21
44
  const helperTextToDisplay = validatemessage || helperText;
22
45
 
46
+ const [decValue, setDecimalvalue] = useState('');
47
+ const [theCurrDec, setCurrDec] = useState('.');
48
+ const [theCurrSep, setCurrSep] = useState(',');
49
+
50
+ useEffect(() => {
51
+ const theSymbols = getCurrencyCharacters(currencyISOCode);
52
+ setCurrDec(theSymbols.theDecimalIndicator);
53
+ setCurrSep(theSymbols.theDigitGroupSeparator);
54
+ }, [currencyISOCode]);
55
+
56
+ useEffect(() => {
57
+ setDecimalvalue(value.toString());
58
+ }, [value]);
59
+
60
+ const theCurrencyOptions = getCurrencyOptions(currencyISOCode);
61
+ const formattedValue = format(value, pConn.getComponentName().toLowerCase(), theCurrencyOptions);
62
+
23
63
  if (displayMode === 'LABELS_LEFT') {
24
- return <FieldValueList name={hideLabel ? '' : label} value={value} />;
64
+ return <FieldValueList name={hideLabel ? '' : label} value={formattedValue} />;
25
65
  }
26
66
 
27
67
  if (displayMode === 'STACKED_LARGE_VAL') {
28
- return <FieldValueList name={hideLabel ? '' : label} value={value} variant='stacked' />;
68
+ return <FieldValueList name={hideLabel ? '' : label} value={formattedValue} variant="stacked" />;
29
69
  }
30
70
 
71
+ let readOnlyProp = {}; // Note: empty if NOT ReadOnly
72
+
31
73
  if (readOnly) {
32
- return <TextInput {...props} />;
74
+ readOnlyProp = { readOnly: true };
75
+ }
76
+
77
+ let testProp = {};
78
+
79
+ testProp = {
80
+ 'data-test-id': testId
81
+ };
82
+
83
+ function decimalOnChange(event) {
84
+ // update internal value
85
+ setDecimalvalue(event?.target?.value);
86
+ }
87
+
88
+ function decimalOnBlur(event, inValue) {
89
+ handleEvent(actions, 'changeNblur', propName, inValue !== '' ? Number(inValue) : inValue);
33
90
  }
34
91
 
35
92
  return (
36
- <TextField
93
+ <CurrencyTextField
37
94
  fullWidth
38
95
  variant={readOnly ? 'standard' : 'outlined'}
39
96
  helperText={helperTextToDisplay}
40
- placeholder=''
41
- size='small'
97
+ placeholder=""
98
+ size="small"
42
99
  required={required}
43
100
  disabled={disabled}
44
- onChange={onChange}
45
- onBlur={!readOnly ? onBlur : undefined}
101
+ onChange={decimalOnChange}
102
+ onBlur={!readOnly ? decimalOnBlur : undefined}
46
103
  error={status === 'error'}
47
104
  label={label}
48
- value={value}
49
- type='text'
50
- inputProps={{ inputMode: 'decimal', pattern: '[0-9]*' }}
105
+ value={decValue}
106
+ type="text"
107
+ outputFormat="number"
108
+ textAlign="left"
109
+ InputProps={{ ...readOnlyProp, inputProps: { ...testProp, value: decValue } }}
110
+ currencySymbol=""
111
+ decimalCharacter={theCurrDec}
112
+ digitGroupSeparator={showGroupSeparators ? theCurrSep : ''}
113
+ decimalPlaces={decimalPrecision}
51
114
  />
52
115
  );
53
116
  }
@@ -3,20 +3,36 @@ import { TextField } from '@material-ui/core';
3
3
  import MenuItem from '@material-ui/core/MenuItem';
4
4
  import Utils from '@pega/react-sdk-components/lib/components/helpers/utils';
5
5
  import handleEvent from '@pega/react-sdk-components/lib/components/helpers/event-utils';
6
- import FieldValueList from '@pega/react-sdk-components/lib/components/designSystemExtension/FieldValueList';
6
+ import { getComponentFromMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
7
+ // import type { PConnFieldProps } from '../../../types/PConnProps';
7
8
 
8
9
  interface IOption {
9
10
  key: string;
10
11
  value: string;
11
12
  }
12
13
 
13
- export default function Dropdown(props) {
14
+ // Can't use DropdownProps with 8.23 until getLocaleRuleNameFromKeys is NOT private
15
+ // interface DropdownProps extends PConnFieldProps {
16
+ // // If any, enter additional props that only exist on Dropdown here
17
+ // datasource?: Array<any>,
18
+ // onRecordChange?: any,
19
+ // fieldMetadata?: any,
20
+ // // eslint-disable-next-line react/no-unused-prop-types
21
+ // listType: string,
22
+ // // eslint-disable-next-line react/no-unused-prop-types
23
+ // additionalProps?: object
24
+ // }
25
+
26
+
27
+ export default function Dropdown(props /* : DropdownProps */) {
28
+ // Get emitted components from map (so we can get any override that may exist)
29
+ const FieldValueList = getComponentFromMap('FieldValueList');
30
+
14
31
  const {
15
32
  getPConnect,
16
33
  label,
17
34
  required,
18
35
  disabled,
19
- placeholder,
20
36
  value = '',
21
37
  datasource = [],
22
38
  validatemessage,
@@ -26,29 +42,58 @@ export default function Dropdown(props) {
26
42
  helperText,
27
43
  displayMode,
28
44
  hideLabel,
29
- onRecordChange
45
+ onRecordChange,
46
+ fieldMetadata
30
47
  } = props;
48
+ let { placeholder = "" } = props;
49
+ placeholder = placeholder || 'Select...';
31
50
  const [options, setOptions] = useState<Array<IOption>>([]);
32
51
  const helperTextToDisplay = validatemessage || helperText;
33
52
 
34
53
  const thePConn = getPConnect();
35
54
  const actionsApi = thePConn.getActionsApi();
36
- const propName = thePConn.getStateProps().value;
55
+ const propName = thePConn.getStateProps()["value"];
56
+ const className = thePConn.getCaseInfo().getClassName();
57
+ const refName = propName?.slice(propName.lastIndexOf('.') + 1);
37
58
 
38
59
  useEffect(() => {
39
- const optionsList = Utils.getOptionList(props, getPConnect().getDataObject());
40
- optionsList.unshift({ key: 'Select', value: 'Select...' });
60
+ const list = Utils.getOptionList(props, getPConnect().getDataObject('')); // 1st arg empty string until typedef marked correctly
61
+ const optionsList = [...list];
62
+ optionsList.unshift({
63
+ key: placeholder,
64
+ value: thePConn.getLocalizedValue(placeholder, '', '')
65
+ }); // 2nd and 3rd args empty string until typedef marked correctly
41
66
  setOptions(optionsList);
42
67
  }, [datasource]);
43
68
 
69
+ const metaData = Array.isArray(fieldMetadata) ? fieldMetadata.filter((field) => field?.classID === className)[0] : fieldMetadata;
70
+
71
+ let displayName = metaData?.datasource?.propertyForDisplayText;
72
+ displayName = displayName?.slice(displayName.lastIndexOf('.') + 1);
73
+ const localeContext = metaData?.datasource?.tableType === 'DataPage' ? 'datapage' : 'associated';
74
+ const localeClass = localeContext === 'datapage' ? '@baseclass' : className;
75
+ const localeName = localeContext === 'datapage' ? metaData?.datasource?.name : refName;
76
+ const localePath = localeContext === 'datapage' ? displayName : localeName;
77
+
44
78
  let readOnlyProp = {};
45
79
 
46
80
  if (displayMode === 'LABELS_LEFT') {
47
- return <FieldValueList name={hideLabel ? '' : label} value={value} />;
81
+ return (
82
+ <FieldValueList
83
+ name={hideLabel ? '' : label}
84
+ value={thePConn.getLocalizedValue(value, localePath, thePConn.getLocaleRuleNameFromKeys(localeClass, localeContext, localeName))}
85
+ />
86
+ );
48
87
  }
49
88
 
50
89
  if (displayMode === 'STACKED_LARGE_VAL') {
51
- return <FieldValueList name={hideLabel ? '' : label} value={value} variant='stacked' />;
90
+ return (
91
+ <FieldValueList
92
+ name={hideLabel ? '' : label}
93
+ value={thePConn.getLocalizedValue(value, localePath, thePConn.getLocaleRuleNameFromKeys(localeClass, localeContext, localeName))}
94
+ variant="stacked"
95
+ />
96
+ );
52
97
  }
53
98
 
54
99
  if (readOnly) {
@@ -61,8 +106,8 @@ export default function Dropdown(props) {
61
106
  'data-test-id': testId
62
107
  };
63
108
 
64
- const handleChange = evt => {
65
- const selectedValue = evt.target.value === 'Select' ? '' : evt.target.value;
109
+ const handleChange = (evt) => {
110
+ const selectedValue = evt.target.value === placeholder ? '' : evt.target.value;
66
111
  handleEvent(actionsApi, 'changeNblur', propName, selectedValue);
67
112
  if (onRecordChange) {
68
113
  onRecordChange(evt);
@@ -76,20 +121,20 @@ export default function Dropdown(props) {
76
121
  fullWidth
77
122
  variant={readOnly ? 'standard' : 'outlined'}
78
123
  helperText={helperTextToDisplay}
79
- placeholder={placeholder}
80
- size='small'
124
+ placeholder={thePConn.getLocalizedValue(placeholder, '', '')} // 2nd and 3rd args empty string until typedef marked correctly
125
+ size="small"
81
126
  required={required}
82
127
  disabled={disabled}
83
128
  onChange={!readOnly ? handleChange : undefined}
84
129
  error={status === 'error'}
85
130
  label={label}
86
- value={value === '' && !readOnly ? 'Select' : value}
131
+ value={value === '' && !readOnly ? placeholder : value}
87
132
  select
88
133
  InputProps={{ ...readOnlyProp, ...testProp }}
89
134
  >
90
135
  {options.map((option: any) => (
91
136
  <MenuItem key={option.key} value={option.key}>
92
- {option.value}
137
+ {thePConn.getLocalizedValue(option.value, localePath, thePConn.getLocaleRuleNameFromKeys(localeClass, localeContext, localeName))}
93
138
  </MenuItem>
94
139
  ))}
95
140
  </TextField>
@@ -1,10 +1,18 @@
1
1
  import React from 'react';
2
2
  import { TextField, InputAdornment } from '@material-ui/core';
3
3
  import MailOutlineIcon from '@material-ui/icons/MailOutline';
4
- import TextInput from '@pega/react-sdk-components/lib/components/field/TextInput';
5
- import FieldValueList from '@pega/react-sdk-components/lib/components/designSystemExtension/FieldValueList';
4
+ import { getComponentFromMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
5
+ import type { PConnFieldProps } from '@pega/react-sdk-components/lib/types/PConnProps';
6
+
7
+ interface EmailProps extends PConnFieldProps {
8
+ // If any, enter additional props that only exist on Date here
9
+ }
10
+
11
+ export default function Email(props: EmailProps) {
12
+ // Get emitted components from map (so we can get any override that may exist)
13
+ const TextInput = getComponentFromMap('TextInput');
14
+ const FieldValueList = getComponentFromMap('FieldValueList');
6
15
 
7
- export default function Email(props) {
8
16
  const {
9
17
  label,
10
18
  required,
@@ -27,7 +35,7 @@ export default function Email(props) {
27
35
  }
28
36
 
29
37
  if (displayMode === 'STACKED_LARGE_VAL') {
30
- return <FieldValueList name={hideLabel ? '' : label} value={value} variant='stacked' />;
38
+ return <FieldValueList name={hideLabel ? '' : label} value={value} variant="stacked" />;
31
39
  }
32
40
 
33
41
  if (readOnly) {
@@ -43,10 +51,10 @@ export default function Email(props) {
43
51
  return (
44
52
  <TextField
45
53
  fullWidth
46
- variant='outlined'
54
+ variant="outlined"
47
55
  helperText={helperTextToDisplay}
48
- placeholder=''
49
- size='small'
56
+ placeholder=""
57
+ size="small"
50
58
  required={required}
51
59
  disabled={disabled}
52
60
  onChange={onChange}
@@ -54,10 +62,10 @@ export default function Email(props) {
54
62
  error={status === 'error'}
55
63
  label={label}
56
64
  value={value}
57
- type='email'
65
+ type="email"
58
66
  InputProps={{
59
67
  startAdornment: (
60
- <InputAdornment position='start'>
68
+ <InputAdornment position="start">
61
69
  <MailOutlineIcon />
62
70
  </InputAdornment>
63
71
  ),
@@ -1,9 +1,17 @@
1
1
  import React from 'react';
2
2
  import { TextField } from '@material-ui/core';
3
- import TextInput from '@pega/react-sdk-components/lib/components/field/TextInput';
4
- import FieldValueList from '@pega/react-sdk-components/lib/components/designSystemExtension/FieldValueList';
3
+ import { getComponentFromMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
4
+ import type { PConnFieldProps } from '@pega/react-sdk-components/lib/types/PConnProps';
5
+
6
+ interface IntegerProps extends PConnFieldProps {
7
+ // If any, enter additional props that only exist on Integer here
8
+ }
9
+
10
+ export default function Integer(props: IntegerProps) {
11
+ // Get emitted components from map (so we can get any override that may exist)
12
+ const TextInput = getComponentFromMap('TextInput');
13
+ const FieldValueList = getComponentFromMap('FieldValueList');
5
14
 
6
- export default function Integer(props) {
7
15
  const {
8
16
  label,
9
17
  required,
@@ -28,7 +36,7 @@ export default function Integer(props) {
28
36
  }
29
37
 
30
38
  if (displayMode === 'STACKED_LARGE_VAL') {
31
- return <FieldValueList name={hideLabel ? '' : label} value={value} variant='stacked' />;
39
+ return <FieldValueList name={hideLabel ? '' : label} value={value} variant="stacked" />;
32
40
  }
33
41
 
34
42
  if (readOnly) {
@@ -63,8 +71,8 @@ export default function Integer(props) {
63
71
  fullWidth
64
72
  variant={readOnly ? 'standard' : 'outlined'}
65
73
  helperText={helperTextToDisplay}
66
- placeholder=''
67
- size='small'
74
+ placeholder=""
75
+ size="small"
68
76
  required={required}
69
77
  disabled={disabled}
70
78
  onChange={intOnChange}
@@ -72,7 +80,7 @@ export default function Integer(props) {
72
80
  error={status === 'error'}
73
81
  label={label}
74
82
  value={value}
75
- type='text'
83
+ type="text"
76
84
  inputProps={{ inputMode: 'numeric', pattern: '[0-9]*', ...testProp }}
77
85
  />
78
86
  );
@@ -2,8 +2,8 @@ import React from 'react';
2
2
  import { TextField } from '@material-ui/core';
3
3
  import { makeStyles } from '@material-ui/core/styles';
4
4
 
5
- import TextInput from '@pega/react-sdk-components/lib/components/field/TextInput';
6
- import FieldValueList from '@pega/react-sdk-components/lib/components/designSystemExtension/FieldValueList';
5
+ import { getComponentFromMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
6
+ import type { PConnFieldProps } from '@pega/react-sdk-components/lib/types/PConnProps';
7
7
 
8
8
  // Inspired by https://stackoverflow.com/questions/50823182/material-ui-remove-up-down-arrow-dials-from-textview
9
9
  const useStyles = makeStyles((/* theme */) => ({
@@ -22,7 +22,15 @@ const useStyles = makeStyles((/* theme */) => ({
22
22
  }
23
23
  }));
24
24
 
25
- export default function Percentage(props) {
25
+ interface PercentageProps extends PConnFieldProps {
26
+ // If any, enter additional props that only exist on Percentage here
27
+ }
28
+
29
+ export default function Percentage(props: PercentageProps) {
30
+ // Get emitted components from map (so we can get any override that may exist)
31
+ const TextInput = getComponentFromMap('TextInput');
32
+ const FieldValueList = getComponentFromMap('FieldValueList');
33
+
26
34
  const classes = useStyles();
27
35
 
28
36
  const {
@@ -49,7 +57,7 @@ export default function Percentage(props) {
49
57
  }
50
58
 
51
59
  if (displayMode === 'STACKED_LARGE_VAL') {
52
- return <FieldValueList name={hideLabel ? '' : label} value={value} variant='stacked' />;
60
+ return <FieldValueList name={hideLabel ? '' : label} value={value} variant="stacked" />;
53
61
  }
54
62
 
55
63
  if (readOnly) {
@@ -68,8 +76,8 @@ export default function Percentage(props) {
68
76
  fullWidth
69
77
  variant={readOnly ? 'standard' : 'outlined'}
70
78
  helperText={helperTextToDisplay}
71
- placeholder=''
72
- size='small'
79
+ placeholder=""
80
+ size="small"
73
81
  required={required}
74
82
  disabled={disabled}
75
83
  onChange={onChange}
@@ -77,7 +85,7 @@ export default function Percentage(props) {
77
85
  error={status === 'error'}
78
86
  label={label}
79
87
  value={value}
80
- type='number'
88
+ type="number"
81
89
  inputProps={{ ...testProp }}
82
90
  />
83
91
  );
@@ -1,8 +1,16 @@
1
1
  import React from 'react';
2
2
  import MuiPhoneNumber from 'material-ui-phone-number';
3
- import FieldValueList from '@pega/react-sdk-components/lib/components/designSystemExtension/FieldValueList';
3
+ import { getComponentFromMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
4
+ import type { PConnFieldProps } from '@pega/react-sdk-components/lib/types/PConnProps';
5
+
6
+ interface PhoneProps extends PConnFieldProps {
7
+ // If any, enter additional props that only exist on Phone here
8
+ }
9
+
10
+ export default function Phone(props: PhoneProps) {
11
+ // Get emitted components from map (so we can get any override that may exist)
12
+ const FieldValueList = getComponentFromMap('FieldValueList');
4
13
 
5
- export default function Phone(props) {
6
14
  const {
7
15
  label,
8
16
  required,
@@ -31,7 +39,7 @@ export default function Phone(props) {
31
39
  }
32
40
 
33
41
  if (displayMode === 'STACKED_LARGE_VAL') {
34
- return <FieldValueList name={hideLabel ? '' : label} value={value} variant='stacked' />;
42
+ return <FieldValueList name={hideLabel ? '' : label} value={value} variant="stacked" />;
35
43
  }
36
44
 
37
45
  if (readOnly) {
@@ -41,8 +49,8 @@ export default function Phone(props) {
41
49
  <MuiPhoneNumber
42
50
  fullWidth
43
51
  helperText={helperTextToDisplay}
44
- placeholder=''
45
- size='small'
52
+ placeholder=""
53
+ size="small"
46
54
  required={required}
47
55
  disabled={disabled}
48
56
  onChange={onChange}
@@ -50,7 +58,8 @@ export default function Phone(props) {
50
58
  label={label}
51
59
  value={value}
52
60
  InputProps={{
53
- readOnly: true
61
+ readOnly: true,
62
+ inputProps: { ...testProp }
54
63
  }}
55
64
  disableDropdown={disableDropdown}
56
65
  />
@@ -58,13 +67,13 @@ export default function Phone(props) {
58
67
  );
59
68
  }
60
69
 
61
- const handleChange = inputVal => {
70
+ const handleChange = (inputVal) => {
62
71
  let phoneValue = inputVal && inputVal.replace(/\D+/g, '');
63
72
  phoneValue = `+${phoneValue}`;
64
73
  onChange({ value: phoneValue });
65
74
  };
66
75
 
67
- const handleBlur = event => {
76
+ const handleBlur = (event) => {
68
77
  const phoneValue = event?.target?.value;
69
78
  event.target.value = `+${phoneValue && phoneValue.replace(/\D+/g, '')}`;
70
79
  onBlur(event);
@@ -73,11 +82,11 @@ export default function Phone(props) {
73
82
  return (
74
83
  <MuiPhoneNumber
75
84
  fullWidth
76
- variant='outlined'
85
+ variant="outlined"
77
86
  helperText={helperTextToDisplay}
78
- placeholder=''
79
- size='small'
80
- defaultCountry='us'
87
+ placeholder=""
88
+ size="small"
89
+ defaultCountry="us"
81
90
  required={required}
82
91
  disabled={disabled}
83
92
  onChange={handleChange}
@@ -1,18 +1,23 @@
1
1
  import React, { useState, useEffect } from 'react';
2
- import {
3
- Radio,
4
- RadioGroup,
5
- FormControl,
6
- FormControlLabel,
7
- FormLabel,
8
- FormHelperText
9
- } from '@material-ui/core';
2
+ import { Radio, RadioGroup, FormControl, FormControlLabel, FormLabel, FormHelperText } from '@material-ui/core';
10
3
 
11
4
  import Utils from '@pega/react-sdk-components/lib/components/helpers/utils';
12
5
  import handleEvent from '@pega/react-sdk-components/lib/components/helpers/event-utils';
13
- import FieldValueList from '@pega/react-sdk-components/lib/components/designSystemExtension/FieldValueList';
6
+ import { getComponentFromMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
7
+ // import type { PConnFieldProps } from '../../../types/PConnProps';
8
+
9
+ // Can't use RadioButtonProps until getLocaleRuleNameFromKeys is NOT private
10
+ // interface RadioButtonsProps extends PConnFieldProps {
11
+ // // If any, enter additional props that only exist on RadioButtons here
12
+ // inline: boolean,
13
+ // fieldMetadata?: any
14
+ // }
15
+
16
+
17
+ export default function RadioButtons(props /* : RadioButtonsProps */ ) {
18
+ // Get emitted components from map (so we can get any override that may exist)
19
+ const FieldValueList = getComponentFromMap('FieldValueList');
14
20
 
15
- export default function RadioButtons(props) {
16
21
  const {
17
22
  getPConnect,
18
23
  label,
@@ -24,19 +29,33 @@ export default function RadioButtons(props) {
24
29
  required,
25
30
  inline,
26
31
  displayMode,
27
- hideLabel
32
+ hideLabel,
33
+ fieldMetadata
28
34
  } = props;
29
35
  const [theSelectedButton, setSelectedButton] = useState(value);
30
36
 
31
37
  const thePConn = getPConnect();
32
38
  const theConfigProps = thePConn.getConfigProps();
33
39
  const actionsApi = thePConn.getActionsApi();
34
- const propName = thePConn.getStateProps().value;
40
+ const propName = thePConn.getStateProps()["value"];
35
41
  const helperTextToDisplay = validatemessage || helperText;
42
+ const className = thePConn.getCaseInfo().getClassName();
43
+
44
+ let configProperty = thePConn.getRawMetadata()?.config?.value || '';
45
+ configProperty = configProperty.startsWith('@P') ? configProperty.substring(3) : configProperty;
46
+ configProperty = configProperty.startsWith('.') ? configProperty.substring(1) : configProperty;
47
+
48
+ const metaData = Array.isArray(fieldMetadata) ? fieldMetadata.filter((field) => field?.classID === className)[0] : fieldMetadata;
49
+ let displayName = metaData?.datasource?.propertyForDisplayText;
50
+ displayName = displayName?.slice(displayName.lastIndexOf('.') + 1);
51
+ const localeContext = metaData?.datasource?.tableType === 'DataPage' ? 'datapage' : 'associated';
52
+ const localeClass = localeContext === 'datapage' ? '@baseclass' : className;
53
+ const localeName = localeContext === 'datapage' ? metaData?.datasource?.name : configProperty;
54
+ const localePath = localeContext === 'datapage' ? displayName : localeName;
36
55
 
37
56
  // theOptions will be an array of JSON objects that are literally key/value pairs.
38
57
  // Ex: [ {key: "Basic", value: "Basic"} ]
39
- const theOptions = Utils.getOptionList(theConfigProps, thePConn.getDataObject());
58
+ const theOptions = Utils.getOptionList(theConfigProps, thePConn.getDataObject(''));
40
59
 
41
60
  useEffect(() => {
42
61
  // This update theSelectedButton which will update the UI to show the selected button correctly
@@ -44,37 +63,47 @@ export default function RadioButtons(props) {
44
63
  }, [value]);
45
64
 
46
65
  if (displayMode === 'LABELS_LEFT') {
47
- return <FieldValueList name={hideLabel ? '' : label} value={value} />;
66
+ return (
67
+ <FieldValueList
68
+ name={hideLabel ? '' : label}
69
+ value={thePConn.getLocalizedValue(value, localePath, thePConn.getLocaleRuleNameFromKeys(localeClass, localeContext, localeName))}
70
+ />
71
+ );
48
72
  }
49
73
 
50
74
  if (displayMode === 'STACKED_LARGE_VAL') {
51
- return <FieldValueList name={hideLabel ? '' : label} value={value} variant='stacked' />;
75
+ return (
76
+ <FieldValueList
77
+ name={hideLabel ? '' : label}
78
+ value={thePConn.getLocalizedValue(value, localePath, thePConn.getLocaleRuleNameFromKeys(localeClass, localeContext, localeName))}
79
+ variant="stacked"
80
+ />
81
+ );
52
82
  }
53
83
 
54
- const handleChange = event => {
84
+ const handleChange = (event) => {
55
85
  handleEvent(actionsApi, 'changeNblur', propName, event.target.value);
56
86
  };
57
87
 
58
- const handleBlur = event => {
59
- thePConn.getValidationApi().validate(event.target.value);
88
+ const handleBlur = (event) => {
89
+ thePConn.getValidationApi().validate(event.target.value, ''); // 2nd arg empty string until typedef marked correctly as optional
60
90
  };
61
91
 
62
92
  return (
63
93
  <FormControl error={status === 'error'} required={required}>
64
- <FormLabel component='legend'>{label}</FormLabel>
65
- <RadioGroup
66
- value={theSelectedButton}
67
- onChange={handleChange}
68
- onBlur={!readOnly ? handleBlur : undefined}
69
- row={inline}
70
- >
71
- {theOptions.map(theOption => {
94
+ <FormLabel component="legend">{label}</FormLabel>
95
+ <RadioGroup value={theSelectedButton} onChange={handleChange} onBlur={!readOnly ? handleBlur : undefined} row={inline}>
96
+ {theOptions.map((theOption) => {
72
97
  return (
73
98
  <FormControlLabel
74
99
  value={theOption.key}
75
100
  key={theOption.key}
76
- label={theOption.value}
77
- control={<Radio key={theOption.key} color='primary' disabled={readOnly} />}
101
+ label={thePConn.getLocalizedValue(
102
+ theOption.value,
103
+ localePath,
104
+ thePConn.getLocaleRuleNameFromKeys(localeClass, localeContext, localeName)
105
+ )}
106
+ control={<Radio key={theOption.key} color="primary" disabled={readOnly} />}
78
107
  />
79
108
  );
80
109
  })}