@pega/dx-component-builder-sdk 0.23.17 → 0.23.19

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 (35) hide show
  1. package/README.md +4 -4
  2. package/package.json +1 -1
  3. package/src/tasks/create/templates/SDK-React/field/Boolean/index.tsx.mustache +3 -2
  4. package/src/tasks/create/templates/SDK-React/field/Decimal/index.tsx.mustache +3 -9
  5. package/src/tasks/create/templates/SDK-React/field/Decimal-Currency/index.tsx.mustache +7 -15
  6. package/src/tasks/create/templates/SDK-React/field/Decimal-Percentage/demo.stories.tsx.mustache +20 -0
  7. package/src/tasks/create/templates/SDK-React/field/Decimal-Percentage/index.tsx.mustache +38 -37
  8. package/src/tasks/create/templates/SDK-React/widget/CASE/index.tsx.mustache +3 -3
  9. package/src/tasks/create/templates/SDK-React/widget/PAGE-CASE/demo.stories.tsx.mustache +7 -0
  10. package/src/tasks/map/map.js +29 -8
  11. package/tests/assets/sdk-r/components/create/override-sdk/field/Checkbox/Checkbox.tsx +3 -1
  12. package/tests/assets/sdk-r/components/create/override-sdk/field/Currency/Currency.tsx +10 -16
  13. package/tests/assets/sdk-r/components/create/override-sdk/field/Decimal/Decimal.tsx +6 -10
  14. package/tests/assets/sdk-r/components/create/override-sdk/field/Group/Group.tsx +2 -0
  15. package/tests/assets/sdk-r/components/create/override-sdk/field/Percentage/Percentage.tsx +41 -36
  16. package/tests/assets/sdk-r/components/create/override-sdk/template/ListView/ListView.tsx +2 -1
  17. package/tests/assets/sdk-r/components/create/override-sdk/template/ListView/utils.ts +3 -1
  18. package/tests/assets/sdk-r/components/create/override-sdk/template/SimpleTableManual/SimpleTableManual.tsx +19 -1
  19. package/tests/assets/sdk-r/components/create/override-sdk/widget/QuickCreate/QuickCreate.tsx +52 -25
  20. package/tests/assets/sdk-r/components/createAll/custom-sdk/field/Pega_DXIL_MyBoolean/index.tsx +3 -2
  21. package/tests/assets/sdk-r/components/createAll/custom-sdk/field/Pega_DXIL_MyCurrency/index.tsx +7 -15
  22. package/tests/assets/sdk-r/components/createAll/custom-sdk/field/Pega_DXIL_MyDecimal/index.tsx +3 -9
  23. package/tests/assets/sdk-r/components/createAll/custom-sdk/field/Pega_DXIL_MyPercentage/demo.stories.tsx +20 -0
  24. package/tests/assets/sdk-r/components/createAll/custom-sdk/field/Pega_DXIL_MyPercentage/index.tsx +38 -37
  25. package/tests/assets/sdk-r/components/createAll/custom-sdk/widget/Pega_DXIL_MyCaseWidget/index.tsx +3 -3
  26. package/tests/assets/sdk-r/components/createAll/custom-sdk/widget/Pega_DXIL_MyPageCaseWidget/demo.stories.tsx +7 -0
  27. package/tests/assets/sdk-r/components/createAll/override-sdk/field/Checkbox/Checkbox.tsx +3 -1
  28. package/tests/assets/sdk-r/components/createAll/override-sdk/field/Currency/Currency.tsx +10 -16
  29. package/tests/assets/sdk-r/components/createAll/override-sdk/field/Decimal/Decimal.tsx +6 -10
  30. package/tests/assets/sdk-r/components/createAll/override-sdk/field/Group/Group.tsx +2 -0
  31. package/tests/assets/sdk-r/components/createAll/override-sdk/field/Percentage/Percentage.tsx +41 -36
  32. package/tests/assets/sdk-r/components/createAll/override-sdk/template/ListView/ListView.tsx +2 -1
  33. package/tests/assets/sdk-r/components/createAll/override-sdk/template/ListView/utils.ts +3 -1
  34. package/tests/assets/sdk-r/components/createAll/override-sdk/template/SimpleTableManual/SimpleTableManual.tsx +19 -1
  35. package/tests/assets/sdk-r/components/createAll/override-sdk/widget/QuickCreate/QuickCreate.tsx +52 -25
@@ -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
  }
@@ -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'
@@ -680,7 +680,9 @@ export const readContextResponse = async (context, params) => {
680
680
  if (compositeKeys.length) {
681
681
  otherContext.setCompositeKeys(compositeKeys);
682
682
  }
683
- otherContext.fetchRowActionDetails = null;
683
+ if (otherContext) {
684
+ otherContext.fetchRowActionDetails = null;
685
+ }
684
686
  }
685
687
 
686
688
  const presetArray = [];
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable no-nested-ternary */
2
- import React, { PropsWithChildren, useEffect, useRef, useState } from 'react';
2
+ import React, { PropsWithChildren, useEffect, useLayoutEffect, useRef, useState } from 'react';
3
3
  import Table from '@material-ui/core/Table';
4
4
  import TableBody from '@material-ui/core/TableBody';
5
5
  import TableCell from '@material-ui/core/TableCell';
@@ -197,6 +197,20 @@ export default function SimpleTableManual(props: PropsWithChildren<SimpleTableMa
197
197
  // Constellation DX Components.
198
198
  const fieldDefs = buildFieldsForTable(rawFields, resolvedFields, showDeleteButton);
199
199
 
200
+ useLayoutEffect(() => {
201
+ if (allowEditingInModal) {
202
+ getPConnect()
203
+ .getListActions()
204
+ .initDefaultPageInstructions(
205
+ getPConnect().getReferenceList(),
206
+ fieldDefs.filter(item => item.name).map(item => item.name)
207
+ );
208
+ } else {
209
+ // @ts-ignore - An argument for 'fields' was not provided
210
+ getPConnect().getListActions().initDefaultPageInstructions(getPConnect().getReferenceList());
211
+ }
212
+ }, []);
213
+
200
214
  const displayedColumns = fieldDefs.map(field => {
201
215
  return field.name ? field.name : field.cellRenderer;
202
216
  });
@@ -290,6 +304,10 @@ export default function SimpleTableManual(props: PropsWithChildren<SimpleTableMa
290
304
  } else {
291
305
  pConn.getListActions().insert({ classID: contextClass }, referenceList.length);
292
306
  }
307
+
308
+ getPConnect().clearErrorMessages({
309
+ property: (getPConnect().getStateProps() as any)?.referenceList?.substring(1)
310
+ } as any);
293
311
  };
294
312
 
295
313
  const editRecord = () => {
@@ -1,3 +1,4 @@
1
+ import { useEffect, useState } from 'react';
1
2
  import { Utils } from '@pega/react-sdk-components/lib/components/helpers/utils';
2
3
  import { getComponentFromMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
3
4
  import { PConnProps } from '@pega/react-sdk-components/lib/types/PConnProps';
@@ -25,38 +26,64 @@ export default function QuickCreate(props: QuickCreateProps) {
25
26
  });
26
27
  };
27
28
 
28
- const cases: any = [];
29
- const envInfo = PCore.getEnvironmentInfo();
30
- if (
31
- classFilter &&
32
- envInfo.environmentInfoObject &&
33
- envInfo.environmentInfoObject.pyCaseTypeList &&
34
- envInfo.environmentInfoObject.pyCaseTypeList.length > 0
35
- ) {
36
- classFilter.forEach(item => {
37
- let icon = Utils.getImageSrc('polaris-solid', Utils.getSDKStaticConentUrl());
38
- let label = '';
29
+ const [quickCreatecases, setCases] = useState([]);
30
+
31
+ /* If the classFilter is empty and has no entries - we will default to the default set of case types
32
+ It will usually come from the envInfo but for Launchpad, this is not populated - instead get the list of cases from the store */
33
+ useEffect(() => {
34
+ const cases: any = [];
35
+ const defaultCases: any = [];
36
+ const envInfo = PCore.getEnvironmentInfo();
37
+ if (envInfo?.environmentInfoObject?.pyCaseTypeList) {
39
38
  envInfo.environmentInfoObject.pyCaseTypeList.forEach(casetype => {
40
- if (casetype.pyWorkTypeImplementationClassName === item) {
41
- icon = casetype.pxIcon && Utils.getImageSrc(casetype?.pxIcon, Utils.getSDKStaticConentUrl());
42
- label = casetype.pyWorkTypeName ?? '';
39
+ if (casetype.pyWorkTypeName && casetype.pyWorkTypeImplementationClassName) {
40
+ defaultCases.push({
41
+ classname: casetype.pyWorkTypeImplementationClassName,
42
+ onClick: () => {
43
+ createCase(casetype.pyWorkTypeImplementationClassName);
44
+ },
45
+ ...(showCaseIcons && { icon: Utils.getImageSrc(casetype?.pxIcon, Utils.getSDKStaticConentUrl()) }),
46
+ label: casetype.pyWorkTypeName
47
+ });
48
+ }
49
+ });
50
+ } else {
51
+ const pConnectInAppContext = PCore.createPConnect({
52
+ options: { context: PCore.getConstants().APP.APP }
53
+ }).getPConnect();
54
+ const pyPortalInAppContext = pConnectInAppContext.getValue('pyPortal') as any;
55
+ pyPortalInAppContext?.pyCaseTypesAvailableToCreate?.forEach(casetype => {
56
+ if (casetype.pyClassName && casetype.pyLabel) {
57
+ defaultCases.push({
58
+ classname: casetype.pyClassName,
59
+ onClick: () => {
60
+ createCase(casetype.pyClassName);
61
+ },
62
+ ...(showCaseIcons && { icon: Utils.getImageSrc(casetype?.pxIcon, Utils.getSDKStaticConentUrl()) }),
63
+ label: casetype.pyLabel
64
+ });
43
65
  }
44
66
  });
45
- if (label !== '') {
46
- cases.push({
47
- label,
48
- onClick: () => {
49
- createCase(item);
50
- },
51
- ...(showCaseIcons && { icon })
67
+ }
68
+
69
+ /* If classFilter is not empty - filter from the list of defaultCases */
70
+ if (classFilter?.length > 0) {
71
+ classFilter.forEach(item => {
72
+ defaultCases.forEach(casetype => {
73
+ if (casetype.classname === item) {
74
+ cases.push(casetype);
75
+ }
52
76
  });
53
- }
54
- });
55
- }
77
+ });
78
+ setCases(cases);
79
+ } else {
80
+ setCases(defaultCases);
81
+ }
82
+ }, []);
56
83
 
57
84
  return (
58
85
  <div>
59
- <WssQuickCreate heading={heading} actions={cases} />
86
+ <WssQuickCreate heading={heading} actions={quickCreatecases} />
60
87
  </div>
61
88
  );
62
89
  }