@pega/react-sdk-overrides 0.23.33 → 0.23.34

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,11 +1,9 @@
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
9
  // Using control from: https://github.com/unicef/material-ui-currency-textfield
@@ -48,17 +46,11 @@ export default function Currency(props: CurrrencyProps) {
48
46
  'data-test-id': testId
49
47
  };
50
48
 
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]);
49
+ // currencySymbols looks like this: { theCurrencySymbol: '$', theDecimalIndicator: '.', theSeparator: ',' }
50
+ const theSymbols = getCurrencyCharacters(currencyISOCode);
51
+ const theCurrSym = theSymbols.theCurrencySymbol;
52
+ const theCurrDec = theSymbols.theDecimalIndicator;
53
+ const theCurrSep = theSymbols.theDigitGroupSeparator;
62
54
 
63
55
  const theCurrencyOptions = getCurrencyOptions(currencyISOCode);
64
56
  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';
@@ -45,14 +44,9 @@ export default function Decimal(props: DecimalProps) {
45
44
  const propName = (pConn.getStateProps() as any).value;
46
45
  const helperTextToDisplay = validatemessage || helperText;
47
46
 
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]);
47
+ const theSymbols = getCurrencyCharacters(currencyISOCode);
48
+ const theCurrDec = theSymbols.theDecimalIndicator;
49
+ const theCurrSep = theSymbols.theDigitGroupSeparator;
56
50
 
57
51
  const theCurrencyOptions = getCurrencyOptions(currencyISOCode);
58
52
  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,55 @@
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';
6
-
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
- }));
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';
23
8
 
24
9
  interface PercentageProps extends PConnFieldProps {
25
10
  // If any, enter additional props that only exist on Percentage here
11
+ currencyISOCode?: string;
26
12
  }
27
13
 
28
14
  export default function Percentage(props: PercentageProps) {
29
15
  // Get emitted components from map (so we can get any override that may exist)
30
- const TextInput = getComponentFromMap('TextInput');
31
16
  const FieldValueList = getComponentFromMap('FieldValueList');
32
17
 
33
- const classes = useStyles();
34
-
35
18
  const {
19
+ getPConnect,
36
20
  label,
37
21
  required,
38
22
  disabled,
39
23
  value = '',
40
24
  validatemessage,
41
25
  status,
42
- onChange,
43
- onBlur,
26
+ // onChange,
27
+ // onBlur,
44
28
  readOnly,
29
+ currencyISOCode = 'USD',
45
30
  testId,
46
31
  helperText,
47
32
  displayMode,
48
33
  hideLabel,
49
34
  placeholder
50
35
  } = props;
36
+
37
+ const pConn = getPConnect();
38
+ const actions = pConn.getActionsApi();
39
+ const propName = (pConn.getStateProps() as any).value;
51
40
  const helperTextToDisplay = validatemessage || helperText;
52
41
 
42
+ const theCurrencyOptions = getCurrencyOptions(currencyISOCode);
43
+ const formattedValue = format(value, pConn.getComponentName().toLowerCase(), theCurrencyOptions);
44
+
53
45
  // console.log(`Percentage: label: ${label} value: ${value}`);
54
46
 
55
47
  if (displayMode === 'LABELS_LEFT') {
56
- return <FieldValueList name={hideLabel ? '' : label} value={value} />;
48
+ return <FieldValueList name={hideLabel ? '' : label} value={formattedValue} />;
57
49
  }
58
50
 
59
51
  if (displayMode === 'STACKED_LARGE_VAL') {
60
- return <FieldValueList name={hideLabel ? '' : label} value={value} variant='stacked' />;
61
- }
62
-
63
- if (readOnly) {
64
- return <TextInput {...props} />;
52
+ return <FieldValueList name={hideLabel ? '' : label} value={formattedValue} variant='stacked' />;
65
53
  }
66
54
 
67
55
  let testProp = {};
@@ -70,9 +58,16 @@ export default function Percentage(props: PercentageProps) {
70
58
  'data-test-id': testId
71
59
  };
72
60
 
61
+ const theSymbols = getCurrencyCharacters(currencyISOCode);
62
+ const theCurrDec = theSymbols.theDecimalIndicator;
63
+ const theCurrSep = theSymbols.theDigitGroupSeparator;
64
+
65
+ function PercentageOnBlur(event, inValue) {
66
+ handleEvent(actions, 'changeNblur', propName, inValue !== '' ? Number(inValue) : inValue);
67
+ }
68
+
73
69
  return (
74
- <TextField
75
- className={classes.input}
70
+ <CurrencyTextField
76
71
  fullWidth
77
72
  variant={readOnly ? 'standard' : 'outlined'}
78
73
  helperText={helperTextToDisplay}
@@ -80,13 +75,20 @@ export default function Percentage(props: PercentageProps) {
80
75
  size='small'
81
76
  required={required}
82
77
  disabled={disabled}
83
- onChange={onChange}
84
- onBlur={!readOnly ? onBlur : undefined}
78
+ readOnly={!!readOnly}
85
79
  error={status === 'error'}
86
80
  label={label}
87
81
  value={value}
88
- type='number'
89
- inputProps={{ ...testProp }}
82
+ type='text'
83
+ outputFormat='number'
84
+ textAlign='left'
85
+ InputProps={{
86
+ inputProps: { ...testProp }
87
+ }}
88
+ currencySymbol=''
89
+ decimalCharacter={theCurrDec}
90
+ digitGroupSeparator={theCurrSep}
91
+ onBlur={!readOnly ? PercentageOnBlur : undefined}
90
92
  />
91
93
  );
92
94
  }
@@ -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
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.34",
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": [