Skip to content

Commit fbc5d5f

Browse files
author
manasa
committed
Merge branch 'master' of https://github.com/pegasystems/react-sdk-components into mod/tor/US-686138
2 parents 996fa4a + 5756597 commit fbc5d5f

File tree

31 files changed

+3431
-259
lines changed

31 files changed

+3431
-259
lines changed

package-lock.json

Lines changed: 3152 additions & 136 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pega/react-sdk-components",
3-
"version": "24.2.10",
3+
"version": "24.2.11",
44
"description": "React SDK packaging: bridge and components, overrides",
55
"main": "index.ts",
66
"scripts": {
@@ -75,7 +75,7 @@
7575
},
7676
"devDependencies": {
7777
"@pega/configs": "^0.7.1",
78-
"@pega/constellationjs": "~24.2.1",
78+
"@pega/constellationjs": "~24.2.2",
7979
"@pega/eslint-config": "^0.7.2",
8080
"@pega/pcore-pconnect-typedefs": "~3.2.2",
8181
"@pega/tsconfig": "^0.6.0",
@@ -115,7 +115,7 @@
115115
"shx": "^0.3.4",
116116
"style-loader": "^3.3.4",
117117
"stylelint": "^16.19.1",
118-
"tinymce": "^7.9.0",
118+
"tinymce": "^6.8.6",
119119
"ts-jest": "^29.3.4",
120120
"ts-loader": "^9.5.2",
121121
"typescript": "^4.9.5",

packages/react-sdk-components/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pega/react-sdk-components",
3-
"version": "24.2.10",
3+
"version": "24.2.11",
44
"description": "React SDK Infrastructure: bridge and components",
55
"_filesComment": "During packing, npm ignores everything NOT in the files list",
66
"files": [

packages/react-sdk-components/src/components/designSystemExtension/FieldValueList/FieldValueList.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export default function FieldValueList(props: FieldValueListProps) {
6363
const formattedValue = formatItemValue(value);
6464

6565
return (
66-
<Grid item xs={variant === 'stacked' ? 12 : 8} className={variant === 'stacked' ? classes.noPaddingTop : ''}>
66+
<Grid item xs={variant === 'stacked' || !name ? 12 : 8} className={variant === 'stacked' ? classes.noPaddingTop : ''}>
6767
{isHtml ? (
6868
// eslint-disable-next-line react/no-danger
6969
<div dangerouslySetInnerHTML={{ __html: formattedValue }} />
@@ -78,7 +78,7 @@ export default function FieldValueList(props: FieldValueListProps) {
7878

7979
return (
8080
<Grid container spacing={4} justifyContent='space-between'>
81-
{getGridItemLabel()}
81+
{name ? getGridItemLabel() : null}
8282
{getGridItemValue()}
8383
</Grid>
8484
);

packages/react-sdk-components/src/components/field/Currency/Currency.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ export default function Currency(props: CurrrencyProps) {
8888
return (
8989
<NumericFormat
9090
valueIsNumericString
91+
variant={readOnly ? 'standard' : 'outlined'}
9192
label={label}
9293
helperText={helperTextToDisplay}
9394
placeholder={placeholder ?? ''}

packages/react-sdk-components/src/components/field/Date/Date.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useState } from 'react';
1+
import { useEffect, useState } from 'react';
22
import { DatePicker } from '@mui/x-date-pickers/DatePicker';
33
import dayjs, { Dayjs } from 'dayjs';
44

@@ -39,6 +39,10 @@ export default function Date(props: DateProps) {
3939
dateFormatInfo.dateFormatStringLC = theDateFormat.dateFormatStringLC;
4040
dateFormatInfo.dateFormatMask = theDateFormat.dateFormatMask;
4141

42+
useEffect(() => {
43+
setDateValue(dayjs(value));
44+
}, [value]);
45+
4246
if (displayMode === 'DISPLAY_ONLY') {
4347
const formattedDate = format(props.value, 'date', {
4448
format: dateFormatInfo.dateFormatString

packages/react-sdk-components/src/components/field/DateTime/DateTime.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { useState } from 'react';
1+
import { useEffect, useState } from 'react';
22
import { DateTimePicker } from '@mui/x-date-pickers/DateTimePicker';
33
import dayjs, { Dayjs } from 'dayjs';
4-
4+
import DateFormatter from '../../helpers/formatters/Date';
55
import handleEvent from '../../helpers/event-utils';
66
import { format } from '../../helpers/formatters';
77
import { dateFormatInfoDefault, getDateFormatInfo } from '../../helpers/date-format-utils';
@@ -19,7 +19,10 @@ export default function DateTime(props: DateTimeProps) {
1919

2020
const { getPConnect, label, required, disabled, value = '', validatemessage, status, readOnly, testId, helperText, displayMode, hideLabel } = props;
2121

22-
const [dateValue, setDateValue] = useState<Dayjs | null>(value ? dayjs(value) : null);
22+
const environmentInfo = PCore.getEnvironmentInfo();
23+
const timezone = environmentInfo && environmentInfo.getTimeZone();
24+
25+
const [dateValue, setDateValue] = useState<Dayjs | null>(value ? dayjs(DateFormatter.convertToTimezone(value, { timezone })) : null);
2326

2427
const pConn = getPConnect();
2528
const actions = pConn.getActionsApi();
@@ -34,6 +37,10 @@ export default function DateTime(props: DateTimeProps) {
3437
dateFormatInfo.dateFormatStringLC = theDateFormat.dateFormatStringLC;
3538
dateFormatInfo.dateFormatMask = theDateFormat.dateFormatMask;
3639

40+
useEffect(() => {
41+
setDateValue(dayjs(DateFormatter.convertToTimezone(value, { timezone })));
42+
}, [value]);
43+
3744
if (displayMode === 'DISPLAY_ONLY') {
3845
const formattedDateTime = format(props.value, 'datetime', {
3946
format: `${dateFormatInfo.dateFormatString} hh:mm a`
@@ -60,8 +67,9 @@ export default function DateTime(props: DateTimeProps) {
6067
};
6168

6269
const handleChange = date => {
63-
setDateValue(date);
64-
const changeValue = date && date.isValid() ? date.toISOString() : null;
70+
const timeZoneDateTime = (dayjs as any).tz(date.format('YYYY-MM-DDTHH:mm:ss'), timezone);
71+
const changeValue = timeZoneDateTime && timeZoneDateTime.isValid() ? timeZoneDateTime.toISOString() : '';
72+
setDateValue(timeZoneDateTime);
6573
handleEvent(actions, 'changeNblur', propName, changeValue);
6674
};
6775

packages/react-sdk-components/src/components/field/Decimal/Decimal.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { NumericFormat } from 'react-number-format';
22
import { TextField } from '@mui/material';
3-
import { useState } from 'react';
3+
import { useEffect, useState } from 'react';
44
import { getCurrencyCharacters, getCurrencyOptions } from '../Currency/currency-utils';
55
import handleEvent from '../../helpers/event-utils';
66
import { format } from '../../helpers/formatters';
@@ -58,6 +58,10 @@ export default function Decimal(props: DecimalProps) {
5858

5959
const theCurrencyOptions = getCurrencyOptions(currencyISOCode);
6060

61+
useEffect(() => {
62+
setValues(value.toString());
63+
}, [value]);
64+
6165
let readOnlyProp = {}; // Note: empty if NOT ReadOnly
6266

6367
if (readOnly) {
@@ -109,6 +113,7 @@ export default function Decimal(props: DecimalProps) {
109113
}}
110114
onBlur={!readOnly ? decimalOnBlur : undefined}
111115
prefix={readOnly && formatter === 'Currency' ? theCurrSym : ''}
116+
suffix={readOnly && formatter === 'Percentage' ? '%' : ''}
112117
decimalSeparator={theCurrDec}
113118
thousandSeparator={showGroupSeparators ? theCurrSep : ''}
114119
decimalScale={readOnly && formatter === 'Currency' ? undefined : decimalPrecision}

packages/react-sdk-components/src/components/field/Dropdown/Dropdown.tsx

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ export default function Dropdown(props: DropdownProps) {
137137
}, [theDatasource]);
138138

139139
useEffect(() => {
140-
if (!displayMode && listType !== 'associated' && typeof datasource === 'string') {
140+
if (listType !== 'associated' && typeof datasource === 'string') {
141141
getDataPage(datasource, parameters, context).then((results: any) => {
142142
const optionsData: any[] = [];
143143
const displayColumn = getDisplayFieldsMetaData(columns);
@@ -165,23 +165,33 @@ export default function Dropdown(props: DropdownProps) {
165165

166166
let readOnlyProp = {};
167167

168-
if (displayMode === 'DISPLAY_ONLY') {
169-
return (
170-
<FieldValueList
171-
name={hideLabel ? '' : label}
172-
value={thePConn.getLocalizedValue(value, localePath, thePConn.getLocaleRuleNameFromKeys(localeClass, localeContext, localeName))}
173-
/>
174-
);
175-
}
168+
const displayFn = (displayM, val) => {
169+
if (displayM === 'DISPLAY_ONLY') {
170+
return (
171+
<FieldValueList
172+
name={hideLabel ? '' : label}
173+
// @ts-ignore - Property 'getLocaleRuleNameFromKeys' is private and only accessible within class 'C11nEnv'
174+
value={thePConn.getLocalizedValue(val, localePath, thePConn.getLocaleRuleNameFromKeys(localeClass, localeContext, localeName))}
175+
/>
176+
);
177+
}
178+
179+
if (displayM === 'STACKED_LARGE_VAL') {
180+
return (
181+
<FieldValueList
182+
name={hideLabel ? '' : label}
183+
// @ts-ignore - Property 'getLocaleRuleNameFromKeys' is private and only accessible within class 'C11nEnv'
184+
value={thePConn.getLocalizedValue(val, localePath, thePConn.getLocaleRuleNameFromKeys(localeClass, localeContext, localeName))}
185+
variant='stacked'
186+
/>
187+
);
188+
}
189+
190+
return null;
191+
};
176192

177-
if (displayMode === 'STACKED_LARGE_VAL') {
178-
return (
179-
<FieldValueList
180-
name={hideLabel ? '' : label}
181-
value={thePConn.getLocalizedValue(value, localePath, thePConn.getLocaleRuleNameFromKeys(localeClass, localeContext, localeName))}
182-
variant='stacked'
183-
/>
184-
);
193+
if (displayMode) {
194+
return displayFn(displayMode, options.find(option => option.key === value)?.value || value);
185195
}
186196

187197
if (readOnly) {

packages/react-sdk-components/src/components/field/Percentage/Percentage.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useState } from 'react';
1+
import { useEffect, useState } from 'react';
22
import { NumericFormat } from 'react-number-format';
33
import { TextField } from '@mui/material';
44
import { getComponentFromMap } from '../../../bridge/helpers/sdk_component_map';
@@ -52,6 +52,10 @@ export default function Percentage(props: PercentageProps) {
5252
const theCurrencyOptions = getCurrencyOptions(currencyISOCode);
5353
const formattedValue = format(value, pConn.getComponentName()?.toLowerCase(), theCurrencyOptions);
5454

55+
useEffect(() => {
56+
setValues(value.toString());
57+
}, [value]);
58+
5559
let readOnlyProp = {}; // Note: empty if NOT ReadOnly
5660

5761
if (readOnly) {

0 commit comments

Comments
 (0)