@pega/react-sdk-overrides 23.1.12 → 24.2.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 (99) hide show
  1. package/lib/designSystemExtension/AlertBanner/AlertBanner.tsx +1 -1
  2. package/lib/designSystemExtension/Banner/Banner.tsx +1 -1
  3. package/lib/designSystemExtension/CaseSummaryFields/CaseSummaryFields.css +0 -1
  4. package/lib/designSystemExtension/CaseSummaryFields/CaseSummaryFields.tsx +13 -4
  5. package/lib/designSystemExtension/DetailsFields/DetailsFields.tsx +4 -4
  6. package/lib/designSystemExtension/FieldGroup/FieldGroup.tsx +4 -4
  7. package/lib/designSystemExtension/FieldGroupList/FieldGroupList.tsx +4 -4
  8. package/lib/designSystemExtension/FieldValueList/FieldValueList.tsx +5 -5
  9. package/lib/designSystemExtension/Operator/Operator.tsx +6 -5
  10. package/lib/designSystemExtension/Pulse/Pulse.tsx +2 -2
  11. package/lib/designSystemExtension/RichTextEditor/RichTextEditor.tsx +3 -2
  12. package/lib/designSystemExtension/WssQuickCreate/WssQuickCreate.tsx +1 -1
  13. package/lib/field/AutoComplete/AutoComplete.tsx +4 -4
  14. package/lib/field/CancelAlert/CancelAlert.tsx +5 -3
  15. package/lib/field/Checkbox/Checkbox.tsx +4 -4
  16. package/lib/field/Currency/Currency.tsx +37 -27
  17. package/lib/field/Date/Date.tsx +23 -42
  18. package/lib/field/DateTime/DateTime.tsx +29 -34
  19. package/lib/field/Decimal/Decimal.tsx +34 -20
  20. package/lib/field/Dropdown/Dropdown.tsx +3 -3
  21. package/lib/field/Email/Email.tsx +29 -8
  22. package/lib/field/Group/Group.tsx +2 -2
  23. package/lib/field/Integer/Integer.tsx +22 -8
  24. package/lib/field/{MultiSelect → Multiselect}/Multiselect.tsx +9 -15
  25. package/lib/field/Percentage/Percentage.tsx +34 -19
  26. package/lib/field/Phone/Phone.tsx +22 -12
  27. package/lib/field/Phone/config-ext.json +8 -0
  28. package/lib/field/RadioButtons/RadioButtons.tsx +3 -3
  29. package/lib/field/RichText/RichText.tsx +1 -1
  30. package/lib/field/RichText/config-ext.json +10 -0
  31. package/lib/field/ScalarList/ScalarList.tsx +4 -2
  32. package/lib/field/SemanticLink/SemanticLink.tsx +4 -4
  33. package/lib/field/TextArea/TextArea.tsx +26 -8
  34. package/lib/field/TextContent/TextContent.tsx +1 -1
  35. package/lib/field/TextInput/TextInput.tsx +2 -2
  36. package/lib/field/Time/Time.tsx +27 -20
  37. package/lib/field/URL/URL.tsx +26 -7
  38. package/lib/field/UserReference/UserReference.tsx +12 -2
  39. package/lib/helpers/common-utils.ts +1 -5
  40. package/lib/helpers/field-group-utils.ts +2 -2
  41. package/lib/helpers/simpleTableHelpers.ts +1 -1
  42. package/lib/infra/ActionButtons/ActionButtons.tsx +3 -3
  43. package/lib/infra/Assignment/Assignment.tsx +38 -7
  44. package/lib/infra/Containers/FlowContainer/FlowContainer.tsx +16 -13
  45. package/lib/infra/Containers/ModalViewContainer/ListViewActionButtons/ListViewActionButtons.tsx +7 -4
  46. package/lib/infra/Containers/ModalViewContainer/ModalViewContainer.tsx +8 -8
  47. package/lib/infra/Containers/ViewContainer/ViewContainer.tsx +1 -1
  48. package/lib/infra/DashboardFilter/DashboardFilter.tsx +2 -2
  49. package/lib/infra/DashboardFilter/filterUtils.tsx +2 -1
  50. package/lib/infra/DeferLoad/DeferLoad.tsx +8 -4
  51. package/lib/infra/MultiStep/MultiStep.tsx +17 -9
  52. package/lib/infra/NavBar/NavBar.css +1 -0
  53. package/lib/infra/NavBar/NavBar.tsx +27 -19
  54. package/lib/infra/RootContainer/RootContainer.tsx +5 -6
  55. package/lib/infra/Stages/Stages.tsx +4 -4
  56. package/lib/infra/VerticalTabs/LeftAlignVerticalTabs/LeftAlignVerticalTabs.tsx +4 -3
  57. package/lib/infra/VerticalTabs/VerticalTabs/VerticalTabs.tsx +2 -2
  58. package/lib/infra/View/View.tsx +37 -3
  59. package/lib/template/AppShell/AppShell.tsx +55 -5
  60. package/lib/template/BannerPage/config-ext.json +9 -0
  61. package/lib/template/CaseView/CaseView.tsx +7 -6
  62. package/lib/template/CaseViewActionsMenu/CaseViewActionsMenu.tsx +8 -8
  63. package/lib/template/Confirmation/Confirmation.tsx +2 -1
  64. package/lib/template/DataReference/DataReference.tsx +3 -3
  65. package/lib/template/DefaultForm/utils/index.ts +2 -7
  66. package/lib/template/Details/Details/Details.tsx +3 -3
  67. package/lib/template/Details/DetailsSubTabs/DetailsSubTabs.tsx +3 -3
  68. package/lib/template/Details/DetailsThreeColumn/DetailsThreeColumn.tsx +3 -3
  69. package/lib/template/Details/DetailsTwoColumn/DetailsTwoColumn.tsx +3 -3
  70. package/lib/template/Details/DynamicTabs/DynamicTabs.tsx +4 -3
  71. package/lib/template/FieldGroupTemplate/FieldGroupTemplate.tsx +12 -3
  72. package/lib/template/InlineDashboard/InlineDashboard.tsx +2 -2
  73. package/lib/template/InlineDashboardPage/config-ext.json +9 -0
  74. package/lib/template/ListView/ListView.tsx +88 -91
  75. package/lib/template/ListView/utils.ts +1 -1
  76. package/lib/template/MultiReferenceReadOnly/MultiReferenceReadOnly.tsx +1 -1
  77. package/lib/template/NarrowWide/NarrowWideDetails/NarrowWideDetails.tsx +3 -3
  78. package/lib/template/OneColumn/OneColumn/OneColumn.tsx +2 -2
  79. package/lib/template/PromotedFilters/PromotedFilters.tsx +2 -1
  80. package/lib/template/SimpleTable/SimpleTableManual/SimpleTableManual.tsx +46 -30
  81. package/lib/template/SingleReferenceReadOnly/SingleReferenceReadOnly.tsx +1 -1
  82. package/lib/template/SubTabs/SubTabs.tsx +2 -2
  83. package/lib/template/TwoColumn/TwoColumn/TwoColumn.tsx +2 -2
  84. package/lib/template/TwoColumn/TwoColumnTab/TwoColumnTab.tsx +2 -2
  85. package/lib/template/WideNarrow/WideNarrowDetails/WideNarrowDetails.tsx +3 -3
  86. package/lib/template/WssNavBar/WssNavBar.tsx +9 -9
  87. package/lib/widget/AppAnnouncement/AppAnnouncement.tsx +2 -2
  88. package/lib/widget/Attachment/Attachment.tsx +8 -4
  89. package/lib/widget/CaseHistory/CaseHistory.tsx +12 -10
  90. package/lib/widget/FileUtility/ActionButtonsForFileUtil/ActionButtonsForFileUtil.tsx +1 -1
  91. package/lib/widget/FileUtility/FileUtility/FileUtility.tsx +5 -4
  92. package/lib/widget/Followers/Followers.tsx +2 -2
  93. package/lib/widget/QuickCreate/QuickCreate.tsx +1 -0
  94. package/lib/widget/QuickCreate/config-ext.json +9 -0
  95. package/lib/widget/SummaryItem/SummaryItem.tsx +3 -2
  96. package/lib/widget/ToDo/ToDo.tsx +91 -21
  97. package/package.json +1 -1
  98. /package/lib/field/{MultiSelect → Multiselect}/index.tsx +0 -0
  99. /package/lib/field/{MultiSelect → Multiselect}/utils.ts +0 -0
@@ -1,12 +1,13 @@
1
- import CurrencyTextField from '@unicef/material-ui-currency-textfield';
2
-
1
+ import { NumericFormat } from 'react-number-format';
2
+ import { TextField } from '@mui/material';
3
+ import { useState } from 'react';
3
4
  import { getCurrencyCharacters, getCurrencyOptions } from '@pega/react-sdk-components/lib/components/field/Currency/currency-utils';
4
5
  import handleEvent from '@pega/react-sdk-components/lib/components/helpers/event-utils';
5
6
  import { format } from '@pega/react-sdk-components/lib/components/helpers/formatters';
6
7
  import { getComponentFromMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
7
8
  import { PConnFieldProps } from '@pega/react-sdk-components/lib/types/PConnProps';
8
9
 
9
- /* Using @unicef/material-ui-currency-textfield component here, since it allows formatting decimal values,
10
+ /* Using react-number-format component here, since it allows formatting decimal values,
10
11
  as per the locale.
11
12
  */
12
13
 
@@ -14,7 +15,7 @@ interface DecimalProps extends PConnFieldProps {
14
15
  // If any, enter additional props that only exist on Decimal here
15
16
  currencyISOCode?: string;
16
17
  decimalPrecision?: number;
17
- showGroupSeparators?: string;
18
+ showGroupSeparators?: boolean;
18
19
  formatter?: string;
19
20
  }
20
21
 
@@ -36,13 +37,15 @@ export default function Decimal(props: DecimalProps) {
36
37
  displayMode,
37
38
  hideLabel,
38
39
  currencyISOCode = 'USD',
39
- decimalPrecision = 2,
40
- showGroupSeparators = true,
40
+ decimalPrecision,
41
+ showGroupSeparators,
41
42
  testId,
42
43
  placeholder,
43
44
  formatter
44
45
  } = props;
45
46
 
47
+ const [values, setValues] = useState(value.toString());
48
+
46
49
  const pConn = getPConnect();
47
50
  const actions = pConn.getActionsApi();
48
51
  const propName = (pConn.getStateProps() as any).value;
@@ -55,6 +58,12 @@ export default function Decimal(props: DecimalProps) {
55
58
 
56
59
  const theCurrencyOptions = getCurrencyOptions(currencyISOCode);
57
60
 
61
+ let readOnlyProp = {}; // Note: empty if NOT ReadOnly
62
+
63
+ if (readOnly) {
64
+ readOnlyProp = { readOnly: true };
65
+ }
66
+
58
67
  let formattedValue = '';
59
68
  if (formatter === 'Currency') {
60
69
  formattedValue = format(value, formatter.toLowerCase(), theCurrencyOptions);
@@ -62,7 +71,7 @@ export default function Decimal(props: DecimalProps) {
62
71
  formattedValue = format(value, pConn.getComponentName().toLowerCase(), theCurrencyOptions);
63
72
  }
64
73
 
65
- if (displayMode === 'LABELS_LEFT') {
74
+ if (displayMode === 'DISPLAY_ONLY') {
66
75
  return <FieldValueList name={hideLabel ? '' : label} value={formattedValue} />;
67
76
  }
68
77
 
@@ -74,12 +83,17 @@ export default function Decimal(props: DecimalProps) {
74
83
  'data-test-id': testId
75
84
  };
76
85
 
77
- function decimalOnBlur(event, inValue) {
78
- handleEvent(actions, 'changeNblur', propName, inValue !== '' ? Number(inValue) : inValue);
86
+ function decimalOnBlur() {
87
+ handleEvent(actions, 'changeNblur', propName, values);
79
88
  }
80
89
 
90
+ const handleChange = val => {
91
+ setValues(val.value);
92
+ };
93
+
81
94
  return (
82
- <CurrencyTextField
95
+ <NumericFormat
96
+ valueIsNumericString
83
97
  fullWidth
84
98
  variant={readOnly ? 'standard' : 'outlined'}
85
99
  helperText={helperTextToDisplay}
@@ -89,17 +103,17 @@ export default function Decimal(props: DecimalProps) {
89
103
  disabled={disabled}
90
104
  error={status === 'error'}
91
105
  label={label}
92
- value={value}
93
- readOnly={!!readOnly}
94
- type='text'
95
- outputFormat='number'
96
- textAlign='left'
97
- InputProps={{ inputProps: { ...testProp } }}
98
- currencySymbol={readOnly && formatter === 'Currency' ? theCurrSym : ''}
99
- decimalCharacter={theCurrDec}
100
- digitGroupSeparator={showGroupSeparators ? theCurrSep : ''}
101
- decimalPlaces={decimalPrecision}
106
+ value={values}
107
+ onValueChange={val => {
108
+ handleChange(val);
109
+ }}
102
110
  onBlur={!readOnly ? decimalOnBlur : undefined}
111
+ prefix={readOnly && formatter === 'Currency' ? theCurrSym : ''}
112
+ decimalSeparator={theCurrDec}
113
+ thousandSeparator={showGroupSeparators ? theCurrSep : ''}
114
+ decimalScale={readOnly && formatter === 'Currency' ? undefined : decimalPrecision}
115
+ InputProps={{ ...readOnlyProp, inputProps: { ...testProp } }}
116
+ customInput={TextField}
103
117
  />
104
118
  );
105
119
  }
@@ -1,6 +1,6 @@
1
1
  import { useEffect, useState } from 'react';
2
- import { TextField } from '@material-ui/core';
3
- import MenuItem from '@material-ui/core/MenuItem';
2
+ import { TextField } from '@mui/material';
3
+ import MenuItem from '@mui/material/MenuItem';
4
4
  import isDeepEqual from 'fast-deep-equal/react';
5
5
  import Utils from '@pega/react-sdk-components/lib/components/helpers/utils';
6
6
  import { getDataPage } from '@pega/react-sdk-components/lib/components/helpers/data_page';
@@ -165,7 +165,7 @@ export default function Dropdown(props: DropdownProps) {
165
165
 
166
166
  let readOnlyProp = {};
167
167
 
168
- if (displayMode === 'LABELS_LEFT') {
168
+ if (displayMode === 'DISPLAY_ONLY') {
169
169
  return (
170
170
  <FieldValueList
171
171
  name={hideLabel ? '' : label}
@@ -1,8 +1,10 @@
1
- import { InputAdornment, TextField } from '@material-ui/core';
2
- import MailOutlineIcon from '@material-ui/icons/MailOutline';
1
+ import { useEffect, useState } from 'react';
2
+ import { InputAdornment, TextField } from '@mui/material';
3
+ import MailOutlineIcon from '@mui/icons-material/MailOutline';
3
4
 
4
5
  import { getComponentFromMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
5
6
  import { PConnFieldProps } from '@pega/react-sdk-components/lib/types/PConnProps';
7
+ import handleEvent from '@pega/react-sdk-components/lib/components/helpers/event-utils';
6
8
 
7
9
  interface EmailProps extends PConnFieldProps {
8
10
  // If any, enter additional props that only exist on Date here
@@ -14,14 +16,13 @@ export default function Email(props: EmailProps) {
14
16
  const FieldValueList = getComponentFromMap('FieldValueList');
15
17
 
16
18
  const {
19
+ getPConnect,
17
20
  label,
18
21
  required,
19
22
  disabled,
20
23
  value = '',
21
24
  validatemessage,
22
25
  status,
23
- onChange,
24
- onBlur,
25
26
  readOnly,
26
27
  testId,
27
28
  helperText,
@@ -29,9 +30,20 @@ export default function Email(props: EmailProps) {
29
30
  hideLabel,
30
31
  placeholder
31
32
  } = props;
33
+
34
+ const pConn = getPConnect();
35
+ const actions = pConn.getActionsApi();
36
+ const propName = (pConn.getStateProps() as any).value;
37
+
32
38
  const helperTextToDisplay = validatemessage || helperText;
33
39
 
34
- if (displayMode === 'LABELS_LEFT') {
40
+ const [inputValue, setInputValue] = useState('');
41
+
42
+ useEffect(() => {
43
+ setInputValue(value);
44
+ }, [value]);
45
+
46
+ if (displayMode === 'DISPLAY_ONLY') {
35
47
  return <FieldValueList name={hideLabel ? '' : label} value={value} />;
36
48
  }
37
49
 
@@ -49,6 +61,15 @@ export default function Email(props: EmailProps) {
49
61
  'data-test-id': testId
50
62
  };
51
63
 
64
+ function handleChange(event) {
65
+ // update internal value
66
+ setInputValue(event?.target?.value);
67
+ }
68
+
69
+ function handleBlur() {
70
+ handleEvent(actions, 'changeNblur', propName, inputValue);
71
+ }
72
+
52
73
  return (
53
74
  <TextField
54
75
  fullWidth
@@ -58,11 +79,11 @@ export default function Email(props: EmailProps) {
58
79
  size='small'
59
80
  required={required}
60
81
  disabled={disabled}
61
- onChange={onChange}
62
- onBlur={!readOnly ? onBlur : undefined}
82
+ onChange={handleChange}
83
+ onBlur={!readOnly ? handleBlur : undefined}
63
84
  error={status === 'error'}
64
85
  label={label}
65
- value={value}
86
+ value={inputValue}
66
87
  type='email'
67
88
  InputProps={{
68
89
  startAdornment: (
@@ -1,5 +1,5 @@
1
1
  import { ReactElement, useMemo } from 'react';
2
- import { Grid } from '@material-ui/core';
2
+ import { Grid } from '@mui/material';
3
3
  import FieldGroup from '@pega/react-sdk-components/lib/components/designSystemExtension/FieldGroup';
4
4
  import { PConnFieldProps } from '@pega/react-sdk-components/lib/types/PConnProps';
5
5
 
@@ -15,7 +15,7 @@ interface GroupProps extends PConnFieldProps {
15
15
  export default function Group(props: GroupProps) {
16
16
  const { children, heading, showHeading, instructions, collapsible, displayMode, type } = props;
17
17
 
18
- const isReadOnly = displayMode === 'LABELS_LEFT';
18
+ const isReadOnly = displayMode === 'DISPLAY_ONLY';
19
19
 
20
20
  const content = useMemo(() => {
21
21
  return (
@@ -1,5 +1,7 @@
1
- import { TextField } from '@material-ui/core';
1
+ import { useEffect, useState } from 'react';
2
+ import { TextField } from '@mui/material';
2
3
 
4
+ import handleEvent from '@pega/react-sdk-components/lib/components/helpers/event-utils';
3
5
  import { getComponentFromMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
4
6
  import { PConnFieldProps } from '@pega/react-sdk-components/lib/types/PConnProps';
5
7
 
@@ -13,14 +15,13 @@ export default function Integer(props: IntegerProps) {
13
15
  const FieldValueList = getComponentFromMap('FieldValueList');
14
16
 
15
17
  const {
18
+ getPConnect,
16
19
  label,
17
20
  required,
18
21
  disabled,
19
22
  value = '',
20
23
  validatemessage,
21
24
  status,
22
- onChange,
23
- onBlur,
24
25
  readOnly,
25
26
  testId,
26
27
  helperText,
@@ -28,11 +29,20 @@ export default function Integer(props: IntegerProps) {
28
29
  hideLabel,
29
30
  placeholder
30
31
  } = props;
32
+
33
+ const pConn = getPConnect();
34
+ const actions = pConn.getActionsApi();
35
+ const propName = (pConn.getStateProps() as any).value;
36
+
31
37
  const helperTextToDisplay = validatemessage || helperText;
32
38
 
33
- // console.log(`Integer: label: ${label} value: ${value}`);
39
+ const [inputValue, setInputValue] = useState('');
40
+
41
+ useEffect(() => {
42
+ setInputValue(value);
43
+ }, [value]);
34
44
 
35
- if (displayMode === 'LABELS_LEFT') {
45
+ if (displayMode === 'DISPLAY_ONLY') {
36
46
  return <FieldValueList name={hideLabel ? '' : label} value={value} />;
37
47
  }
38
48
 
@@ -64,7 +74,11 @@ export default function Integer(props: IntegerProps) {
64
74
  }
65
75
 
66
76
  // Pass through to the Constellation change handler
67
- onChange(event);
77
+ setInputValue(event.target.value);
78
+ }
79
+
80
+ function handleBlur() {
81
+ handleEvent(actions, 'changeNblur', propName, inputValue);
68
82
  }
69
83
 
70
84
  return (
@@ -77,10 +91,10 @@ export default function Integer(props: IntegerProps) {
77
91
  required={required}
78
92
  disabled={disabled}
79
93
  onChange={intOnChange}
80
- onBlur={!readOnly ? onBlur : undefined}
94
+ onBlur={!readOnly ? handleBlur : undefined}
81
95
  error={status === 'error'}
82
96
  label={label}
83
- value={value}
97
+ value={inputValue}
84
98
  type='text'
85
99
  inputProps={{ inputMode: 'numeric', pattern: '[0-9]*', ...testProp }}
86
100
  />
@@ -1,15 +1,9 @@
1
- import { Checkbox, TextField } from '@material-ui/core';
2
- import Autocomplete from '@material-ui/lab/Autocomplete';
3
- import CheckBoxOutlineBlankIcon from '@material-ui/icons/CheckBoxOutlineBlank';
4
- import CheckBoxIcon from '@material-ui/icons/CheckBox';
5
1
  import { useEffect, useMemo, useRef, useState } from 'react';
2
+ import { Autocomplete, TextField } from '@mui/material';
6
3
  import { doSearch, getDisplayFieldsMetaData, useDeepMemo, preProcessColumns, getGroupDataForItemsTree } from './utils';
7
4
  import { insertInstruction, deleteInstruction } from '@pega/react-sdk-components/lib/components/helpers/instructions-utils';
8
5
  import { debounce } from 'throttle-debounce';
9
6
 
10
- const icon = <CheckBoxOutlineBlankIcon fontSize='small' />;
11
- const checkedIcon = <CheckBoxIcon fontSize='small' />;
12
-
13
7
  export default function Multiselect(props) {
14
8
  const {
15
9
  getPConnect,
@@ -115,7 +109,7 @@ export default function Multiselect(props) {
115
109
  const pConn = getPConnect();
116
110
  const contextName = pConn.getContextName();
117
111
  const listActions = pConn.getListActions();
118
- const dataApiObj = useRef();
112
+ const dataApiObj: any = useRef();
119
113
 
120
114
  // main search function trigger
121
115
  const getCaseListBasedOnParams = async (searchText, group, selectedRows, currentItemsTree, isTriggeredFromSearch = false) => {
@@ -226,16 +220,16 @@ export default function Multiselect(props) {
226
220
  fullWidth
227
221
  options={itemsTree}
228
222
  disableCloseOnSelect
229
- getOptionSelected={(option: any, val: any) => option?.primary === val?.primary}
223
+ // getOptionSelected={(option: any, val: any) => option?.primary === val?.primary}
230
224
  getOptionLabel={(option: any) => option?.primary}
231
225
  onChange={handleChange}
232
226
  value={selectedItems}
233
- renderOption={(option: any, { selected }) => (
234
- <>
235
- <Checkbox icon={icon} checkedIcon={checkedIcon} style={{ marginRight: 8 }} checked={selected} />
236
- {option.primary}
237
- </>
238
- )}
227
+ // renderOption={(_props, option: any, { selected }) => (
228
+ // <>
229
+ // <Checkbox icon={icon} checkedIcon={checkedIcon} style={{ marginRight: 8 }} checked={selected} />
230
+ // {option.primary}
231
+ // </>
232
+ // )}
239
233
  renderInput={params => (
240
234
  <TextField {...params} variant='outlined' fullWidth label={label} placeholder={placeholder} size='small' onChange={onSearchHandler} />
241
235
  )}
@@ -1,17 +1,20 @@
1
- import CurrencyTextField from '@unicef/material-ui-currency-textfield';
2
-
1
+ import { useState } from 'react';
2
+ import { NumericFormat } from 'react-number-format';
3
+ import { TextField } from '@mui/material';
3
4
  import { getComponentFromMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
4
5
  import { PConnFieldProps } from '@pega/react-sdk-components/lib/types/PConnProps';
5
6
  import { getCurrencyCharacters, getCurrencyOptions } from '@pega/react-sdk-components/lib/components/field/Currency/currency-utils';
6
7
  import handleEvent from '@pega/react-sdk-components/lib/components/helpers/event-utils';
7
8
  import { format } from '@pega/react-sdk-components/lib/components/helpers/formatters';
8
9
 
9
- /* Using @unicef/material-ui-currency-textfield component here, since it allows formatting decimal values,
10
+ /* Using react-number-format component here, since it allows formatting decimal values,
10
11
  as per the locale.
11
12
  */
12
13
  interface PercentageProps extends PConnFieldProps {
13
14
  // If any, enter additional props that only exist on Percentage here
14
15
  currencyISOCode?: string;
16
+ showGroupSeparators?: string;
17
+ decimalPrecision?: number;
15
18
  }
16
19
 
17
20
  export default function Percentage(props: PercentageProps) {
@@ -34,9 +37,13 @@ export default function Percentage(props: PercentageProps) {
34
37
  helperText,
35
38
  displayMode,
36
39
  hideLabel,
37
- placeholder
40
+ placeholder,
41
+ showGroupSeparators,
42
+ decimalPrecision
38
43
  } = props;
39
44
 
45
+ const [values, setValues] = useState(value.toString());
46
+
40
47
  const pConn = getPConnect();
41
48
  const actions = pConn.getActionsApi();
42
49
  const propName = (pConn.getStateProps() as any).value;
@@ -45,9 +52,13 @@ export default function Percentage(props: PercentageProps) {
45
52
  const theCurrencyOptions = getCurrencyOptions(currencyISOCode);
46
53
  const formattedValue = format(value, pConn.getComponentName().toLowerCase(), theCurrencyOptions);
47
54
 
48
- // console.log(`Percentage: label: ${label} value: ${value}`);
55
+ let readOnlyProp = {}; // Note: empty if NOT ReadOnly
56
+
57
+ if (readOnly) {
58
+ readOnlyProp = { readOnly: true };
59
+ }
49
60
 
50
- if (displayMode === 'LABELS_LEFT') {
61
+ if (displayMode === 'DISPLAY_ONLY') {
51
62
  return <FieldValueList name={hideLabel ? '' : label} value={formattedValue} />;
52
63
  }
53
64
 
@@ -65,12 +76,17 @@ export default function Percentage(props: PercentageProps) {
65
76
  const theCurrDec = theSymbols.theDecimalIndicator;
66
77
  const theCurrSep = theSymbols.theDigitGroupSeparator;
67
78
 
68
- function PercentageOnBlur(event, inValue) {
69
- handleEvent(actions, 'changeNblur', propName, inValue !== '' ? Number(inValue) : inValue);
79
+ function PercentageOnBlur() {
80
+ handleEvent(actions, 'changeNblur', propName, values);
70
81
  }
71
82
 
83
+ const handleChange = val => {
84
+ setValues(val.value);
85
+ };
86
+
72
87
  return (
73
- <CurrencyTextField
88
+ <NumericFormat
89
+ valueIsNumericString
74
90
  fullWidth
75
91
  variant={readOnly ? 'standard' : 'outlined'}
76
92
  helperText={helperTextToDisplay}
@@ -78,20 +94,19 @@ export default function Percentage(props: PercentageProps) {
78
94
  size='small'
79
95
  required={required}
80
96
  disabled={disabled}
81
- readOnly={!!readOnly}
82
97
  error={status === 'error'}
83
98
  label={label}
84
- value={value}
85
- type='text'
86
- outputFormat='number'
87
- textAlign='left'
88
- InputProps={{
89
- inputProps: { ...testProp }
99
+ value={values}
100
+ onValueChange={val => {
101
+ handleChange(val);
90
102
  }}
91
- currencySymbol=''
92
- decimalCharacter={theCurrDec}
93
- digitGroupSeparator={theCurrSep}
94
103
  onBlur={!readOnly ? PercentageOnBlur : undefined}
104
+ decimalSeparator={theCurrDec}
105
+ thousandSeparator={showGroupSeparators ? theCurrSep : ''}
106
+ decimalScale={decimalPrecision}
107
+ suffix='%'
108
+ InputProps={{ ...readOnlyProp, inputProps: { ...testProp } }}
109
+ customInput={TextField}
95
110
  />
96
111
  );
97
112
  }
@@ -1,7 +1,9 @@
1
- import MuiPhoneNumber from 'material-ui-phone-number';
1
+ import { useEffect, useState } from 'react';
2
+ import { MuiTelInput } from 'mui-tel-input';
2
3
 
3
4
  import { getComponentFromMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
4
5
  import { PConnFieldProps } from '@pega/react-sdk-components/lib/types/PConnProps';
6
+ import handleEvent from '@pega/react-sdk-components/lib/components/helpers/event-utils';
5
7
 
6
8
  interface PhoneProps extends PConnFieldProps {
7
9
  // If any, enter additional props that only exist on Phone here
@@ -12,6 +14,7 @@ export default function Phone(props: PhoneProps) {
12
14
  const FieldValueList = getComponentFromMap('FieldValueList');
13
15
 
14
16
  const {
17
+ getPConnect,
15
18
  label,
16
19
  required,
17
20
  disabled,
@@ -19,7 +22,6 @@ export default function Phone(props: PhoneProps) {
19
22
  validatemessage,
20
23
  status,
21
24
  onChange,
22
- onBlur,
23
25
  readOnly,
24
26
  testId,
25
27
  helperText,
@@ -27,6 +29,14 @@ export default function Phone(props: PhoneProps) {
27
29
  hideLabel,
28
30
  placeholder
29
31
  } = props;
32
+
33
+ const pConn = getPConnect();
34
+ const actions = pConn.getActionsApi();
35
+ const propName = (pConn.getStateProps() as any).value;
36
+
37
+ const [inputValue, setInputValue] = useState(value);
38
+ useEffect(() => setInputValue(value), [value]);
39
+
30
40
  const helperTextToDisplay = validatemessage || helperText;
31
41
 
32
42
  let testProp = {};
@@ -35,7 +45,7 @@ export default function Phone(props: PhoneProps) {
35
45
  'data-test-id': testId
36
46
  };
37
47
 
38
- if (displayMode === 'LABELS_LEFT') {
48
+ if (displayMode === 'DISPLAY_ONLY') {
39
49
  return <FieldValueList name={hideLabel ? '' : label} value={value} />;
40
50
  }
41
51
 
@@ -47,11 +57,12 @@ export default function Phone(props: PhoneProps) {
47
57
  const disableDropdown = true;
48
58
  return (
49
59
  <div>
50
- <MuiPhoneNumber
60
+ <MuiTelInput
51
61
  fullWidth
52
62
  helperText={helperTextToDisplay}
53
63
  placeholder={placeholder ?? ''}
54
64
  size='small'
65
+ defaultCountry='US'
55
66
  required={required}
56
67
  disabled={disabled}
57
68
  onChange={onChange}
@@ -69,32 +80,31 @@ export default function Phone(props: PhoneProps) {
69
80
  }
70
81
 
71
82
  const handleChange = inputVal => {
72
- let phoneValue = inputVal && inputVal.replace(/\D+/g, '');
73
- phoneValue = `+${phoneValue}`;
74
- onChange({ value: phoneValue });
83
+ setInputValue(inputVal);
75
84
  };
76
85
 
77
86
  const handleBlur = event => {
78
87
  const phoneValue = event?.target?.value;
79
- event.target.value = `+${phoneValue && phoneValue.replace(/\D+/g, '')}`;
80
- onBlur(event);
88
+ let phoneNumber = phoneValue.split(' ').slice(1).join();
89
+ phoneNumber = phoneNumber ? `+${phoneValue && phoneValue.replace(/\D+/g, '')}` : '';
90
+ handleEvent(actions, 'changeNblur', propName, phoneNumber);
81
91
  };
82
92
 
83
93
  return (
84
- <MuiPhoneNumber
94
+ <MuiTelInput
85
95
  fullWidth
86
96
  variant='outlined'
87
97
  helperText={helperTextToDisplay}
88
98
  placeholder={placeholder ?? ''}
89
99
  size='small'
90
- defaultCountry='us'
100
+ defaultCountry='US'
91
101
  required={required}
92
102
  disabled={disabled}
93
103
  onChange={handleChange}
94
104
  onBlur={!readOnly ? handleBlur : undefined}
95
105
  error={status === 'error'}
96
106
  label={label}
97
- value={value}
107
+ value={inputValue}
98
108
  InputProps={{ ...testProp }}
99
109
  />
100
110
  );
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "Phone",
3
+ "label": "Phone",
4
+ "description": "Phone",
5
+ "type": "Field",
6
+ "subtype": "DATA_CAPTURE",
7
+ "properties": []
8
+ }
@@ -1,5 +1,5 @@
1
1
  import { useState, useEffect } from 'react';
2
- import { Radio, RadioGroup, FormControl, FormControlLabel, FormLabel, FormHelperText } from '@material-ui/core';
2
+ import { Radio, RadioGroup, FormControl, FormControlLabel, FormLabel, FormHelperText } from '@mui/material';
3
3
 
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';
@@ -61,7 +61,7 @@ export default function RadioButtons(props: RadioButtonsProps) {
61
61
  setSelectedButton(value);
62
62
  }, [value]);
63
63
 
64
- if (displayMode === 'LABELS_LEFT') {
64
+ if (displayMode === 'DISPLAY_ONLY') {
65
65
  return (
66
66
  <FieldValueList
67
67
  name={hideLabel ? '' : label}
@@ -91,7 +91,7 @@ export default function RadioButtons(props: RadioButtonsProps) {
91
91
  };
92
92
 
93
93
  return (
94
- <FormControl error={status === 'error'} required={required}>
94
+ <FormControl variant='standard' error={status === 'error'} required={required}>
95
95
  <FormLabel component='legend'>{label}</FormLabel>
96
96
  <RadioGroup value={theSelectedButton} onChange={handleChange} onBlur={!readOnly ? handleBlur : undefined} row={inline}>
97
97
  {theOptions.map(theOption => {
@@ -23,7 +23,7 @@ export default function RichText(props: RichTextProps) {
23
23
 
24
24
  const helperTextToDisplay = validatemessage || helperText;
25
25
 
26
- if (displayMode === 'LABELS_LEFT') {
26
+ if (displayMode === 'DISPLAY_ONLY') {
27
27
  return <FieldValueList name={hideLabel ? '' : label} value={value} isHtml />;
28
28
  }
29
29
 
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "RichText",
3
+ "label": "Rich text editor",
4
+ "description": "Text (paragraph)",
5
+ "type": "Field",
6
+ "subtype": "Text-Paragraph",
7
+ "icon": "images/pz-text-area-active.svg",
8
+ "properties": [],
9
+ "defaultConfig": {}
10
+ }
@@ -36,10 +36,12 @@ export default function ScalarList(props: ScalarListProps) {
36
36
  {
37
37
  type: componentType,
38
38
  config: {
39
+ // @ts-ignore - Type '{ readOnly: true; displayInModal: boolean; value: any; displayMode: string; label: string; }' is not assignable to type 'ComponentMetadataConfig'.
39
40
  value: scalarValue,
40
- displayMode: 'LABELS_LEFT',
41
+ displayMode: 'DISPLAY_ONLY',
41
42
  label,
42
43
  ...restProps,
44
+ // @ts-ignore - Type 'string' is not assignable to type 'boolean | undefined'.
43
45
  readOnly: 'true'
44
46
  }
45
47
  },
@@ -49,7 +51,7 @@ export default function ScalarList(props: ScalarListProps) {
49
51
  ); // 2nd, 3rd, and 4th args empty string/object/null until typedef marked correctly as optional;
50
52
  });
51
53
 
52
- if (['LABELS_LEFT', 'STACKED_LARGE_VAL', 'DISPLAY_ONLY'].includes(displayMode)) {
54
+ if (['STACKED_LARGE_VAL', 'DISPLAY_ONLY'].includes(displayMode)) {
53
55
  return (
54
56
  <div>
55
57
  <CommaSeparatedList items={items} />
@@ -1,6 +1,6 @@
1
- import Typography from '@material-ui/core/Typography';
2
- import Grid from '@material-ui/core/Grid';
3
- import { makeStyles } from '@material-ui/core/styles';
1
+ import Typography from '@mui/material/Typography';
2
+ import Grid from '@mui/material/Grid';
3
+ import makeStyles from '@mui/styles/makeStyles';
4
4
 
5
5
  import { getComponentFromMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
6
6
  import { PConnFieldProps } from '@pega/react-sdk-components/lib/types/PConnProps';
@@ -52,7 +52,7 @@ export default function SemanticLink(props: SemanticLinkProps) {
52
52
  const { text, displayMode, label, hideLabel } = props;
53
53
  const classes = useStyles();
54
54
 
55
- if (displayMode === 'LABELS_LEFT' || (!displayMode && label !== undefined)) {
55
+ if (displayMode === 'DISPLAY_ONLY' || (!displayMode && label !== undefined)) {
56
56
  const value = text || '---';
57
57
  return (
58
58
  <Grid container spacing={1} style={{ padding: '4px 0px' }} id='semantic-link-grid'>