@pega/react-sdk-overrides 23.1.10 → 23.1.12
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.
- package/LICENSE +201 -0
- package/README.md +17 -0
- package/SECURITY.md +10 -0
- package/lib/designSystemExtension/AlertBanner/AlertBanner.tsx +6 -14
- package/lib/designSystemExtension/Banner/Banner.tsx +14 -11
- package/lib/designSystemExtension/CaseSummaryFields/CaseSummaryFields.css +0 -1
- package/lib/designSystemExtension/CaseSummaryFields/CaseSummaryFields.tsx +27 -22
- package/lib/designSystemExtension/DetailsFields/DetailsFields.tsx +14 -20
- package/lib/designSystemExtension/DetailsFields/index.tsx +1 -1
- package/lib/designSystemExtension/FieldGroup/FieldGroup.tsx +44 -19
- package/lib/designSystemExtension/FieldGroupList/FieldGroupList.tsx +7 -12
- package/lib/designSystemExtension/FieldValueList/FieldValueList.tsx +21 -32
- package/lib/designSystemExtension/Operator/Operator.tsx +94 -82
- package/lib/designSystemExtension/Pulse/Pulse.tsx +14 -16
- package/lib/designSystemExtension/RichTextEditor/RichTextEditor.tsx +6 -5
- package/lib/designSystemExtension/WssQuickCreate/WssQuickCreate.tsx +14 -14
- package/lib/field/AutoComplete/AutoComplete.tsx +24 -26
- package/lib/field/AutoComplete/config-ext.json +2 -3
- package/lib/field/CancelAlert/CancelAlert.tsx +98 -84
- package/lib/field/CancelAlert/index.tsx +1 -1
- package/lib/field/Checkbox/Checkbox.tsx +120 -63
- package/lib/field/Checkbox/config-ext.json +2 -3
- package/lib/field/Currency/Currency.tsx +25 -50
- package/lib/field/Currency/config-ext.json +2 -3
- package/lib/field/Currency/currency-utils.ts +9 -16
- package/lib/field/Date/Date.tsx +15 -11
- package/lib/field/Date/config-ext.json +2 -3
- package/lib/field/DateTime/DateTime.tsx +9 -9
- package/lib/field/DateTime/config-ext.json +1 -2
- package/lib/field/Decimal/Decimal.tsx +33 -44
- package/lib/field/Decimal/config-ext.json +1 -2
- package/lib/field/Decimal/index.tsx +1 -1
- package/lib/field/Dropdown/Dropdown.tsx +122 -31
- package/lib/field/Dropdown/config-ext.json +1 -2
- package/lib/field/Email/Email.tsx +11 -10
- package/lib/field/Email/config-ext.json +1 -2
- package/lib/field/Email/index.tsx +1 -1
- package/lib/field/Group/Group.tsx +39 -0
- package/lib/field/Group/config-ext.json +7 -0
- package/lib/field/Group/index.tsx +1 -0
- package/lib/field/Integer/Integer.tsx +8 -7
- package/lib/field/Integer/config-ext.json +1 -2
- package/lib/field/MultiSelect/Multiselect.tsx +244 -0
- package/lib/field/MultiSelect/index.tsx +1 -0
- package/lib/field/MultiSelect/utils.ts +230 -0
- package/lib/field/Percentage/Percentage.tsx +46 -41
- package/lib/field/Percentage/config-ext.json +1 -2
- package/lib/field/Phone/Phone.tsx +13 -12
- package/lib/field/Phone/index.tsx +1 -1
- package/lib/field/RadioButtons/RadioButtons.tsx +20 -18
- package/lib/field/RadioButtons/config-ext.json +1 -2
- package/lib/field/RichText/RichText.tsx +8 -7
- package/lib/field/ScalarList/ScalarList.tsx +3 -13
- package/lib/field/ScalarList/config-ext.json +1 -2
- package/lib/field/SemanticLink/SemanticLink.tsx +7 -7
- package/lib/field/SemanticLink/config-ext.json +1 -2
- package/lib/field/SemanticLink/utils.ts +8 -11
- package/lib/field/TextArea/TextArea.tsx +7 -6
- package/lib/field/TextArea/config-ext.json +1 -2
- package/lib/field/TextContent/TextContent.tsx +4 -6
- package/lib/field/TextContent/config-ext.json +1 -2
- package/lib/field/TextInput/TextInput.tsx +9 -7
- package/lib/field/TextInput/config-ext.json +1 -2
- package/lib/field/TextInput/index.tsx +1 -1
- package/lib/field/Time/Time.tsx +11 -11
- package/lib/field/Time/config-ext.json +1 -2
- package/lib/field/URL/URL.tsx +9 -8
- package/lib/field/URL/config-ext.json +1 -2
- package/lib/field/URL/index.tsx +1 -1
- package/lib/field/UserReference/UserReference.tsx +18 -16
- package/lib/field/UserReference/UserReferenceUtils.ts +2 -2
- package/lib/field/UserReference/config-ext.json +1 -2
- package/lib/helpers/attachmentHelpers.ts +13 -8
- package/lib/helpers/case-utils.tsx +4 -8
- package/lib/helpers/common-utils.ts +5 -1
- package/lib/helpers/data_page.ts +3 -7
- package/lib/helpers/date-format-utils.ts +3 -3
- package/lib/helpers/event-utils.ts +3 -3
- package/lib/helpers/field-group-utils.ts +1 -1
- package/lib/helpers/formatters/Boolean.ts +9 -26
- package/lib/helpers/formatters/Currency.ts +15 -21
- package/lib/helpers/formatters/CurrencyMap.ts +505 -501
- package/lib/helpers/formatters/Date.ts +20 -26
- package/lib/helpers/formatters/common.ts +1 -2
- package/lib/helpers/formatters/index.ts +26 -19
- package/lib/helpers/instructions-utils.ts +38 -0
- package/lib/helpers/reactContextHelpers.ts +2 -2
- package/lib/helpers/simpleTableHelpers.ts +59 -83
- package/lib/helpers/state-utils.tsx +5 -9
- package/lib/helpers/template-utils.ts +3 -6
- package/lib/helpers/utils.ts +5 -5
- package/lib/helpers/versionHelpers.ts +1 -4
- package/lib/infra/ActionButtons/ActionButtons.tsx +38 -29
- package/lib/infra/ActionButtons/index.tsx +1 -1
- package/lib/infra/Assignment/Assignment.tsx +99 -79
- package/lib/infra/Assignment/index.tsx +1 -1
- package/lib/infra/AssignmentCard/AssignmentCard.tsx +13 -16
- package/lib/infra/AssignmentCard/index.tsx +1 -1
- package/lib/infra/Containers/FlowContainer/FlowContainer.tsx +67 -213
- package/lib/infra/Containers/FlowContainer/helpers.ts +34 -45
- package/lib/infra/Containers/FlowContainer/index.tsx +1 -1
- package/lib/infra/Containers/ModalViewContainer/ListViewActionButtons/ListViewActionButtons.tsx +65 -0
- package/lib/infra/Containers/ModalViewContainer/ListViewActionButtons/index.tsx +1 -0
- package/lib/infra/Containers/ModalViewContainer/ModalViewContainer.tsx +227 -218
- package/lib/infra/Containers/ModalViewContainer/index.tsx +1 -1
- package/lib/infra/Containers/SimpleView/SimpleView.tsx +48 -0
- package/lib/infra/Containers/SimpleView/helper.ts +125 -0
- package/lib/infra/Containers/SimpleView/index.tsx +1 -0
- package/lib/infra/Containers/ViewContainer/ViewContainer.tsx +36 -46
- package/lib/infra/Containers/helpers.ts +6 -0
- package/lib/infra/DashboardFilter/DashboardFilter.tsx +21 -42
- package/lib/infra/DashboardFilter/filterUtils.tsx +12 -43
- package/lib/infra/DeferLoad/DeferLoad.tsx +22 -28
- package/lib/infra/DeferLoad/index.tsx +1 -1
- package/lib/infra/ErrorBoundary/ErrorBoundary.tsx +16 -30
- package/lib/infra/MultiStep/MultiStep.css +11 -15
- package/lib/infra/MultiStep/MultiStep.tsx +176 -212
- package/lib/infra/MultiStep/index.tsx +1 -1
- package/lib/infra/NavBar/NavBar.css +103 -105
- package/lib/infra/NavBar/NavBar.tsx +19 -31
- package/lib/infra/Reference/Reference.tsx +16 -18
- package/lib/infra/Region/Region.tsx +4 -6
- package/lib/infra/RootContainer/RootContainer.tsx +75 -111
- package/lib/infra/RootContainer/index.tsx +1 -1
- package/lib/infra/Stages/Stages.tsx +32 -39
- package/lib/infra/VerticalTabs/LeftAlignVerticalTabs/LeftAlignVerticalTabs.tsx +11 -11
- package/lib/infra/VerticalTabs/VerticalTabs/VerticalTabs.tsx +21 -28
- package/lib/infra/View/View.tsx +17 -21
- package/lib/template/AppShell/AppShell.css +22 -23
- package/lib/template/AppShell/AppShell.tsx +39 -74
- package/lib/template/BannerPage/BannerPage.tsx +12 -14
- package/lib/template/CaseSummary/CaseSummary.tsx +58 -18
- package/lib/template/CaseSummary/config-ext.json +1 -2
- package/lib/template/CaseView/CaseView.tsx +34 -63
- package/lib/template/CaseView/config-ext.json +1 -2
- package/lib/template/CaseViewActionsMenu/CaseViewActionsMenu.tsx +63 -19
- package/lib/template/Confirmation/Confirmation.tsx +12 -17
- package/lib/template/Confirmation/config-ext.json +1 -2
- package/lib/template/DataReference/DataReference.tsx +95 -121
- package/lib/template/DataReference/config-ext.json +1 -2
- package/lib/template/DefaultForm/DefaultForm.css +7 -3
- package/lib/template/DefaultForm/DefaultForm.tsx +13 -16
- package/lib/template/DefaultForm/config-ext.json +1 -2
- package/lib/template/Details/Details/Details.tsx +19 -22
- package/lib/template/Details/DetailsSubTabs/DetailsSubTabs.tsx +9 -13
- package/lib/template/Details/DetailsSubTabs/config-ext.json +1 -2
- package/lib/template/Details/DetailsThreeColumn/DetailsThreeColumn.tsx +19 -24
- package/lib/template/Details/DetailsThreeColumn/config-ext.json +1 -2
- package/lib/template/Details/DetailsTwoColumn/DetailsTwoColumn.tsx +19 -25
- package/lib/template/Details/DetailsTwoColumn/config-ext.json +1 -2
- package/lib/template/Details/DetailsTwoColumn/index.tsx +1 -1
- package/lib/template/Details/DynamicTabs/DynamicTabs.tsx +15 -14
- package/lib/template/FieldGroupTemplate/FieldGroupTemplate.tsx +15 -22
- package/lib/template/InlineDashboard/InlineDashboard.tsx +12 -14
- package/lib/template/InlineDashboardPage/InlineDashboardPage.tsx +12 -16
- package/lib/template/ListPage/ListPage.tsx +5 -10
- package/lib/template/ListPage/config-ext.json +1 -2
- package/lib/template/ListView/DefaultViewMeta.ts +1 -3
- package/lib/template/ListView/ListView.tsx +185 -175
- package/lib/template/ListView/config-ext.json +1 -2
- package/lib/template/ListView/hooks.ts +24 -26
- package/lib/template/ListView/utils.ts +51 -87
- package/lib/template/MultiReferenceReadOnly/MultiReferenceReadOnly.tsx +20 -20
- package/lib/template/NarrowWide/NarrowWide/NarrowWide.css +0 -2
- package/lib/template/NarrowWide/NarrowWide/NarrowWide.tsx +25 -38
- package/lib/template/NarrowWide/NarrowWideDetails/NarrowWideDetails.tsx +20 -25
- package/lib/template/NarrowWide/NarrowWideDetails/config-ext.json +1 -2
- package/lib/template/NarrowWide/NarrowWideForm/NarrowWideForm.css +0 -2
- package/lib/template/NarrowWide/NarrowWideForm/NarrowWideForm.tsx +14 -24
- package/lib/template/NarrowWide/NarrowWideForm/config-ext.json +1 -2
- package/lib/template/NarrowWide/NarrowWidePage/NarrowWidePage.tsx +9 -19
- package/lib/template/NarrowWide/NarrowWidePage/config-ext.json +1 -2
- package/lib/template/OneColumn/OneColumn/OneColumn.tsx +14 -15
- package/lib/template/OneColumn/OneColumn/config-ext.json +1 -2
- package/lib/template/OneColumn/OneColumnPage/OneColumnPage.tsx +3 -10
- package/lib/template/OneColumn/OneColumnPage/config-ext.json +1 -2
- package/lib/template/OneColumn/OneColumnTab/OneColumnTab.tsx +6 -10
- package/lib/template/OneColumn/OneColumnTab/config-ext.json +1 -2
- package/lib/template/PromotedFilters/PromotedFilters.css +1 -1
- package/lib/template/PromotedFilters/PromotedFilters.tsx +32 -28
- package/lib/template/SimpleTable/SimpleTable/SimpleTable.tsx +37 -33
- package/lib/template/SimpleTable/SimpleTable/config-ext.json +1 -2
- package/lib/template/SimpleTable/SimpleTableManual/SimpleTableManual.tsx +187 -121
- package/lib/template/SimpleTable/SimpleTableSelect/SimpleTableSelect.tsx +24 -25
- package/lib/template/SingleReferenceReadOnly/SingleReferenceReadOnly.tsx +30 -30
- package/lib/template/SubTabs/SubTabs.tsx +22 -40
- package/lib/template/SubTabs/config-ext.json +1 -2
- package/lib/template/SubTabs/tabUtils.ts +2 -5
- package/lib/template/TwoColumn/TwoColumn/TwoColumn.css +0 -1
- package/lib/template/TwoColumn/TwoColumn/TwoColumn.tsx +30 -28
- package/lib/template/TwoColumn/TwoColumn/config-ext.json +1 -2
- package/lib/template/TwoColumn/TwoColumnPage/TwoColumnPage.tsx +3 -10
- package/lib/template/TwoColumn/TwoColumnPage/config-ext.json +1 -2
- package/lib/template/TwoColumn/TwoColumnTab/TwoColumnTab.tsx +30 -28
- package/lib/template/TwoColumn/TwoColumnTab/config-ext.json +1 -2
- package/lib/template/WideNarrow/WideNarrow/WideNarrow.css +0 -2
- package/lib/template/WideNarrow/WideNarrow/WideNarrow.tsx +22 -34
- package/lib/template/WideNarrow/WideNarrowDetails/WideNarrowDetails.tsx +24 -28
- package/lib/template/WideNarrow/WideNarrowDetails/config-ext.json +1 -2
- package/lib/template/WideNarrow/WideNarrowForm/WideNarrowForm.css +0 -2
- package/lib/template/WideNarrow/WideNarrowForm/WideNarrowForm.tsx +13 -21
- package/lib/template/WideNarrow/WideNarrowForm/config-ext.json +1 -2
- package/lib/template/WideNarrow/WideNarrowPage/WideNarrowPage.tsx +8 -16
- package/lib/template/WideNarrow/WideNarrowPage/config-ext.json +1 -2
- package/lib/template/WideNarrow/WideNarrowPage/index.tsx +1 -1
- package/lib/template/WssNavBar/WssNavBar.tsx +18 -21
- package/lib/widget/AppAnnouncement/AppAnnouncement.tsx +29 -28
- package/lib/widget/AppAnnouncement/config-ext.json +1 -2
- package/lib/widget/Attachment/Attachment.css +60 -1
- package/lib/widget/Attachment/Attachment.tsx +378 -405
- package/lib/widget/Attachment/index.tsx +1 -1
- package/lib/widget/CaseHistory/CaseHistory.tsx +64 -66
- package/lib/widget/CaseHistory/config-ext.json +1 -2
- package/lib/widget/CaseHistory/index.tsx +1 -1
- package/lib/widget/FileUtility/ActionButtonsForFileUtil/ActionButtonsForFileUtil.tsx +16 -18
- package/lib/widget/FileUtility/FileUtility/FileUtility.css +2 -2
- package/lib/widget/FileUtility/FileUtility/FileUtility.tsx +310 -246
- package/lib/widget/FileUtility/FileUtility/config-ext.json +1 -2
- package/lib/widget/Followers/Followers.tsx +23 -20
- package/lib/widget/Followers/config-ext.json +1 -2
- package/lib/widget/QuickCreate/QuickCreate.tsx +68 -42
- package/lib/widget/SummaryItem/SummaryItem.css +9 -9
- package/lib/widget/SummaryItem/SummaryItem.tsx +58 -58
- package/lib/widget/SummaryItem/index.tsx +1 -1
- package/lib/widget/SummaryList/SummaryList.tsx +7 -10
- package/lib/widget/ToDo/ToDo.css +4 -4
- package/lib/widget/ToDo/ToDo.tsx +52 -53
- package/lib/widget/ToDo/config-ext.json +1 -2
- package/package.json +5 -2
- package/lib/helpers/auth.js +0 -834
- package/lib/helpers/authManager.ts +0 -933
- package/lib/helpers/config_access.js +0 -186
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import React, { useState, useEffect } from 'react';
|
|
2
1
|
import CurrencyTextField from '@unicef/material-ui-currency-textfield';
|
|
2
|
+
|
|
3
|
+
import { getComponentFromMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
|
|
4
|
+
import { PConnFieldProps } from '@pega/react-sdk-components/lib/types/PConnProps';
|
|
3
5
|
import handleEvent from '@pega/react-sdk-components/lib/components/helpers/event-utils';
|
|
4
6
|
import { format } from '@pega/react-sdk-components/lib/components/helpers/formatters';
|
|
5
7
|
import { getCurrencyCharacters, getCurrencyOptions } from './currency-utils';
|
|
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
8
|
|
|
9
|
-
|
|
9
|
+
/* Using @unicef/material-ui-currency-textfield component here, since it allows formatting decimal values,
|
|
10
|
+
as per the locale.
|
|
11
|
+
*/
|
|
10
12
|
|
|
11
13
|
interface CurrrencyProps extends PConnFieldProps {
|
|
12
14
|
// If any, enter additional props that only exist on Currency here
|
|
@@ -31,45 +33,26 @@ export default function Currency(props: CurrrencyProps) {
|
|
|
31
33
|
helperText,
|
|
32
34
|
displayMode,
|
|
33
35
|
hideLabel,
|
|
34
|
-
currencyISOCode = 'USD'
|
|
36
|
+
currencyISOCode = 'USD',
|
|
37
|
+
placeholder
|
|
35
38
|
} = props;
|
|
36
39
|
|
|
37
40
|
const pConn = getPConnect();
|
|
38
41
|
const actions = pConn.getActionsApi();
|
|
39
|
-
const propName = pConn.getStateProps()
|
|
42
|
+
const propName = (pConn.getStateProps() as any).value;
|
|
40
43
|
const helperTextToDisplay = validatemessage || helperText;
|
|
41
44
|
|
|
42
45
|
// console.log(`Currency: label: ${label} value: ${value}`);
|
|
43
46
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if (readOnly) {
|
|
47
|
-
readOnlyProp = { readOnly: true };
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
let testProp = {};
|
|
51
|
-
|
|
52
|
-
testProp = {
|
|
47
|
+
const testProp = {
|
|
53
48
|
'data-test-id': testId
|
|
54
49
|
};
|
|
55
50
|
|
|
56
|
-
|
|
57
|
-
const
|
|
58
|
-
const
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
useEffect(() => {
|
|
62
|
-
// currencySymbols looks like this: { theCurrencySymbol: '$', theDecimalIndicator: '.', theSeparator: ',' }
|
|
63
|
-
const theSymbols = getCurrencyCharacters(currencyISOCode);
|
|
64
|
-
setCurrSym(theSymbols.theCurrencySymbol);
|
|
65
|
-
setCurrDec(theSymbols.theDecimalIndicator);
|
|
66
|
-
setCurrSep(theSymbols.theDigitGroupSeparator);
|
|
67
|
-
}, [currencyISOCode]);
|
|
68
|
-
|
|
69
|
-
useEffect(() => {
|
|
70
|
-
// const testVal = value;
|
|
71
|
-
setCurrValue(value.toString());
|
|
72
|
-
}, [value]);
|
|
51
|
+
// currencySymbols looks like this: { theCurrencySymbol: '$', theDecimalIndicator: '.', theSeparator: ',' }
|
|
52
|
+
const theSymbols = getCurrencyCharacters(currencyISOCode);
|
|
53
|
+
const theCurrSym = theSymbols.theCurrencySymbol;
|
|
54
|
+
const theCurrDec = theSymbols.theDecimalIndicator;
|
|
55
|
+
const theCurrSep = theSymbols.theDigitGroupSeparator;
|
|
73
56
|
|
|
74
57
|
const theCurrencyOptions = getCurrencyOptions(currencyISOCode);
|
|
75
58
|
const formattedValue = format(value, pConn.getComponentName().toLowerCase(), theCurrencyOptions);
|
|
@@ -79,15 +62,7 @@ export default function Currency(props: CurrrencyProps) {
|
|
|
79
62
|
}
|
|
80
63
|
|
|
81
64
|
if (displayMode === 'STACKED_LARGE_VAL') {
|
|
82
|
-
return <FieldValueList name={hideLabel ? '' : label} value={formattedValue} variant=
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
|
|
86
|
-
function currOnChange(event, inValue) {
|
|
87
|
-
// console.log(`Currency currOnChange inValue: ${inValue}`);
|
|
88
|
-
|
|
89
|
-
// update internal value
|
|
90
|
-
setCurrValue(event?.target?.value);
|
|
65
|
+
return <FieldValueList name={hideLabel ? '' : label} value={formattedValue} variant='stacked' />;
|
|
91
66
|
}
|
|
92
67
|
|
|
93
68
|
function currOnBlur(event, inValue) {
|
|
@@ -102,22 +77,22 @@ export default function Currency(props: CurrrencyProps) {
|
|
|
102
77
|
fullWidth
|
|
103
78
|
variant={readOnly ? 'standard' : 'outlined'}
|
|
104
79
|
helperText={helperTextToDisplay}
|
|
105
|
-
placeholder=
|
|
106
|
-
size=
|
|
80
|
+
placeholder={placeholder ?? ''}
|
|
81
|
+
size='small'
|
|
107
82
|
required={required}
|
|
108
83
|
disabled={disabled}
|
|
109
|
-
|
|
110
|
-
onBlur={!readOnly ? currOnBlur : undefined}
|
|
84
|
+
readOnly={!!readOnly}
|
|
111
85
|
error={status === 'error'}
|
|
112
86
|
label={label}
|
|
113
|
-
value={
|
|
114
|
-
type=
|
|
115
|
-
outputFormat=
|
|
116
|
-
textAlign=
|
|
117
|
-
InputProps={{
|
|
87
|
+
value={value}
|
|
88
|
+
type='text'
|
|
89
|
+
outputFormat='number'
|
|
90
|
+
textAlign='left'
|
|
91
|
+
InputProps={{ inputProps: { ...testProp } }}
|
|
118
92
|
currencySymbol={theCurrSym}
|
|
119
93
|
decimalCharacter={theCurrDec}
|
|
120
94
|
digitGroupSeparator={theCurrSep}
|
|
95
|
+
onBlur={!readOnly ? currOnBlur : undefined}
|
|
121
96
|
/>
|
|
122
97
|
);
|
|
123
98
|
}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
// eslint-disable-next-line import/no-named-default
|
|
2
|
-
import { default as CurrencyAlias} from '@pega/react-sdk-components/lib/components/helpers/formatters/Currency';
|
|
2
|
+
import { default as CurrencyAlias } from '@pega/react-sdk-components/lib/components/helpers/formatters/Currency';
|
|
3
3
|
// eslint-disable-next-line import/no-named-default
|
|
4
4
|
import { default as CurrencyMapAlias } from '@pega/react-sdk-components/lib/components/helpers/formatters/CurrencyMap';
|
|
5
5
|
|
|
6
|
-
|
|
7
6
|
export const getCurrencyOptions = (inISOCode: string) => {
|
|
8
|
-
|
|
9
7
|
const operatorLocale = PCore.getEnvironmentInfo().getUseLocale() || PCore.getEnvironmentInfo().getLocale() || 'en-US';
|
|
10
8
|
|
|
11
9
|
let currMapToUse = CurrencyMapAlias.US;
|
|
@@ -15,12 +13,12 @@ export const getCurrencyOptions = (inISOCode: string) => {
|
|
|
15
13
|
// If no ISO code, use locale
|
|
16
14
|
// If no locale, default to US
|
|
17
15
|
if (inISOCode) {
|
|
18
|
-
if (inISOCode ===
|
|
16
|
+
if (inISOCode === 'EUR') {
|
|
19
17
|
currMapToUse = CurrencyMapAlias.NL;
|
|
20
|
-
localeToUse =
|
|
18
|
+
localeToUse = 'nl-NL';
|
|
21
19
|
} else {
|
|
22
20
|
// For all other ISO codes, use first 2 characters as the lookup from CurrencyMap
|
|
23
|
-
const countryCode = inISOCode.substring(0,2);
|
|
21
|
+
const countryCode = inISOCode.substring(0, 2);
|
|
24
22
|
currMapToUse = CurrencyMapAlias[countryCode];
|
|
25
23
|
}
|
|
26
24
|
} else if (operatorLocale) {
|
|
@@ -34,23 +32,19 @@ export const getCurrencyOptions = (inISOCode: string) => {
|
|
|
34
32
|
|
|
35
33
|
// If no currMapToUse at this point, default to US as a failsafe
|
|
36
34
|
if (!currMapToUse) {
|
|
37
|
-
currMapToUse = CurrencyMapAlias
|
|
35
|
+
currMapToUse = CurrencyMapAlias.US;
|
|
38
36
|
}
|
|
39
37
|
|
|
40
38
|
const theCode = currMapToUse.currencyCode.substring(0, 3);
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return currencyOptions;
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
39
|
+
return { locale: localeToUse, style: 'currency', currency: theCode };
|
|
40
|
+
};
|
|
47
41
|
|
|
48
42
|
export const getCurrencyCharacters = (inISOCode: string) => {
|
|
49
43
|
const theCurrencyChars = {
|
|
50
44
|
theCurrencySymbol: '$',
|
|
51
45
|
theDecimalIndicator: '.',
|
|
52
46
|
theDigitGroupSeparator: ','
|
|
53
|
-
}
|
|
47
|
+
};
|
|
54
48
|
|
|
55
49
|
const theCurrencyOptions = getCurrencyOptions(inISOCode);
|
|
56
50
|
|
|
@@ -71,5 +65,4 @@ export const getCurrencyCharacters = (inISOCode: string) => {
|
|
|
71
65
|
// console.log(`theCurrencyChars: symbol: ${theCurrencyChars.theCurrencySymbol} | theDigitGroupSeparator: ${theCurrencyChars.theDigitGroupSeparator} | theDecimalIndicator: ${theCurrencyChars.theDecimalIndicator}`);
|
|
72
66
|
|
|
73
67
|
return theCurrencyChars;
|
|
74
|
-
|
|
75
|
-
}
|
|
68
|
+
};
|
package/lib/field/Date/Date.tsx
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import { KeyboardDatePicker } from '@material-ui/pickers';
|
|
2
|
+
|
|
3
3
|
import handleEvent from '@pega/react-sdk-components/lib/components/helpers/event-utils';
|
|
4
4
|
import { format } from '@pega/react-sdk-components/lib/components/helpers/formatters';
|
|
5
5
|
import { dateFormatInfoDefault, getDateFormatInfo } from '@pega/react-sdk-components/lib/components/helpers/date-format-utils';
|
|
6
6
|
import { getComponentFromMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
|
|
7
|
-
import
|
|
7
|
+
import { PConnFieldProps } from '@pega/react-sdk-components/lib/types/PConnProps';
|
|
8
8
|
|
|
9
9
|
// Will return the date string in YYYY-MM-DD format which we'll be POSTing to the server
|
|
10
10
|
function getFormattedDate(date) {
|
|
@@ -39,7 +39,7 @@ export default function Date(props: DateProps) {
|
|
|
39
39
|
|
|
40
40
|
const pConn = getPConnect();
|
|
41
41
|
const actions = pConn.getActionsApi();
|
|
42
|
-
const propName = pConn.getStateProps()
|
|
42
|
+
const propName = (pConn.getStateProps() as any).value;
|
|
43
43
|
const helperTextToDisplay = validatemessage || helperText;
|
|
44
44
|
|
|
45
45
|
// Start with default dateFormatInfo
|
|
@@ -51,13 +51,17 @@ export default function Date(props: DateProps) {
|
|
|
51
51
|
dateFormatInfo.dateFormatMask = theDateFormat.dateFormatMask;
|
|
52
52
|
|
|
53
53
|
if (displayMode === 'LABELS_LEFT') {
|
|
54
|
-
const formattedDate = format(props.value, 'date', {
|
|
54
|
+
const formattedDate = format(props.value, 'date', {
|
|
55
|
+
format: dateFormatInfo.dateFormatString
|
|
56
|
+
});
|
|
55
57
|
return <FieldValueList name={hideLabel ? '' : label} value={formattedDate} />;
|
|
56
58
|
}
|
|
57
59
|
|
|
58
60
|
if (displayMode === 'STACKED_LARGE_VAL') {
|
|
59
|
-
const formattedDate = format(props.value, 'date', {
|
|
60
|
-
|
|
61
|
+
const formattedDate = format(props.value, 'date', {
|
|
62
|
+
format: dateFormatInfo.dateFormatString
|
|
63
|
+
});
|
|
64
|
+
return <FieldValueList name={hideLabel ? '' : label} value={formattedDate} variant='stacked' />;
|
|
61
65
|
}
|
|
62
66
|
|
|
63
67
|
if (readOnly) {
|
|
@@ -71,13 +75,13 @@ export default function Date(props: DateProps) {
|
|
|
71
75
|
'data-test-id': testId
|
|
72
76
|
};
|
|
73
77
|
|
|
74
|
-
const handleChange =
|
|
78
|
+
const handleChange = date => {
|
|
75
79
|
if (date && date.isValid()) {
|
|
76
80
|
onChange({ value: getFormattedDate(date) });
|
|
77
81
|
}
|
|
78
82
|
};
|
|
79
83
|
|
|
80
|
-
const handleAccept =
|
|
84
|
+
const handleAccept = date => {
|
|
81
85
|
if (date && date.isValid()) {
|
|
82
86
|
handleEvent(actions, 'changeNblur', propName, getFormattedDate(date));
|
|
83
87
|
}
|
|
@@ -86,8 +90,8 @@ export default function Date(props: DateProps) {
|
|
|
86
90
|
return (
|
|
87
91
|
<KeyboardDatePicker
|
|
88
92
|
disableToolbar
|
|
89
|
-
variant=
|
|
90
|
-
inputVariant=
|
|
93
|
+
variant='inline'
|
|
94
|
+
inputVariant='outlined'
|
|
91
95
|
placeholder={dateFormatInfo.dateFormatStringLC}
|
|
92
96
|
format={dateFormatInfo.dateFormatString}
|
|
93
97
|
mask={dateFormatInfo.dateFormatMask}
|
|
@@ -97,7 +101,7 @@ export default function Date(props: DateProps) {
|
|
|
97
101
|
disabled={disabled}
|
|
98
102
|
error={status === 'error'}
|
|
99
103
|
helperText={helperTextToDisplay}
|
|
100
|
-
size=
|
|
104
|
+
size='small'
|
|
101
105
|
label={label}
|
|
102
106
|
value={value || null}
|
|
103
107
|
onChange={handleChange}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import { KeyboardDateTimePicker } from '@material-ui/pickers';
|
|
2
|
+
|
|
3
3
|
import handleEvent from '@pega/react-sdk-components/lib/components/helpers/event-utils';
|
|
4
4
|
import { format } from '@pega/react-sdk-components/lib/components/helpers/formatters';
|
|
5
5
|
import { dateFormatInfoDefault, getDateFormatInfo } from '@pega/react-sdk-components/lib/components/helpers/date-format-utils';
|
|
6
6
|
import { getComponentFromMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
|
|
7
|
-
import
|
|
7
|
+
import { PConnFieldProps } from '@pega/react-sdk-components/lib/types/PConnProps';
|
|
8
8
|
|
|
9
9
|
interface DateTimeProps extends PConnFieldProps {
|
|
10
10
|
// If any, enter additional props that only exist on DateTime here
|
|
@@ -33,7 +33,7 @@ export default function DateTime(props: DateTimeProps) {
|
|
|
33
33
|
|
|
34
34
|
const pConn = getPConnect();
|
|
35
35
|
const actions = pConn.getActionsApi();
|
|
36
|
-
const propName = pConn.getStateProps()
|
|
36
|
+
const propName = (pConn.getStateProps() as any).value;
|
|
37
37
|
const helperTextToDisplay = validatemessage || helperText;
|
|
38
38
|
|
|
39
39
|
// Start with default dateFormatInfo
|
|
@@ -55,7 +55,7 @@ export default function DateTime(props: DateTimeProps) {
|
|
|
55
55
|
const formattedDateTime = format(props.value, 'datetime', {
|
|
56
56
|
format: `${dateFormatInfo.dateFormatString} hh:mm a`
|
|
57
57
|
});
|
|
58
|
-
return <FieldValueList name={hideLabel ? '' : label} value={formattedDateTime} variant=
|
|
58
|
+
return <FieldValueList name={hideLabel ? '' : label} value={formattedDateTime} variant='stacked' />;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
if (readOnly) {
|
|
@@ -63,12 +63,12 @@ export default function DateTime(props: DateTimeProps) {
|
|
|
63
63
|
return <TextInput {...props} value={formattedDateTime} />;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
const handleChange =
|
|
66
|
+
const handleChange = date => {
|
|
67
67
|
const changeValue = date && date.isValid() ? date.toISOString() : null;
|
|
68
68
|
onChange({ value: changeValue });
|
|
69
69
|
};
|
|
70
70
|
|
|
71
|
-
const handleAccept =
|
|
71
|
+
const handleAccept = date => {
|
|
72
72
|
const changeValue = date && date.isValid() ? date.toISOString() : null;
|
|
73
73
|
handleEvent(actions, 'changeNblur', propName, changeValue);
|
|
74
74
|
};
|
|
@@ -80,8 +80,8 @@ export default function DateTime(props: DateTimeProps) {
|
|
|
80
80
|
|
|
81
81
|
return (
|
|
82
82
|
<KeyboardDateTimePicker
|
|
83
|
-
variant=
|
|
84
|
-
inputVariant=
|
|
83
|
+
variant='inline'
|
|
84
|
+
inputVariant='outlined'
|
|
85
85
|
fullWidth
|
|
86
86
|
autoOk
|
|
87
87
|
required={required}
|
|
@@ -92,7 +92,7 @@ export default function DateTime(props: DateTimeProps) {
|
|
|
92
92
|
minutesStep={5}
|
|
93
93
|
error={status === 'error'}
|
|
94
94
|
helperText={helperTextToDisplay}
|
|
95
|
-
size=
|
|
95
|
+
size='small'
|
|
96
96
|
label={label}
|
|
97
97
|
value={value || null}
|
|
98
98
|
onChange={handleChange}
|
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
import React, { useState, useEffect } from 'react';
|
|
2
1
|
import CurrencyTextField from '@unicef/material-ui-currency-textfield';
|
|
2
|
+
|
|
3
3
|
import { getCurrencyCharacters, getCurrencyOptions } from '@pega/react-sdk-components/lib/components/field/Currency/currency-utils';
|
|
4
4
|
import handleEvent from '@pega/react-sdk-components/lib/components/helpers/event-utils';
|
|
5
5
|
import { format } from '@pega/react-sdk-components/lib/components/helpers/formatters';
|
|
6
6
|
import { getComponentFromMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
|
|
7
|
-
import
|
|
7
|
+
import { PConnFieldProps } from '@pega/react-sdk-components/lib/types/PConnProps';
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
/* Using @unicef/material-ui-currency-textfield component here, since it allows formatting decimal values,
|
|
10
|
+
as per the locale.
|
|
11
|
+
*/
|
|
10
12
|
|
|
11
13
|
interface DecimalProps extends PConnFieldProps {
|
|
12
14
|
// If any, enter additional props that only exist on Decimal here
|
|
13
15
|
currencyISOCode?: string;
|
|
14
16
|
decimalPrecision?: number;
|
|
15
17
|
showGroupSeparators?: string;
|
|
18
|
+
formatter?: string;
|
|
16
19
|
}
|
|
17
20
|
|
|
18
21
|
export default function Decimal(props: DecimalProps) {
|
|
@@ -35,56 +38,42 @@ export default function Decimal(props: DecimalProps) {
|
|
|
35
38
|
currencyISOCode = 'USD',
|
|
36
39
|
decimalPrecision = 2,
|
|
37
40
|
showGroupSeparators = true,
|
|
38
|
-
testId
|
|
41
|
+
testId,
|
|
42
|
+
placeholder,
|
|
43
|
+
formatter
|
|
39
44
|
} = props;
|
|
40
45
|
|
|
41
46
|
const pConn = getPConnect();
|
|
42
47
|
const actions = pConn.getActionsApi();
|
|
43
|
-
const propName = pConn.getStateProps()
|
|
48
|
+
const propName = (pConn.getStateProps() as any).value;
|
|
44
49
|
const helperTextToDisplay = validatemessage || helperText;
|
|
45
50
|
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
-
const
|
|
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]);
|
|
51
|
+
const theSymbols = getCurrencyCharacters(currencyISOCode);
|
|
52
|
+
const theCurrDec = theSymbols.theDecimalIndicator;
|
|
53
|
+
const theCurrSep = theSymbols.theDigitGroupSeparator;
|
|
54
|
+
const theCurrSym = theSymbols.theCurrencySymbol;
|
|
59
55
|
|
|
60
56
|
const theCurrencyOptions = getCurrencyOptions(currencyISOCode);
|
|
61
|
-
|
|
57
|
+
|
|
58
|
+
let formattedValue = '';
|
|
59
|
+
if (formatter === 'Currency') {
|
|
60
|
+
formattedValue = format(value, formatter.toLowerCase(), theCurrencyOptions);
|
|
61
|
+
} else {
|
|
62
|
+
formattedValue = format(value, pConn.getComponentName().toLowerCase(), theCurrencyOptions);
|
|
63
|
+
}
|
|
62
64
|
|
|
63
65
|
if (displayMode === 'LABELS_LEFT') {
|
|
64
66
|
return <FieldValueList name={hideLabel ? '' : label} value={formattedValue} />;
|
|
65
67
|
}
|
|
66
68
|
|
|
67
69
|
if (displayMode === 'STACKED_LARGE_VAL') {
|
|
68
|
-
return <FieldValueList name={hideLabel ? '' : label} value={formattedValue} variant=
|
|
70
|
+
return <FieldValueList name={hideLabel ? '' : label} value={formattedValue} variant='stacked' />;
|
|
69
71
|
}
|
|
70
72
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
if (readOnly) {
|
|
74
|
-
readOnlyProp = { readOnly: true };
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
let testProp = {};
|
|
78
|
-
|
|
79
|
-
testProp = {
|
|
73
|
+
const testProp = {
|
|
80
74
|
'data-test-id': testId
|
|
81
75
|
};
|
|
82
76
|
|
|
83
|
-
function decimalOnChange(event) {
|
|
84
|
-
// update internal value
|
|
85
|
-
setDecimalvalue(event?.target?.value);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
77
|
function decimalOnBlur(event, inValue) {
|
|
89
78
|
handleEvent(actions, 'changeNblur', propName, inValue !== '' ? Number(inValue) : inValue);
|
|
90
79
|
}
|
|
@@ -94,23 +83,23 @@ export default function Decimal(props: DecimalProps) {
|
|
|
94
83
|
fullWidth
|
|
95
84
|
variant={readOnly ? 'standard' : 'outlined'}
|
|
96
85
|
helperText={helperTextToDisplay}
|
|
97
|
-
placeholder=
|
|
98
|
-
size=
|
|
86
|
+
placeholder={placeholder ?? ''}
|
|
87
|
+
size='small'
|
|
99
88
|
required={required}
|
|
100
89
|
disabled={disabled}
|
|
101
|
-
onChange={decimalOnChange}
|
|
102
|
-
onBlur={!readOnly ? decimalOnBlur : undefined}
|
|
103
90
|
error={status === 'error'}
|
|
104
91
|
label={label}
|
|
105
|
-
value={
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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 : ''}
|
|
111
99
|
decimalCharacter={theCurrDec}
|
|
112
100
|
digitGroupSeparator={showGroupSeparators ? theCurrSep : ''}
|
|
113
101
|
decimalPlaces={decimalPrecision}
|
|
102
|
+
onBlur={!readOnly ? decimalOnBlur : undefined}
|
|
114
103
|
/>
|
|
115
104
|
);
|
|
116
105
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default } from './Decimal';
|
|
1
|
+
export { default } from './Decimal';
|