@pega/react-sdk-overrides 0.23.33 → 0.23.35

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.
@@ -1,5 +1,5 @@
1
1
  import { useState, useEffect } from 'react';
2
- import { Checkbox, FormControl, FormControlLabel, FormGroup, FormHelperText } from '@material-ui/core';
2
+ import { Checkbox, FormControl, FormControlLabel, FormGroup, FormHelperText, FormLabel } from '@material-ui/core';
3
3
 
4
4
  import handleEvent from '@pega/react-sdk-components/lib/components/helpers/event-utils';
5
5
  import { getComponentFromMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
@@ -20,6 +20,7 @@ export default function CheckboxComponent(props: CheckboxProps) {
20
20
 
21
21
  const {
22
22
  getPConnect,
23
+ label,
23
24
  value = false,
24
25
  readOnly,
25
26
  testId,
@@ -73,6 +74,7 @@ export default function CheckboxComponent(props: CheckboxProps) {
73
74
 
74
75
  return (
75
76
  <FormControl required={required} error={status === 'error'}>
77
+ {!hideLabel && <FormLabel component='legend'>{label}</FormLabel>}
76
78
  <FormGroup>
77
79
  <FormControlLabel
78
80
  control={theCheckbox}
@@ -1,14 +1,14 @@
1
- import { useState, useEffect } from 'react';
2
1
  import CurrencyTextField from '@unicef/material-ui-currency-textfield';
3
2
 
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
3
  import { getComponentFromMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
7
4
  import { PConnFieldProps } from '@pega/react-sdk-components/lib/types/PConnProps';
8
-
5
+ import handleEvent from '@pega/react-sdk-components/lib/components/helpers/event-utils';
6
+ import { format } from '@pega/react-sdk-components/lib/components/helpers/formatters';
9
7
  import { getCurrencyCharacters, getCurrencyOptions } from './currency-utils';
10
8
 
11
- // Using control from: https://github.com/unicef/material-ui-currency-textfield
9
+ /* Using @unicef/material-ui-currency-textfield component here, since it allows formatting decimal values,
10
+ as per the locale.
11
+ */
12
12
 
13
13
  interface CurrrencyProps extends PConnFieldProps {
14
14
  // If any, enter additional props that only exist on Currency here
@@ -48,17 +48,11 @@ export default function Currency(props: CurrrencyProps) {
48
48
  'data-test-id': testId
49
49
  };
50
50
 
51
- const [theCurrSym, setCurrSym] = useState('$');
52
- const [theCurrDec, setCurrDec] = useState('.');
53
- const [theCurrSep, setCurrSep] = useState(',');
54
-
55
- useEffect(() => {
56
- // currencySymbols looks like this: { theCurrencySymbol: '$', theDecimalIndicator: '.', theSeparator: ',' }
57
- const theSymbols = getCurrencyCharacters(currencyISOCode);
58
- setCurrSym(theSymbols.theCurrencySymbol);
59
- setCurrDec(theSymbols.theDecimalIndicator);
60
- setCurrSep(theSymbols.theDigitGroupSeparator);
61
- }, [currencyISOCode]);
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;
62
56
 
63
57
  const theCurrencyOptions = getCurrencyOptions(currencyISOCode);
64
58
  const formattedValue = format(value, pConn.getComponentName().toLowerCase(), theCurrencyOptions);
@@ -1,4 +1,3 @@
1
- import { useState, useEffect } from 'react';
2
1
  import CurrencyTextField from '@unicef/material-ui-currency-textfield';
3
2
 
4
3
  import { getCurrencyCharacters, getCurrencyOptions } from '@pega/react-sdk-components/lib/components/field/Currency/currency-utils';
@@ -7,7 +6,9 @@ import { format } from '@pega/react-sdk-components/lib/components/helpers/format
7
6
  import { getComponentFromMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
8
7
  import { PConnFieldProps } from '@pega/react-sdk-components/lib/types/PConnProps';
9
8
 
10
- // Using control from: https://github.com/unicef/material-ui-currency-textfield
9
+ /* Using @unicef/material-ui-currency-textfield component here, since it allows formatting decimal values,
10
+ as per the locale.
11
+ */
11
12
 
12
13
  interface DecimalProps extends PConnFieldProps {
13
14
  // If any, enter additional props that only exist on Decimal here
@@ -45,14 +46,9 @@ export default function Decimal(props: DecimalProps) {
45
46
  const propName = (pConn.getStateProps() as any).value;
46
47
  const helperTextToDisplay = validatemessage || helperText;
47
48
 
48
- const [theCurrDec, setCurrDec] = useState('.');
49
- const [theCurrSep, setCurrSep] = useState(',');
50
-
51
- useEffect(() => {
52
- const theSymbols = getCurrencyCharacters(currencyISOCode);
53
- setCurrDec(theSymbols.theDecimalIndicator);
54
- setCurrSep(theSymbols.theDigitGroupSeparator);
55
- }, [currencyISOCode]);
49
+ const theSymbols = getCurrencyCharacters(currencyISOCode);
50
+ const theCurrDec = theSymbols.theDecimalIndicator;
51
+ const theCurrSep = theSymbols.theDigitGroupSeparator;
56
52
 
57
53
  const theCurrencyOptions = getCurrencyOptions(currencyISOCode);
58
54
  const formattedValue = format(value, pConn.getComponentName().toLowerCase(), theCurrencyOptions);
@@ -29,6 +29,8 @@ export default function Group(props: GroupProps) {
29
29
  );
30
30
  }, [children, type, isReadOnly]);
31
31
 
32
+ if (!children) return null;
33
+
32
34
  return (
33
35
  <FieldGroup name={showHeading ? heading : undefined} collapsible={collapsible} instructions={instructions}>
34
36
  {content}
@@ -1,67 +1,58 @@
1
- import { TextField } from '@material-ui/core';
2
- import { makeStyles } from '@material-ui/core/styles';
1
+ import CurrencyTextField from '@unicef/material-ui-currency-textfield';
3
2
 
4
3
  import { getComponentFromMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
5
4
  import { PConnFieldProps } from '@pega/react-sdk-components/lib/types/PConnProps';
5
+ import { getCurrencyCharacters, getCurrencyOptions } from '@pega/react-sdk-components/lib/components/field/Currency/currency-utils';
6
+ import handleEvent from '@pega/react-sdk-components/lib/components/helpers/event-utils';
7
+ import { format } from '@pega/react-sdk-components/lib/components/helpers/formatters';
6
8
 
7
- // Inspired by https://stackoverflow.com/questions/50823182/material-ui-remove-up-down-arrow-dials-from-textview
8
- const useStyles = makeStyles((/* theme */) => ({
9
- input: {
10
- '& input[type=number]': {
11
- '-moz-appearance': 'textfield'
12
- },
13
- '& input[type=number]::-webkit-outer-spin-button': {
14
- '-webkit-appearance': 'none',
15
- margin: 0
16
- },
17
- '& input[type=number]::-webkit-inner-spin-button': {
18
- '-webkit-appearance': 'none',
19
- margin: 0
20
- }
21
- }
22
- }));
23
-
9
+ /* Using @unicef/material-ui-currency-textfield component here, since it allows formatting decimal values,
10
+ as per the locale.
11
+ */
24
12
  interface PercentageProps extends PConnFieldProps {
25
13
  // If any, enter additional props that only exist on Percentage here
14
+ currencyISOCode?: string;
26
15
  }
27
16
 
28
17
  export default function Percentage(props: PercentageProps) {
29
18
  // Get emitted components from map (so we can get any override that may exist)
30
- const TextInput = getComponentFromMap('TextInput');
31
19
  const FieldValueList = getComponentFromMap('FieldValueList');
32
20
 
33
- const classes = useStyles();
34
-
35
21
  const {
22
+ getPConnect,
36
23
  label,
37
24
  required,
38
25
  disabled,
39
26
  value = '',
40
27
  validatemessage,
41
28
  status,
42
- onChange,
43
- onBlur,
29
+ // onChange,
30
+ // onBlur,
44
31
  readOnly,
32
+ currencyISOCode = 'USD',
45
33
  testId,
46
34
  helperText,
47
35
  displayMode,
48
36
  hideLabel,
49
37
  placeholder
50
38
  } = props;
39
+
40
+ const pConn = getPConnect();
41
+ const actions = pConn.getActionsApi();
42
+ const propName = (pConn.getStateProps() as any).value;
51
43
  const helperTextToDisplay = validatemessage || helperText;
52
44
 
45
+ const theCurrencyOptions = getCurrencyOptions(currencyISOCode);
46
+ const formattedValue = format(value, pConn.getComponentName().toLowerCase(), theCurrencyOptions);
47
+
53
48
  // console.log(`Percentage: label: ${label} value: ${value}`);
54
49
 
55
50
  if (displayMode === 'LABELS_LEFT') {
56
- return <FieldValueList name={hideLabel ? '' : label} value={value} />;
51
+ return <FieldValueList name={hideLabel ? '' : label} value={formattedValue} />;
57
52
  }
58
53
 
59
54
  if (displayMode === 'STACKED_LARGE_VAL') {
60
- return <FieldValueList name={hideLabel ? '' : label} value={value} variant='stacked' />;
61
- }
62
-
63
- if (readOnly) {
64
- return <TextInput {...props} />;
55
+ return <FieldValueList name={hideLabel ? '' : label} value={formattedValue} variant='stacked' />;
65
56
  }
66
57
 
67
58
  let testProp = {};
@@ -70,9 +61,16 @@ export default function Percentage(props: PercentageProps) {
70
61
  'data-test-id': testId
71
62
  };
72
63
 
64
+ const theSymbols = getCurrencyCharacters(currencyISOCode);
65
+ const theCurrDec = theSymbols.theDecimalIndicator;
66
+ const theCurrSep = theSymbols.theDigitGroupSeparator;
67
+
68
+ function PercentageOnBlur(event, inValue) {
69
+ handleEvent(actions, 'changeNblur', propName, inValue !== '' ? Number(inValue) : inValue);
70
+ }
71
+
73
72
  return (
74
- <TextField
75
- className={classes.input}
73
+ <CurrencyTextField
76
74
  fullWidth
77
75
  variant={readOnly ? 'standard' : 'outlined'}
78
76
  helperText={helperTextToDisplay}
@@ -80,13 +78,20 @@ export default function Percentage(props: PercentageProps) {
80
78
  size='small'
81
79
  required={required}
82
80
  disabled={disabled}
83
- onChange={onChange}
84
- onBlur={!readOnly ? onBlur : undefined}
81
+ readOnly={!!readOnly}
85
82
  error={status === 'error'}
86
83
  label={label}
87
84
  value={value}
88
- type='number'
89
- inputProps={{ ...testProp }}
85
+ type='text'
86
+ outputFormat='number'
87
+ textAlign='left'
88
+ InputProps={{
89
+ inputProps: { ...testProp }
90
+ }}
91
+ currencySymbol=''
92
+ decimalCharacter={theCurrDec}
93
+ digitGroupSeparator={theCurrSep}
94
+ onBlur={!readOnly ? PercentageOnBlur : undefined}
90
95
  />
91
96
  );
92
97
  }
@@ -80,6 +80,13 @@ export function format(value, type, options = {}): string {
80
80
  break;
81
81
  }
82
82
 
83
+ case 'percentage': {
84
+ const defaultOptions = { locale: getLocale(), decPlaces: 2 };
85
+ const params = { ...defaultOptions, ...options };
86
+ formattedValue = Currency.Percentage(value, params);
87
+ break;
88
+ }
89
+
83
90
  case 'integer': {
84
91
  const defaultOptions = { locale: getLocale() };
85
92
  const params = { ...defaultOptions, ...options };
@@ -304,11 +304,11 @@ export const FlowContainer = (props: FlowContainerProps) => {
304
304
  {!bShowConfirm &&
305
305
  (!todo_showTodo ? (
306
306
  !displayOnlyFA ? (
307
- <Card className={classes.root}>
307
+ <Card className={`${classes.root} psdk-root`}>
308
308
  <CardHeader
309
309
  title={<Typography variant='h6'>{containerName}</Typography>}
310
310
  subheader={`Task in ${caseId} \u2022 Priority ${urgency}`}
311
- avatar={<Avatar className={classes.avatar}>{operatorInitials}</Avatar>}
311
+ avatar={<Avatar className={`${classes.avatar} psdk-avatar`}>{operatorInitials}</Avatar>}
312
312
  />
313
313
  {displayPageMessages()}
314
314
  <MuiPickersUtilsProvider utils={DayjsUtils}>
@@ -318,7 +318,7 @@ export const FlowContainer = (props: FlowContainerProps) => {
318
318
  </MuiPickersUtilsProvider>
319
319
  </Card>
320
320
  ) : (
321
- <Card className={classes.root}>
321
+ <Card className={`${classes.root} psdk-root`}>
322
322
  <Typography variant='h6'>{containerName}</Typography>
323
323
  {displayPageMessages()}
324
324
  <MuiPickersUtilsProvider utils={DayjsUtils}>
@@ -345,7 +345,7 @@ export const FlowContainer = (props: FlowContainerProps) => {
345
345
  </div>
346
346
  ))}
347
347
  {bHasCaseMessages && (
348
- <div className={classes.alert}>
348
+ <div className={`${classes.alert} psdk-alert`}>
349
349
  <Alert severity='success'>{caseMessages}</Alert>
350
350
  </div>
351
351
  )}
@@ -310,10 +310,10 @@ export default function ModalViewContainer(props: ModalViewContainerProps) {
310
310
  return (
311
311
  <>
312
312
  <Dialog open={bShowModal} aria-labelledby='form-dialog-title'>
313
- <DialogTitle id='form-dialog-title' className={classes.dlgTitle}>
313
+ <DialogTitle id='form-dialog-title' className={`${classes.dlgTitle} psdk-dialog-title`}>
314
314
  {title}
315
315
  </DialogTitle>
316
- <DialogContent className={classes.dlgContent}>
316
+ <DialogContent className={`${classes.dlgContent} psdk-dialog-content`}>
317
317
  {bShowModal ? (
318
318
  <MuiPickersUtilsProvider utils={DayjsUtils}>
319
319
  <Assignment
@@ -154,7 +154,8 @@ export default function ListView(props: ListViewProps) {
154
154
  paper: {
155
155
  width: '100%',
156
156
  marginTop: theme.spacing(2),
157
- marginBottom: theme.spacing(2)
157
+ marginBottom: theme.spacing(2),
158
+ display: 'grid'
158
159
  },
159
160
  search: {
160
161
  padding: '5px 5px'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/react-sdk-overrides",
3
- "version": "0.23.33",
3
+ "version": "0.23.35",
4
4
  "description": "React SDK - Code for overriding components",
5
5
  "_filesComment": "During packing, npm ignores everything NOT in the files list",
6
6
  "files": [