@pega/react-sdk-overrides 0.23.26 → 8.8.20

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 (139) hide show
  1. package/lib/designSystemExtension/AlertBanner/AlertBanner.tsx +47 -0
  2. package/lib/designSystemExtension/AlertBanner/index.tsx +1 -0
  3. package/lib/designSystemExtension/Banner/Banner.tsx +12 -1
  4. package/lib/designSystemExtension/CaseSummaryFields/CaseSummaryFields.tsx +15 -10
  5. package/lib/designSystemExtension/DetailsFields/DetailsFields.tsx +10 -11
  6. package/lib/designSystemExtension/FieldGroup/FieldGroup.tsx +10 -3
  7. package/lib/designSystemExtension/FieldGroupList/FieldGroupList.tsx +11 -5
  8. package/lib/designSystemExtension/FieldValueList/FieldValueList.tsx +11 -3
  9. package/lib/designSystemExtension/Operator/Operator.tsx +30 -21
  10. package/lib/designSystemExtension/Pulse/Pulse.tsx +11 -7
  11. package/lib/designSystemExtension/RichTextEditor/RichTextEditor.tsx +121 -0
  12. package/lib/designSystemExtension/RichTextEditor/index.tsx +1 -0
  13. package/lib/designSystemExtension/WssQuickCreate/WssQuickCreate.tsx +12 -3
  14. package/lib/field/AutoComplete/AutoComplete.tsx +37 -18
  15. package/lib/field/CancelAlert/CancelAlert.tsx +21 -12
  16. package/lib/field/Checkbox/Checkbox.tsx +41 -17
  17. package/lib/field/Currency/Currency.tsx +23 -15
  18. package/lib/field/Currency/currency-utils.ts +1 -2
  19. package/lib/field/Date/Date.tsx +31 -17
  20. package/lib/field/DateTime/DateTime.tsx +26 -15
  21. package/lib/field/Decimal/Decimal.tsx +82 -19
  22. package/lib/field/Dropdown/Dropdown.tsx +57 -14
  23. package/lib/field/Email/Email.tsx +17 -9
  24. package/lib/field/Integer/Integer.tsx +15 -7
  25. package/lib/field/Percentage/Percentage.tsx +15 -7
  26. package/lib/field/Phone/Phone.tsx +21 -12
  27. package/lib/field/RadioButtons/RadioButtons.tsx +54 -27
  28. package/lib/field/RichText/RichText.tsx +93 -0
  29. package/lib/field/RichText/index.tsx +1 -0
  30. package/lib/field/ScalarList/ScalarList.tsx +64 -0
  31. package/lib/field/ScalarList/config-ext.json +8 -0
  32. package/lib/field/ScalarList/index.tsx +1 -0
  33. package/lib/field/SemanticLink/SemanticLink.tsx +26 -25
  34. package/lib/field/SemanticLink/utils.ts +2 -1
  35. package/lib/field/TextArea/TextArea.tsx +14 -5
  36. package/lib/field/TextContent/TextContent.tsx +10 -1
  37. package/lib/field/TextInput/TextInput.tsx +40 -11
  38. package/lib/field/Time/Time.tsx +29 -26
  39. package/lib/field/URL/URL.tsx +24 -8
  40. package/lib/field/UserReference/UserReference.tsx +52 -60
  41. package/lib/helpers/{attachmentHelpers.js → attachmentHelpers.ts} +5 -5
  42. package/lib/helpers/auth.js +741 -390
  43. package/lib/helpers/authManager.ts +933 -0
  44. package/lib/helpers/case-utils.tsx +103 -0
  45. package/lib/helpers/common-utils.ts +4 -0
  46. package/lib/helpers/config_access.js +63 -145
  47. package/lib/helpers/data_page.ts +2 -1
  48. package/lib/helpers/date-format-utils.ts +29 -19
  49. package/lib/helpers/{event-utils.js → event-utils.ts} +1 -1
  50. package/lib/helpers/{field-group-utils.js → field-group-utils.ts} +4 -3
  51. package/lib/helpers/formatters/{Currency.js → Currency.ts} +13 -12
  52. package/lib/helpers/formatters/{CurrencyMap.js → CurrencyMap.ts} +8 -5
  53. package/lib/helpers/formatters/{Date.js → Date.ts} +2 -2
  54. package/lib/helpers/formatters/{common.js → common.ts} +4 -4
  55. package/lib/helpers/formatters/{index.js → index.ts} +3 -3
  56. package/lib/helpers/simpleTableHelpers.ts +10 -6
  57. package/lib/helpers/state-utils.tsx +47 -0
  58. package/lib/helpers/template-utils.ts +3 -4
  59. package/lib/helpers/utils.ts +12 -4
  60. package/lib/helpers/versionHelpers.ts +0 -1
  61. package/lib/infra/ActionButtons/ActionButtons.tsx +13 -18
  62. package/lib/infra/Assignment/Assignment.tsx +38 -32
  63. package/lib/infra/AssignmentCard/AssignmentCard.tsx +15 -19
  64. package/lib/infra/Containers/FlowContainer/FlowContainer.tsx +76 -64
  65. package/lib/infra/Containers/FlowContainer/{helpers.js → helpers.ts} +18 -16
  66. package/lib/infra/Containers/ModalViewContainer/ModalViewContainer.tsx +41 -27
  67. package/lib/infra/Containers/ViewContainer/ViewContainer.tsx +19 -28
  68. package/lib/infra/DashboardFilter/DashboardFilter.tsx +16 -20
  69. package/lib/infra/DashboardFilter/filterUtils.tsx +3 -1
  70. package/lib/infra/DeferLoad/DeferLoad.tsx +16 -19
  71. package/lib/infra/ErrorBoundary/ErrorBoundary.tsx +20 -19
  72. package/lib/infra/MultiStep/MultiStep.tsx +24 -24
  73. package/lib/infra/NavBar/NavBar.tsx +23 -24
  74. package/lib/infra/Reference/Reference.tsx +13 -18
  75. package/lib/infra/Region/Region.tsx +8 -6
  76. package/lib/infra/RootContainer/RootContainer.tsx +32 -39
  77. package/lib/infra/Stages/Stages.tsx +15 -9
  78. package/lib/infra/VerticalTabs/LeftAlignVerticalTabs/LeftAlignVerticalTabs.tsx +8 -1
  79. package/lib/infra/VerticalTabs/VerticalTabs/VerticalTabs.tsx +12 -12
  80. package/lib/infra/View/View.tsx +28 -56
  81. package/lib/template/AppShell/AppShell.tsx +51 -34
  82. package/lib/template/BannerPage/BannerPage.tsx +26 -31
  83. package/lib/template/CaseSummary/CaseSummary.tsx +15 -8
  84. package/lib/template/CaseView/CaseView.tsx +137 -100
  85. package/lib/template/CaseViewActionsMenu/CaseViewActionsMenu.tsx +27 -27
  86. package/lib/template/Confirmation/Confirmation.tsx +29 -52
  87. package/lib/template/DataReference/DataReference.tsx +50 -52
  88. package/lib/template/DefaultForm/DefaultForm.tsx +29 -20
  89. package/lib/template/DefaultForm/utils/index.ts +33 -0
  90. package/lib/template/Details/Details/Details.tsx +16 -17
  91. package/lib/template/Details/DetailsSubTabs/DetailsSubTabs.tsx +13 -16
  92. package/lib/template/Details/DetailsThreeColumn/DetailsThreeColumn.tsx +19 -18
  93. package/lib/template/Details/DetailsTwoColumn/DetailsTwoColumn.tsx +20 -18
  94. package/lib/template/FieldGroupTemplate/FieldGroupTemplate.tsx +24 -27
  95. package/lib/template/InlineDashboard/InlineDashboard.tsx +11 -7
  96. package/lib/template/InlineDashboardPage/InlineDashboardPage.tsx +19 -17
  97. package/lib/template/ListPage/ListPage.tsx +14 -13
  98. package/lib/template/ListView/ListView.tsx +140 -152
  99. package/lib/template/ListView/{hooks.js → hooks.ts} +3 -1
  100. package/lib/template/ListView/{utils.js → utils.ts} +172 -23
  101. package/lib/template/MultiReferenceReadOnly/MultiReferenceReadOnly.tsx +12 -17
  102. package/lib/template/NarrowWide/NarrowWide/NarrowWide.tsx +16 -1
  103. package/lib/template/NarrowWide/NarrowWideDetails/NarrowWideDetails.tsx +19 -18
  104. package/lib/template/NarrowWide/NarrowWideForm/NarrowWideForm.tsx +9 -1
  105. package/lib/template/NarrowWide/NarrowWidePage/NarrowWidePage.tsx +17 -17
  106. package/lib/template/OneColumn/OneColumn/OneColumn.tsx +8 -7
  107. package/lib/template/OneColumn/OneColumnPage/OneColumnPage.tsx +10 -10
  108. package/lib/template/OneColumn/OneColumnTab/OneColumnTab.tsx +5 -7
  109. package/lib/template/PromotedFilters/PromotedFilters.tsx +23 -17
  110. package/lib/template/SimpleTable/SimpleTable/SimpleTable.tsx +103 -6
  111. package/lib/template/SimpleTable/SimpleTableManual/SimpleTableManual.tsx +28 -7
  112. package/lib/template/SimpleTable/SimpleTableSelect/SimpleTableSelect.tsx +26 -31
  113. package/lib/template/SingleReferenceReadOnly/SingleReferenceReadOnly.tsx +34 -36
  114. package/lib/template/SubTabs/SubTabs.tsx +10 -11
  115. package/lib/template/SubTabs/tabUtils.ts +0 -2
  116. package/lib/template/TwoColumn/TwoColumn/TwoColumn.tsx +10 -15
  117. package/lib/template/TwoColumn/TwoColumnPage/TwoColumnPage.tsx +10 -10
  118. package/lib/template/TwoColumn/TwoColumnTab/TwoColumnTab.tsx +10 -12
  119. package/lib/template/WideNarrow/WideNarrow/WideNarrow.tsx +17 -3
  120. package/lib/template/WideNarrow/WideNarrowDetails/WideNarrowDetails.tsx +35 -25
  121. package/lib/template/WideNarrow/WideNarrowForm/WideNarrowForm.tsx +7 -1
  122. package/lib/template/WideNarrow/WideNarrowPage/WideNarrowPage.tsx +15 -17
  123. package/lib/template/WssNavBar/WssNavBar.tsx +20 -3
  124. package/lib/widget/AppAnnouncement/AppAnnouncement.tsx +13 -21
  125. package/lib/widget/Attachment/Attachment.css +15 -3
  126. package/lib/widget/Attachment/Attachment.tsx +51 -32
  127. package/lib/widget/CaseHistory/CaseHistory.tsx +13 -11
  128. package/lib/widget/FileUtility/ActionButtonsForFileUtil/ActionButtonsForFileUtil.tsx +13 -1
  129. package/lib/widget/FileUtility/FileUtility/FileUtility.tsx +40 -26
  130. package/lib/widget/Followers/Followers.tsx +10 -11
  131. package/lib/widget/QuickCreate/QuickCreate.tsx +15 -6
  132. package/lib/widget/SummaryItem/SummaryItem.tsx +12 -4
  133. package/lib/widget/SummaryList/SummaryList.tsx +17 -3
  134. package/lib/widget/ToDo/ToDo.tsx +69 -104
  135. package/package.json +1 -1
  136. package/lib/helpers/authManager.js +0 -631
  137. /package/lib/helpers/formatters/{Boolean.js → Boolean.ts} +0 -0
  138. /package/lib/helpers/{reactContextHelpers.js → reactContextHelpers.ts} +0 -0
  139. /package/lib/template/ListView/{DefaultViewMeta.js → DefaultViewMeta.ts} +0 -0
@@ -0,0 +1,93 @@
1
+ import React, { useRef } from 'react';
2
+ import handleEvent from '@pega/react-sdk-components/lib/components/helpers/event-utils';
3
+ import { getComponentFromMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
4
+ import type { PConnFieldProps } from '@pega/react-sdk-components/lib/types/PConnProps';
5
+
6
+ interface RichTextProps extends PConnFieldProps {
7
+ // If any, enter additional props that only exist on TextArea here
8
+ additionalProps?: object;
9
+ }
10
+
11
+ export default function RichText(props: RichTextProps) {
12
+ // Get emitted components from map (so we can get any override that may exist)
13
+ const FieldValueList = getComponentFromMap('FieldValueList');
14
+ const RichTextEditor = getComponentFromMap('RichTextEditor');
15
+
16
+ const { getPConnect, value, placeholder, validatemessage, label, hideLabel, helperText, testId, displayMode, additionalProps } = props;
17
+ const pConn = getPConnect();
18
+ const editorRef: any = useRef(null);
19
+
20
+ let { readOnly, required, disabled } = props;
21
+ [readOnly, required, disabled] = [readOnly, required, disabled].map((prop) => prop === true || (typeof prop === 'string' && prop === 'true'));
22
+
23
+ const helperTextToDisplay = validatemessage || helperText;
24
+
25
+ if (displayMode === 'LABELS_LEFT') {
26
+ return <FieldValueList name={hideLabel ? '' : label} value={value} />;
27
+ }
28
+
29
+ if (displayMode === 'STACKED_LARGE_VAL') {
30
+ return <FieldValueList name={hideLabel ? '' : label} value={value} variant="stacked" />;
31
+ }
32
+
33
+ let richTextComponent;
34
+
35
+ if (readOnly) {
36
+ // Rich Text read-only component
37
+ richTextComponent = (
38
+ <RichTextEditor
39
+ {...additionalProps}
40
+ label={label}
41
+ labelHidden={hideLabel}
42
+ defaultValue={value}
43
+ testId={testId}
44
+ info={helperTextToDisplay}
45
+ ref={editorRef}
46
+ readOnly
47
+ />
48
+ );
49
+ } else {
50
+ // Rich Text editable component
51
+ const actionsApi = pConn.getActionsApi();
52
+ let status = '';
53
+ if (validatemessage !== '') {
54
+ status = 'error';
55
+ }
56
+ const handleChange = () => {
57
+ if (status === 'error') {
58
+ const property = pConn.getStateProps().value;
59
+ pConn.clearErrorMessages({
60
+ property
61
+ });
62
+ }
63
+ };
64
+
65
+ const handleBlur = () => {
66
+ if (editorRef.current) {
67
+ const editorValue = editorRef.current.getContent({ format: 'html' });
68
+ const property = pConn.getStateProps().value;
69
+ handleEvent(actionsApi, 'changeNblur', property, editorValue);
70
+ }
71
+ };
72
+
73
+ richTextComponent = (
74
+ <RichTextEditor
75
+ {...additionalProps}
76
+ label={label}
77
+ labelHidden={hideLabel}
78
+ info={helperTextToDisplay}
79
+ defaultValue={value}
80
+ placeholder={placeholder}
81
+ disabled={disabled}
82
+ required={required}
83
+ testId={testId}
84
+ ref={editorRef}
85
+ error={status === 'error'}
86
+ onBlur={handleBlur}
87
+ onChange={handleChange}
88
+ />
89
+ );
90
+ }
91
+
92
+ return richTextComponent;
93
+ }
@@ -0,0 +1 @@
1
+ export { default } from './RichText';
@@ -0,0 +1,64 @@
1
+ /* eslint-disable react/no-array-index-key */
2
+ import React from 'react';
3
+ import { getComponentFromMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
4
+ import type { PConnProps } from '@pega/react-sdk-components/lib/types/PConnProps';
5
+
6
+ // ScalarListProps can't extend PConnFieldProps because its 'value' has a different type
7
+ interface ScalarListProps extends PConnProps {
8
+ // If any, enter additional props that only exist on this component
9
+ displayInModal: boolean;
10
+ hideLabel: boolean;
11
+ value: Array<any>;
12
+ componentType: string;
13
+ label: string;
14
+ displayMode: string;
15
+ }
16
+
17
+ function CommaSeparatedList(props) {
18
+ const { items } = props;
19
+
20
+ return (
21
+ <ul style={{ padding: '0', margin: '0' }}>
22
+ {items.map((value, index) => {
23
+ return <span key={index}>{value}</span>;
24
+ })}
25
+ </ul>
26
+ );
27
+ }
28
+
29
+ export default function ScalarList(props: ScalarListProps) {
30
+ // Get emitted components from map (so we can get any override that may exist)
31
+ const FieldValueList = getComponentFromMap('FieldValueList');
32
+ const { label, getPConnect, componentType, value: scalarValues, displayMode, hideLabel, ...restProps } = props;
33
+
34
+ const items = scalarValues?.map((scalarValue) => {
35
+ return getPConnect().createComponent(
36
+ {
37
+ type: componentType,
38
+ config: {
39
+ value: scalarValue,
40
+ displayMode: 'LABELS_LEFT',
41
+ label,
42
+ ...restProps,
43
+ readOnly: 'true'
44
+ }
45
+ },
46
+ null,
47
+ null,
48
+ {}
49
+ ); // 2nd, 3rd, and 4th args empty string/object/null until typedef marked correctly as optional;
50
+ });
51
+
52
+ if (['LABELS_LEFT', 'STACKED_LARGE_VAL', 'DISPLAY_ONLY'].includes(displayMode)) {
53
+ const displayComp = (
54
+ <div>
55
+ <CommaSeparatedList items={items} />
56
+ </div>
57
+ );
58
+ return displayComp;
59
+ }
60
+
61
+ const displayComp = <CommaSeparatedList items={items} />;
62
+
63
+ return <FieldValueList name={hideLabel ? '' : label} value={displayComp} variant="stacked" />;
64
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "label": "ScalarList",
3
+ "componentKey": "ScalarList",
4
+ "name": "ScalarList",
5
+ "type": "Field",
6
+ "properties": [
7
+ ]
8
+ }
@@ -0,0 +1 @@
1
+ export { default } from './ScalarList';
@@ -1,9 +1,9 @@
1
- import React from "react";
2
- import PropTypes from "prop-types";
1
+ import React from 'react';
3
2
  import Typography from '@material-ui/core/Typography';
4
3
  import Grid from '@material-ui/core/Grid';
5
4
  import { makeStyles } from '@material-ui/core/styles';
6
- import FieldValueList from '@pega/react-sdk-components/lib/components/designSystemExtension/FieldValueList';
5
+ import { getComponentFromMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
6
+ import type { PConnFieldProps } from '@pega/react-sdk-components/lib/types/PConnProps';
7
7
 
8
8
  /* although this is called the SemanticLink component, we are not yet displaying as a
9
9
  SemanticLink in SDK and only showing the value as a read only text field. */
@@ -17,7 +17,7 @@ const useStyles = makeStyles((theme) => ({
17
17
  marginRight: theme.spacing(1),
18
18
  marginLeft: theme.spacing(1),
19
19
  marginTop: theme.spacing(1),
20
- marginBottom: theme.spacing(1),
20
+ marginBottom: theme.spacing(1)
21
21
  },
22
22
  fieldMargin: {
23
23
  paddingRight: theme.spacing(1),
@@ -27,7 +27,7 @@ const useStyles = makeStyles((theme) => ({
27
27
  marginRight: theme.spacing(1),
28
28
  marginLeft: theme.spacing(1),
29
29
  marginTop: theme.spacing(1),
30
- marginBottom: theme.spacing(1),
30
+ marginBottom: theme.spacing(1)
31
31
  },
32
32
  fieldLabel: {
33
33
  fontWeight: 400,
@@ -39,37 +39,38 @@ const useStyles = makeStyles((theme) => ({
39
39
  }
40
40
  }));
41
41
 
42
- export default function SemanticLink(props) {
43
- const {
44
- text,
45
- displayMode,
46
- label,
47
- hideLabel
48
- } = props;
49
- const classes = useStyles();
42
+ interface SemanticLinkProps extends PConnFieldProps {
43
+ // If any, enter additional props that only exist on SemanticLink here
44
+ // from previous PropTypes
45
+ text: string;
46
+ }
50
47
 
48
+ export default function SemanticLink(props: SemanticLinkProps) {
49
+ // Get emitted components from map (so we can get any override that may exist)
50
+ const FieldValueList = getComponentFromMap('FieldValueList');
51
51
 
52
- if (displayMode === "LABELS_LEFT" || (!displayMode && label !== undefined)) {
53
- const value = text || "---";
52
+ const { text, displayMode, label, hideLabel } = props;
53
+ const classes = useStyles();
54
+
55
+ if (displayMode === 'LABELS_LEFT' || (!displayMode && label !== undefined)) {
56
+ const value = text || '---';
54
57
  return (
55
- <Grid container spacing={1} style={{padding: "4px 0px"}} id="semantic-link-grid">
58
+ <Grid container spacing={1} style={{ padding: '4px 0px' }} id="semantic-link-grid">
56
59
  <Grid item xs={6}>
57
- <Typography variant="body2" component="span" className={`${classes.fieldLabel} ${classes.fieldMargin}`}>{label}</Typography>
60
+ <Typography variant="body2" component="span" className={`${classes.fieldLabel} ${classes.fieldMargin}`}>
61
+ {label}
62
+ </Typography>
58
63
  </Grid>
59
64
  <Grid item xs={6}>
60
- <Typography variant="body2" component="span" className={classes.fieldValue}>{value}</Typography>
65
+ <Typography variant="body2" component="span" className={classes.fieldValue}>
66
+ {value}
67
+ </Typography>
61
68
  </Grid>
62
69
  </Grid>
63
70
  );
64
71
  }
65
72
 
66
73
  if (displayMode === 'STACKED_LARGE_VAL') {
67
- return <FieldValueList name={hideLabel ? '' : label} value={text} variant='stacked' />;
74
+ return <FieldValueList name={hideLabel ? '' : label} value={text} variant="stacked" />;
68
75
  }
69
76
  }
70
-
71
- SemanticLink.propTypes = {
72
- text: PropTypes.string.isRequired,
73
- displayMode: PropTypes.string,
74
- label: PropTypes.string,
75
- };
@@ -1,4 +1,5 @@
1
- declare const PCore;
1
+ // Remove this and use "real" PCore type once .d.ts is fixed (currently shows 2 errors)
2
+ declare const PCore: any;
2
3
 
3
4
  function getDataReferenceInfo(pConnect, dataRelationshipContext) {
4
5
  if (!pConnect) {
@@ -1,8 +1,17 @@
1
1
  import React from 'react';
2
2
  import { TextField } from '@material-ui/core';
3
- import FieldValueList from '@pega/react-sdk-components/lib/components/designSystemExtension/FieldValueList';
3
+ import { getComponentFromMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
4
+ import type { PConnFieldProps } from '@pega/react-sdk-components/lib/types/PConnProps';
5
+
6
+ interface TextAreaProps extends PConnFieldProps {
7
+ // If any, enter additional props that only exist on TextArea here
8
+ fieldMetadata?: any;
9
+ }
10
+
11
+ export default function TextArea(props: TextAreaProps) {
12
+ // Get emitted components from map (so we can get any override that may exist)
13
+ const FieldValueList = getComponentFromMap('FieldValueList');
4
14
 
5
- export default function TextArea(props) {
6
15
  const {
7
16
  label,
8
17
  required,
@@ -30,7 +39,7 @@ export default function TextArea(props) {
30
39
  }
31
40
 
32
41
  if (displayMode === 'STACKED_LARGE_VAL') {
33
- return <FieldValueList name={hideLabel ? '' : label} value={value} variant='stacked' />;
42
+ return <FieldValueList name={hideLabel ? '' : label} value={value} variant="stacked" />;
34
43
  }
35
44
 
36
45
  if (readOnly) {
@@ -53,8 +62,8 @@ export default function TextArea(props) {
53
62
  fullWidth
54
63
  variant={readOnly ? 'standard' : 'outlined'}
55
64
  helperText={helperTextToDisplay}
56
- placeholder=''
57
- size='small'
65
+ placeholder=""
66
+ size="small"
58
67
  required={required}
59
68
  disabled={disabled}
60
69
  onChange={onChange}
@@ -1,7 +1,16 @@
1
1
  import React from 'react';
2
2
  import { Typography } from '@material-ui/core';
3
+ import type { PConnProps } from '@pega/react-sdk-components/lib/types/PConnProps';
3
4
 
4
- export default function TextContent(props) {
5
+ interface TextContentProps extends PConnProps {
6
+ // If any, enter additional props that only exist on TextContent here
7
+ content: string,
8
+ displayAs: 'Paragraph' | 'Heading 1' | 'Heading 2' | 'Heading 3' | 'Heading 4'
9
+ }
10
+
11
+
12
+
13
+ export default function TextContent(props: TextContentProps) {
5
14
  type ExpectedDisplayAs = 'Paragraph' | 'Heading 1' | 'Heading 2' | 'Heading 3' | 'Heading 4';
6
15
  type ExpectedVariants = 'body1' | 'h1' | 'h2' | 'h3' | 'h4';
7
16
 
@@ -1,17 +1,27 @@
1
- import React from 'react';
1
+ import React, { useState, useEffect } from 'react';
2
2
  import { TextField } from '@material-ui/core';
3
- import FieldValueList from '@pega/react-sdk-components/lib/components/designSystemExtension/FieldValueList';
3
+ import handleEvent from '@pega/react-sdk-components/lib/components/helpers/event-utils';
4
+ import { getComponentFromMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
5
+ import type { PConnFieldProps } from '@pega/react-sdk-components/lib/types/PConnProps';
6
+
7
+ interface TextInputProps extends PConnFieldProps {
8
+ // If any, enter additional props that only exist on TextInput here
9
+ fieldMetadata?: any;
10
+ }
11
+
12
+ export default function TextInput(props: TextInputProps) {
13
+ // Get emitted components from map (so we can get any override that may exist)
14
+ const FieldValueList = getComponentFromMap('FieldValueList');
4
15
 
5
- export default function TextInput(props) {
6
16
  const {
17
+ getPConnect,
7
18
  label,
8
19
  required,
9
20
  disabled,
10
21
  value = '',
11
22
  validatemessage,
12
23
  status,
13
- onChange,
14
- onBlur,
24
+ /* onChange, onBlur */
15
25
  readOnly,
16
26
  testId,
17
27
  fieldMetadata,
@@ -19,18 +29,28 @@ export default function TextInput(props) {
19
29
  displayMode,
20
30
  hideLabel
21
31
  } = props;
32
+
33
+ const pConn = getPConnect();
34
+ const actions = pConn.getActionsApi();
35
+ const propName = pConn.getStateProps().value;
36
+
22
37
  const helperTextToDisplay = validatemessage || helperText;
23
38
 
39
+ const [inputValue, setInputValue] = useState('');
24
40
  const maxLength = fieldMetadata?.maxLength;
25
41
 
26
42
  let readOnlyProp = {}; // Note: empty if NOT ReadOnly
27
43
 
44
+ useEffect(() => {
45
+ setInputValue(value);
46
+ }, [value]);
47
+
28
48
  if (displayMode === 'LABELS_LEFT') {
29
49
  return <FieldValueList name={hideLabel ? '' : label} value={value} />;
30
50
  }
31
51
 
32
52
  if (displayMode === 'STACKED_LARGE_VAL') {
33
- return <FieldValueList name={hideLabel ? '' : label} value={value} variant='stacked' />;
53
+ return <FieldValueList name={hideLabel ? '' : label} value={value} variant="stacked" />;
34
54
  }
35
55
 
36
56
  if (readOnly) {
@@ -43,20 +63,29 @@ export default function TextInput(props) {
43
63
  'data-test-id': testId
44
64
  };
45
65
 
66
+ function handleChange(event) {
67
+ // update internal value
68
+ setInputValue(event?.target?.value);
69
+ }
70
+
71
+ function handleBlur() {
72
+ handleEvent(actions, 'changeNblur', propName, inputValue);
73
+ }
74
+
46
75
  return (
47
76
  <TextField
48
77
  fullWidth
49
78
  variant={readOnly ? 'standard' : 'outlined'}
50
79
  helperText={helperTextToDisplay}
51
- placeholder=''
52
- size='small'
80
+ placeholder=""
81
+ size="small"
53
82
  required={required}
54
83
  disabled={disabled}
55
- onChange={onChange}
56
- onBlur={!readOnly ? onBlur : undefined}
84
+ onChange={handleChange}
85
+ onBlur={!readOnly ? handleBlur : undefined}
57
86
  error={status === 'error'}
58
87
  label={label}
59
- value={value}
88
+ value={inputValue}
60
89
  InputProps={{ ...readOnlyProp, inputProps: { maxLength, ...testProp } }}
61
90
  />
62
91
  );
@@ -1,24 +1,20 @@
1
1
  import React from 'react';
2
2
  import { KeyboardTimePicker } from '@material-ui/pickers';
3
- import TextInput from '@pega/react-sdk-components/lib/components/field/TextInput';
4
- import dayjs from 'dayjs';
5
3
  import AccessTimeIcon from '@material-ui/icons/AccessTime';
6
- import FieldValueList from '@pega/react-sdk-components/lib/components/designSystemExtension/FieldValueList';
4
+ import dayjs from 'dayjs';
5
+ import { getComponentFromMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
6
+ import type { PConnFieldProps } from '@pega/react-sdk-components/lib/types/PConnProps';
7
+
8
+ interface TimeProps extends PConnFieldProps {
9
+ // If any, enter additional props that only exist on Time here
10
+ }
7
11
 
8
- export default function Time(props) {
9
- const {
10
- label,
11
- required,
12
- disabled,
13
- value,
14
- validatemessage,
15
- status,
16
- onChange,
17
- readOnly,
18
- helperText,
19
- displayMode,
20
- hideLabel
21
- } = props;
12
+ export default function Time(props: TimeProps) {
13
+ // Get emitted components from map (so we can get any override that may exist)
14
+ const FieldValueList = getComponentFromMap('FieldValueList');
15
+ const TextInput = getComponentFromMap('TextInput');
16
+
17
+ const { label, required, disabled, value = '', validatemessage, status, onChange, readOnly, helperText, displayMode, hideLabel, testId } = props;
22
18
  const helperTextToDisplay = validatemessage || helperText;
23
19
 
24
20
  if (displayMode === 'LABELS_LEFT') {
@@ -26,21 +22,27 @@ export default function Time(props) {
26
22
  }
27
23
 
28
24
  if (displayMode === 'STACKED_LARGE_VAL') {
29
- return <FieldValueList name={hideLabel ? '' : label} value={value} variant='stacked' />;
25
+ return <FieldValueList name={hideLabel ? '' : label} value={value} variant="stacked" />;
30
26
  }
31
27
 
32
28
  if (readOnly) {
33
29
  return <TextInput {...props} />;
34
30
  }
35
31
 
36
- const handleChange = date => {
32
+ let testProp = {};
33
+
34
+ testProp = {
35
+ 'data-test-id': testId
36
+ };
37
+
38
+ const handleChange = (date) => {
37
39
  const theValue = date && date.isValid() ? date.format('HH:mm') : null;
38
40
  onChange({ value: theValue });
39
41
  };
40
42
 
41
43
  let timeValue: any = null;
42
44
  if (value) {
43
- const timeArray = value.split(':').map(itm => Number(itm));
45
+ const timeArray = value.split(':').map((itm) => Number(itm));
44
46
  timeValue = dayjs().hour(timeArray[0]).minute(timeArray[1]);
45
47
  }
46
48
 
@@ -51,9 +53,9 @@ export default function Time(props) {
51
53
 
52
54
  return (
53
55
  <KeyboardTimePicker
54
- variant='inline'
55
- inputVariant='outlined'
56
- placeholder='hh:mm am'
56
+ variant="inline"
57
+ inputVariant="outlined"
58
+ placeholder="hh:mm am"
57
59
  keyboardIcon={<AccessTimeIcon />}
58
60
  fullWidth
59
61
  required={required}
@@ -61,13 +63,14 @@ export default function Time(props) {
61
63
  error={status === 'error'}
62
64
  helperText={helperTextToDisplay}
63
65
  minutesStep={5}
64
- size='small'
66
+ size="small"
65
67
  label={label}
66
68
  autoOk
67
- mask='__:__ _m'
68
- format='hh:mm a'
69
+ mask="__:__ _m"
70
+ format="hh:mm a"
69
71
  value={timeValue}
70
72
  onChange={handleChange}
73
+ InputProps={{ inputProps: { ...testProp } }}
71
74
  />
72
75
  );
73
76
  }
@@ -1,12 +1,20 @@
1
1
  import React from 'react';
2
2
  import { TextField } from '@material-ui/core';
3
- import TextInput from '@pega/react-sdk-components/lib/components/field/TextInput';
4
- import FieldValueList from '@pega/react-sdk-components/lib/components/designSystemExtension/FieldValueList';
3
+ import { getComponentFromMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
4
+ import type { PConnFieldProps } from '@pega/react-sdk-components/lib/types/PConnProps';
5
+
6
+ interface URLComponentProps extends PConnFieldProps {
7
+ // If any, enter additional props that only exist on URLComponent here
8
+ }
5
9
 
6
10
  // NOTE: that we had to change the name from URL to URLComponent
7
11
  // Otherwise, we were getting all kinds of weird errors when we
8
12
  // referred to URL as a component.
9
- export default function URLComponent(props) {
13
+ export default function URLComponent(props: URLComponentProps) {
14
+ // Get emitted components from map (so we can get any override that may exist)
15
+ const FieldValueList = getComponentFromMap('FieldValueList');
16
+ const TextInput = getComponentFromMap('TextInput');
17
+
10
18
  const {
11
19
  label,
12
20
  required,
@@ -17,6 +25,7 @@ export default function URLComponent(props) {
17
25
  onChange,
18
26
  onBlur,
19
27
  readOnly,
28
+ testId,
20
29
  helperText,
21
30
  displayMode,
22
31
  hideLabel
@@ -28,21 +37,27 @@ export default function URLComponent(props) {
28
37
  }
29
38
 
30
39
  if (displayMode === 'STACKED_LARGE_VAL') {
31
- return <FieldValueList name={hideLabel ? '' : label} value={value} variant='stacked' />;
40
+ return <FieldValueList name={hideLabel ? '' : label} value={value} variant="stacked" />;
32
41
  }
33
42
 
34
43
  if (readOnly) {
35
44
  return <TextInput {...props} />;
36
45
  }
37
46
 
47
+ let testProp = {};
48
+
49
+ testProp = {
50
+ 'data-test-id': testId
51
+ };
52
+
38
53
  return (
39
54
  <TextField
40
- type='url'
55
+ type="url"
41
56
  fullWidth
42
- variant='outlined'
57
+ variant="outlined"
43
58
  helperText={helperTextToDisplay}
44
- placeholder=''
45
- size='small'
59
+ placeholder=""
60
+ size="small"
46
61
  required={required}
47
62
  disabled={disabled}
48
63
  onChange={onChange}
@@ -50,6 +65,7 @@ export default function URLComponent(props) {
50
65
  error={status === 'error'}
51
66
  label={label}
52
67
  value={value}
68
+ InputProps={{ inputProps: { ...testProp } }}
53
69
  />
54
70
  );
55
71
  }