@pega/sdk 0.0.14 → 0.0.15

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 (130) hide show
  1. package/README.md +46 -6
  2. package/dist/index.js +50 -24
  3. package/package.json +42 -3
  4. package/templates/angular-sdk-reference/angular.json +1 -2
  5. package/templates/angular-sdk-reference/extra-webpack.config.cjs +23 -0
  6. package/templates/angular-sdk-reference/index.html +12 -0
  7. package/templates/angular-sdk-reference/package.json +0 -1
  8. package/templates/angular-sdk-reference/src/app/app.component.ts +15 -232
  9. package/templates/angular-sdk-reference/src/app/pconnect-renderer.component.ts +153 -0
  10. package/templates/angular-sdk-reference/src/components/fields/auto-complete/auto-complete.component.ts +58 -21
  11. package/templates/angular-sdk-reference/src/components/fields/checkbox/checkbox.component.ts +8 -3
  12. package/templates/angular-sdk-reference/src/components/fields/currency/currency.component.ts +22 -7
  13. package/templates/angular-sdk-reference/src/components/fields/date-input/date-input.component.ts +19 -6
  14. package/templates/angular-sdk-reference/src/components/fields/dropdown/dropdown.component.ts +24 -7
  15. package/templates/angular-sdk-reference/src/components/fields/email/email.component.ts +19 -6
  16. package/templates/angular-sdk-reference/src/components/fields/integer/integer.component.ts +19 -6
  17. package/templates/angular-sdk-reference/src/components/fields/phone/phone.component.ts +19 -6
  18. package/templates/angular-sdk-reference/src/components/fields/radio-buttons/radio-buttons.component.ts +16 -5
  19. package/templates/angular-sdk-reference/src/components/fields/text-area/text-area.component.ts +19 -6
  20. package/templates/angular-sdk-reference/src/components/fields/text-input/text-input.component.ts +19 -6
  21. package/templates/angular-sdk-reference/src/components/fields/url-input/url-input.component.ts +26 -7
  22. package/templates/angular-sdk-reference/src/components/helpers/sdk-helpers.ts +93 -0
  23. package/templates/angular-sdk-reference/src/components/infra/case-summary/case-summary.component.ts +8 -9
  24. package/templates/angular-sdk-reference/src/components/infra/case-view/case-view.component.ts +24 -12
  25. package/templates/angular-sdk-reference/src/components/infra/root-container/root-container.component.ts +21 -15
  26. package/templates/angular-sdk-reference/src/components/infra/stages/stages.component.ts +21 -10
  27. package/templates/angular-sdk-reference/src/components/infra/view/view.component.ts +14 -9
  28. package/templates/angular-sdk-reference/src/components/templates/default-form/default-form.component.ts +12 -8
  29. package/templates/angular-sdk-reference/tsconfig.app.json +13 -0
  30. package/templates/angular-sdk-reference/tsconfig.json +2 -5
  31. package/templates/react-sdk-reference/.ai-common/agents/embedded-flow-expert.md +65 -31
  32. package/templates/react-sdk-reference/.ai-common/agents/implementation-expert.md +74 -38
  33. package/templates/react-sdk-reference/.ai-common/global/ai-agent-instructions-embedded.md +33 -1
  34. package/templates/react-sdk-reference/.ai-common/global/ai-agent-instructions.md +57 -22
  35. package/templates/react-sdk-reference/.ai-common/instructions/embedded-component.md +25 -10
  36. package/templates/react-sdk-reference/.ai-common/prompts/add-component.md +40 -19
  37. package/templates/react-sdk-reference/.ai-common/prompts/component-manifest.json +55 -1
  38. package/templates/react-sdk-reference/.ai-common/prompts/embedded-component-manifest.md +26 -4
  39. package/templates/react-sdk-reference/.ai-common/prompts/generate-all-components.md +82 -33
  40. package/templates/react-sdk-reference/.ai-common/prompts/generate-dse-components.md +46 -26
  41. package/templates/react-sdk-reference/.ai-common/prompts/generate-embedded-components.md +28 -15
  42. package/templates/react-sdk-reference/.ai-common/prompts/generate-field-components.md +24 -6
  43. package/templates/react-sdk-reference/.ai-common/prompts/generate-infra-components.md +24 -6
  44. package/templates/react-sdk-reference/.ai-common/prompts/generate-template-components.md +24 -6
  45. package/templates/react-sdk-reference/.ai-common/prompts/generate-widget-components.md +24 -6
  46. package/templates/react-sdk-reference/.ai-common/prompts/identify-components.md +2 -0
  47. package/templates/react-sdk-reference/.ai-common/prompts/replace-design-system.md +44 -17
  48. package/templates/react-sdk-reference/.ai-common/skills/connect-pega-server.md +14 -1
  49. package/templates/react-sdk-reference/.ai-common/skills/design-system-extension-skills/AssignmentHeader.md +79 -0
  50. package/templates/react-sdk-reference/.ai-common/skills/design-system-extension-skills/Toast.md +96 -0
  51. package/templates/react-sdk-reference/.ai-common/skills/design-system-extension.md +56 -35
  52. package/templates/react-sdk-reference/.ai-common/skills/embedded-flow/analyze-customer-repo.md +29 -3
  53. package/templates/react-sdk-reference/.ai-common/skills/embedded-flow/run-and-verify-integration.md +97 -37
  54. package/templates/react-sdk-reference/.ai-common/skills/embedded-flow/wire-integration.md +91 -60
  55. package/templates/react-sdk-reference/.ai-common/skills/field-components.md +13 -1
  56. package/templates/react-sdk-reference/.ai-common/skills/infra-components.md +13 -1
  57. package/templates/react-sdk-reference/.ai-common/skills/portal-flow/run-and-verify-portal.md +290 -0
  58. package/templates/react-sdk-reference/.ai-common/skills/template-components.md +13 -1
  59. package/templates/react-sdk-reference/.ai-common/skills/widget-components.md +13 -1
  60. package/templates/react-sdk-reference/assets/icons/trash.svg +3 -0
  61. package/templates/react-sdk-reference/index.html +0 -1
  62. package/templates/react-sdk-reference/package.json +2 -2
  63. package/templates/react-sdk-reference/package.minimal.json +2 -2
  64. package/templates/react-sdk-reference/sdk-config.json +3 -3
  65. package/templates/react-sdk-reference/src/FallbackComponent.tsx +1 -1
  66. package/templates/react-sdk-reference/src/MashupApp.tsx +33 -78
  67. package/templates/react-sdk-reference/src/PortalApp.tsx +23 -100
  68. package/templates/react-sdk-reference/src/components/component-map.ts +15 -1
  69. package/templates/react-sdk-reference/src/components/designSystemExtension/AssignmentHeader/AssignmentHeader.tsx +15 -0
  70. package/templates/react-sdk-reference/src/components/designSystemExtension/AssignmentHeader/index.tsx +1 -0
  71. package/templates/react-sdk-reference/src/components/designSystemExtension/FieldGroup/FieldGroup.tsx +1 -1
  72. package/templates/react-sdk-reference/src/components/designSystemExtension/FieldGroupList/FieldGroupList.tsx +1 -1
  73. package/templates/react-sdk-reference/src/components/designSystemExtension/FieldValueList/FieldValueList.tsx +16 -4
  74. package/templates/react-sdk-reference/src/components/designSystemExtension/ModalDialog/ModalDialog.tsx +26 -0
  75. package/templates/react-sdk-reference/src/components/designSystemExtension/ModalDialog/index.tsx +1 -0
  76. package/templates/react-sdk-reference/src/components/designSystemExtension/Toast/Toast.tsx +35 -0
  77. package/templates/react-sdk-reference/src/components/designSystemExtension/Toast/index.tsx +1 -0
  78. package/templates/react-sdk-reference/src/components/field/AutoComplete/AutoComplete.tsx +362 -24
  79. package/templates/react-sdk-reference/src/components/field/CancelAlert/CancelAlert.tsx +1 -1
  80. package/templates/react-sdk-reference/src/components/field/Checkbox/Checkbox.tsx +3 -1
  81. package/templates/react-sdk-reference/src/components/field/Currency/Currency.tsx +6 -3
  82. package/templates/react-sdk-reference/src/components/field/Date/Date.tsx +2 -1
  83. package/templates/react-sdk-reference/src/components/field/DateTime/DateTime.tsx +2 -1
  84. package/templates/react-sdk-reference/src/components/field/Decimal/Decimal.tsx +4 -3
  85. package/templates/react-sdk-reference/src/components/field/Dropdown/Dropdown.tsx +2 -0
  86. package/templates/react-sdk-reference/src/components/field/Email/Email.tsx +2 -1
  87. package/templates/react-sdk-reference/src/components/field/EmbeddedDataMulti/EmbeddedDataMulti.tsx +121 -0
  88. package/templates/react-sdk-reference/src/components/field/EmbeddedDataMulti/config-ext.json +7 -0
  89. package/templates/react-sdk-reference/src/components/field/EmbeddedDataMulti/index.tsx +1 -0
  90. package/templates/react-sdk-reference/src/components/field/Integer/Integer.tsx +2 -1
  91. package/templates/react-sdk-reference/src/components/field/Location/Location.tsx +1 -1
  92. package/templates/react-sdk-reference/src/components/field/Multiselect/Multiselect.tsx +40 -20
  93. package/templates/react-sdk-reference/src/components/field/ObjectReference/ObjectReference.tsx +554 -49
  94. package/templates/react-sdk-reference/src/components/field/ObjectReference/utils.ts +111 -20
  95. package/templates/react-sdk-reference/src/components/field/Percentage/Percentage.tsx +4 -3
  96. package/templates/react-sdk-reference/src/components/field/Phone/Phone.tsx +2 -1
  97. package/templates/react-sdk-reference/src/components/field/SelectableCard/SelectableCard.tsx +2 -1
  98. package/templates/react-sdk-reference/src/components/field/TextArea/TextArea.tsx +2 -1
  99. package/templates/react-sdk-reference/src/components/field/TextInput/TextInput.tsx +2 -1
  100. package/templates/react-sdk-reference/src/components/field/Time/Time.tsx +2 -1
  101. package/templates/react-sdk-reference/src/components/field/URL/URL.tsx +2 -1
  102. package/templates/react-sdk-reference/src/components/field/UserReference/UserReference.tsx +1 -1
  103. package/templates/react-sdk-reference/src/components/helpers/field-utils.ts +44 -0
  104. package/templates/react-sdk-reference/src/components/helpers/simpleTableHelpers.ts +19 -7
  105. package/templates/react-sdk-reference/src/components/infra/ModalViewContainer/DataViewActionButtons/DataViewActionButtons.tsx +97 -0
  106. package/templates/react-sdk-reference/src/components/infra/ModalViewContainer/DataViewActionButtons/index.tsx +1 -0
  107. package/templates/react-sdk-reference/src/components/infra/ModalViewContainer/ListViewActionButtons/ListViewActionButtons.tsx +53 -0
  108. package/templates/react-sdk-reference/src/components/infra/ModalViewContainer/ListViewActionButtons/index.tsx +1 -0
  109. package/templates/react-sdk-reference/src/components/template/AdvancedSearch/SearchGroups/SearchGroups.tsx +2 -2
  110. package/templates/react-sdk-reference/src/components/template/CaseSummary/CaseSummary.tsx +3 -1
  111. package/templates/react-sdk-reference/src/components/template/DataReference/SearchForm.tsx +4 -4
  112. package/templates/react-sdk-reference/src/components/template/HierarchicalForm/HierarchicalForm.tsx +2 -2
  113. package/templates/react-sdk-reference/src/components/template/InlineDashboard/InlineDashboard.tsx +1 -1
  114. package/templates/react-sdk-reference/src/components/template/ListView/ListView.tsx +7 -3
  115. package/templates/react-sdk-reference/src/components/template/SimpleTable/SimpleTableManual/SimpleTableManual.tsx +173 -99
  116. package/templates/react-sdk-reference/src/components/template/SimpleTable/SimpleTableSelect/SimpleTableSelect.tsx +63 -56
  117. package/templates/react-sdk-reference/src/components/widget/ToDo/ToDo.tsx +1 -1
  118. package/templates/react-sdk-reference/vite.config.ts +26 -4
  119. package/templates/angular-sdk-reference/pega-constellationjs-0.26.3-local.tgz +0 -0
  120. package/templates/angular-sdk-reference/src/helpers/event-utils.ts +0 -18
  121. package/templates/angular-sdk-reference/src/helpers/utils.ts +0 -38
  122. package/templates/angular-sdk-reference/src/helpers/versionHelpers.ts +0 -14
  123. package/templates/react-sdk-reference/.ai-common/instructions/dse-component.md +0 -47
  124. package/templates/react-sdk-reference/.ai-common/instructions/field-component.md +0 -50
  125. package/templates/react-sdk-reference/.ai-common/instructions/infra-component.md +0 -76
  126. package/templates/react-sdk-reference/.ai-common/instructions/template-component.md +0 -43
  127. package/templates/react-sdk-reference/.ai-common/instructions/widget-component.md +0 -45
  128. package/templates/react-sdk-reference/.ai-common/skills/embedded-flow/authenticate.md +0 -311
  129. package/templates/react-sdk-reference/pega-constellationjs-0.26.3-local.tgz +0 -0
  130. package/templates/react-sdk-reference/pega-sdk-react-0.1.0.tgz +0 -0
@@ -41,9 +41,9 @@ const checkIfSelectionsExist = (getPConnect) => {
41
41
  };
42
42
 
43
43
  const SearchForm = (props) => {
44
- const { children, getPConnect, searchSelectCacheKey } = props;
44
+ const { children, getPConnect, searchSelectCacheKey, type, label } = props;
45
45
 
46
- const deferLoadedTabs = children[2];
46
+ const deferLoadedTabs = type === 'ObjectReference' ? { props: { getPConnect } } : children[2];
47
47
  const cache: any = PCore.getNavigationUtils().getComponentCache(searchSelectCacheKey) ?? {};
48
48
  const { selectedCategory } = cache;
49
49
  const firstTabId = getFirstVisibleTabId(deferLoadedTabs, selectedCategory);
@@ -115,8 +115,8 @@ const SearchForm = (props) => {
115
115
  }
116
116
 
117
117
  return (
118
- <Box display="flex" flexDirection="column" gap={2}>
119
- <Typography variant="h5">{propsToUse.label}</Typography>
118
+ <Box sx={{ display: 'flex', flexDirection: 'column', gap: 2 }}>
119
+ <Typography variant="h5">{label ?? propsToUse.label}</Typography>
120
120
  {searchCategoriesComp}
121
121
  <TabContext value={currentTabId}>
122
122
  <Tabs style={{ display: 'none' }} value={currentTabId} onChange={(e, newValue) => setCurrentTabId(newValue)}>
@@ -12,9 +12,9 @@ export default function HierarchicalForm(props: PropsWithChildren<HierarchicalFo
12
12
  }
13
13
 
14
14
  return (
15
- <Box display="flex" flexDirection="column">
15
+ <Box sx={{ display: 'flex', flexDirection: 'column' }}>
16
16
  {instructions && (
17
- <Box mb={2}>
17
+ <Box sx={{ mb: 2 }}>
18
18
  <div dangerouslySetInnerHTML={{ __html: instructions }} />
19
19
  </Box>
20
20
  )}
@@ -50,7 +50,7 @@ export default function InlineDashboard(props: PropsWithChildren<InlineDashboard
50
50
  </Typography>
51
51
 
52
52
  {filterPosition === 'block-start' && (
53
- <Grid container spacing={2} direction="column-reverse" className={classes.containerStyles}>
53
+ <Grid container spacing={2} sx={{ flexDirection: 'column-reverse' }} className={classes.containerStyles}>
54
54
  <Grid size={{ xs: 12 }} className={classes.colStyles}>
55
55
  {childrenToRender[0]}
56
56
  </Grid>
@@ -56,6 +56,7 @@ interface ListViewProps extends PConnProps {
56
56
  compositeKeys?: any;
57
57
  showDynamicFields?: boolean;
58
58
  readonlyContextList?: any;
59
+ selectedValues?: any;
59
60
  value: any;
60
61
  viewName?: string;
61
62
  showRecords?: boolean;
@@ -88,11 +89,14 @@ export default function ListView(props: ListViewProps) {
88
89
  compositeKeys,
89
90
  showDynamicFields,
90
91
  viewName,
91
- readonlyContextList: selectedValues,
92
+ readonlyContextList,
93
+ selectedValues: selectedValuesProp,
92
94
  value,
93
95
  displayAs,
94
96
  localeReference,
95
97
  } = props;
98
+ // SimpleTableSelect passes selectedValues; other callers only set readonlyContextList
99
+ const selectedValues = selectedValuesProp ?? readonlyContextList;
96
100
  let { showRecords } = props;
97
101
  const ref = useRef({}).current;
98
102
  const cosmosTableRef = useRef();
@@ -1132,12 +1136,12 @@ export default function ListView(props: ListViewProps) {
1132
1136
  <>
1133
1137
  {arColumns && arColumns.length > 0 && (
1134
1138
  <Paper className={classes.paper}>
1135
- <Grid container justifyContent="space-between">
1139
+ <Grid container sx={{ justifyContent: 'space-between' }}>
1136
1140
  <Typography variant="h6" color="textPrimary" gutterBottom>
1137
1141
  {_listTitle()}
1138
1142
  </Typography>
1139
1143
  {globalSearch && (
1140
- <Grid container spacing={1} alignItems="flex-end">
1144
+ <Grid container spacing={1} sx={{ alignItems: 'flex-end' }}>
1141
1145
  <Grid>
1142
1146
  <SearchIcon />
1143
1147
  </Grid>
@@ -55,6 +55,9 @@ interface SimpleTableManualProps extends PConnProps {
55
55
  viewForEditModal: any;
56
56
  validatemessage?: string;
57
57
  required?: boolean;
58
+ targetClassLabel?: string;
59
+ uniqueField?: string;
60
+ hideEditRow?: boolean;
58
61
  }
59
62
 
60
63
  const useStyles = makeStyles((/* theme */) => ({
@@ -101,9 +104,6 @@ let menuColumnId = '';
101
104
  let menuColumnType = '';
102
105
  let menuColumnLabel = '';
103
106
 
104
- const filterByColumns: any[] = [];
105
- let myRows: any[];
106
-
107
107
  export default function SimpleTableManual(props: PropsWithChildren<SimpleTableManualProps>) {
108
108
  const classes = useStyles();
109
109
  const {
@@ -118,6 +118,7 @@ export default function SimpleTableManual(props: PropsWithChildren<SimpleTableMa
118
118
  contextClass,
119
119
  hideAddRow,
120
120
  hideDeleteRow,
121
+ hideEditRow,
121
122
  propertyLabel,
122
123
  fieldMetadata,
123
124
  editMode,
@@ -129,7 +130,10 @@ export default function SimpleTableManual(props: PropsWithChildren<SimpleTableMa
129
130
  viewForEditModal,
130
131
  required,
131
132
  validatemessage,
133
+ targetClassLabel,
134
+ uniqueField,
132
135
  } = props;
136
+ const normalizedUniqueField = uniqueField?.charAt(0) === '.' ? uniqueField.substring(1) : uniqueField;
133
137
  const pConn = getPConnect();
134
138
  const [rowData, setRowData] = useState([]);
135
139
  const [elements, setElementsData] = useState([]);
@@ -148,6 +152,8 @@ export default function SimpleTableManual(props: PropsWithChildren<SimpleTableMa
148
152
  const [displayDialogDateFilter, setDisplayDialogDateFilter] = useState<string>('notequal');
149
153
  const [displayDialogDateValue, setDisplayDialogDateValue] = useState<string>('');
150
154
  const selectedRowIndex: any = useRef(null);
155
+ const myRowsRef = useRef<any[]>([]);
156
+ const filterByColumnsRef = useRef<any[]>([]);
151
157
  const localizedVal = PCore.getLocaleUtils().getLocaleValue;
152
158
  const localeCategory = 'SimpleTable';
153
159
  const parameters = fieldMetadata?.datasource?.parameters;
@@ -163,8 +169,17 @@ export default function SimpleTableManual(props: PropsWithChildren<SimpleTableMa
163
169
  pConn.setReferenceList(resolvedList);
164
170
  const menuIconOverride$ = Utils.getImageSrc('trash', Utils.getSDKStaticConentUrl());
165
171
 
166
- const resolvedFields = children?.[0]?.children || presets?.[0].children?.[0].children;
167
- const primaryFieldsViewIndex = resolvedFields.findIndex((field) => field.config.value === 'pyPrimaryFields');
172
+ // sdk-react's `children` prop is React elements, so resolved columns come from the config props instead.
173
+ const resolvedFields =
174
+ children?.[0]?.children ||
175
+ presets?.[0].children?.[0].children ||
176
+ (pConn.getConfigProps() as any)?.children?.[0]?.children;
177
+ // @ts-ignore
178
+ const qualifiedPrimaryFields = PCore.getNameSpaceUtils?.()?.getDefaultQualifiedName('pyPrimaryFields');
179
+ const primaryFieldsViewIndex = resolvedFields?.findIndex((field) => {
180
+ const value = field.config.value;
181
+ return value === 'pyPrimaryFields' || value === qualifiedPrimaryFields;
182
+ });
168
183
  // NOTE: props has each child.config with datasource and value undefined
169
184
  // but getRawMetadata() has each child.config with datasource and value showing their unresolved values (ex: "@P thePropName")
170
185
  // We need to use the prop name as the "glue" to tie the table dataSource, displayColumns and data together.
@@ -188,22 +203,51 @@ export default function SimpleTableManual(props: PropsWithChildren<SimpleTableMa
188
203
  (editMode ? editMode === 'modal' : addAndEditRowsWithin === 'modal') &&
189
204
  !(renderMode === 'ReadOnly' || isDisplayModeEnabled);
190
205
  const showDeleteButton = editableMode && !hideDeleteRow;
206
+ const showEditButton = allowEditingInModal && !hideEditRow;
207
+ const { allowRowDelete: allowRowDeleteConfig } = pConn.getComponentConfig?.() ?? {};
208
+
209
+ const isDeleteAllowedForRow = (index: number): boolean => {
210
+ if (!showDeleteButton) return false;
211
+ if (allowRowDeleteConfig === undefined || allowRowDeleteConfig === true) return true;
212
+ if (typeof allowRowDeleteConfig === 'string' && allowRowDeleteConfig.startsWith('@E ')) {
213
+ try {
214
+ const expression = allowRowDeleteConfig.replace('@E ', '');
215
+ // @ts-expect-error - options param is optional per corejs docs
216
+ return PCore.getExpressionEngine().evaluate(expression, referenceList[index]);
217
+ } catch {
218
+ return true;
219
+ }
220
+ }
221
+ return false;
222
+ };
191
223
  const defaultView = editModeConfig ? editModeConfig.defaultView : viewForAddAndEditModal;
192
224
  const bUseSeparateViewForEdit = editModeConfig ? editModeConfig.useSeparateViewForEdit : useSeparateViewForEdit;
193
225
  const editView = editModeConfig ? editModeConfig.editView : viewForEditModal;
194
-
226
+ const editType = editModeConfig?.editType;
227
+ const defaultActionId = editType === 'action' ? editModeConfig?.defaultAction : undefined;
228
+ const editActionId =
229
+ editType === 'action' && editModeConfig?.useSeparateActionForEdit
230
+ ? editModeConfig?.editAction
231
+ : editModeConfig?.defaultAction;
195
232
  const configFields = getConfigFields(rawFields, contextClass, primaryFieldsViewIndex);
196
-
197
- const fieldsWithPropNames = rawFields.map((field, index) => {
198
- return {
199
- ...resolvedFields[index],
200
- propName: field.config.value.replace('@P .', ''),
201
- };
233
+ const addLabel = targetClassLabel
234
+ ? localizedVal('Add {0}', 'SimpleTable').replace('{0}', targetClassLabel)
235
+ : localizedVal('Add', 'SimpleTable');
236
+
237
+ const fieldsWithPropNames = configFields.map((field) => {
238
+ let propName = field.config.value;
239
+ if (propName.startsWith('@')) {
240
+ propName = propName.substring(propName.indexOf(' ') + 1);
241
+ }
242
+ if (propName.startsWith('.')) {
243
+ propName = propName.substring(1);
244
+ }
245
+ return { ...field, propName };
202
246
  });
203
247
 
204
248
  useEffect(() => {
205
249
  buildElementsForTable();
206
- if (readOnlyMode || allowEditingInModal) {
250
+ if (readOnlyMode || allowEditingInModal || hideEditRow) {
207
251
  generateRowsData();
208
252
  }
209
253
  }, [referenceList]);
@@ -220,7 +264,7 @@ export default function SimpleTableManual(props: PropsWithChildren<SimpleTableMa
220
264
  isDisplayModeEnabled || readOnlyMode
221
265
  ? initializeColumns(configFields, undefined)
222
266
  : // For inline edit table
223
- buildFieldsForTable(rawFields, getPConnect(), showDeleteButton, {
267
+ buildFieldsForTable(configFields, getPConnect(), showDeleteButton, {
224
268
  primaryFieldsViewIndex,
225
269
  fields: resolvedFields,
226
270
  }),
@@ -233,11 +277,14 @@ export default function SimpleTableManual(props: PropsWithChildren<SimpleTableMa
233
277
  .getListActions()
234
278
  .initDefaultPageInstructions(
235
279
  getPConnect().getReferenceList(),
236
- fieldDefs.filter((item) => item.name).map((item) => item.name),
280
+ // Temporary filter for attachments to align with constellation payload behavior.
281
+ fieldDefs.filter((item) => item.name && item.meta?.type !== 'Attachment').map((item) => item.name),
237
282
  );
238
283
  } else {
239
- // @ts-expect-error - An argument for 'fields' was not provided
240
- getPConnect().getListActions().initDefaultPageInstructions(getPConnect().getReferenceList());
284
+ // @ts-ignore - fields param is optional, uniqueField passed as 3rd arg for page instructions
285
+ getPConnect()
286
+ .getListActions()
287
+ .initDefaultPageInstructions(getPConnect().getReferenceList(), undefined, uniqueField);
241
288
  }
242
289
  }, []);
243
290
 
@@ -267,8 +314,10 @@ export default function SimpleTableManual(props: PropsWithChildren<SimpleTableMa
267
314
  // See what data (if any) we have to display
268
315
  const refKeys: string[] = inColKey?.split('.');
269
316
  let valBuilder = inRowData;
317
+ let index = 0;
270
318
  for (const key of refKeys) {
271
- valBuilder = valBuilder[key];
319
+ index += 1;
320
+ valBuilder = valBuilder[key] !== undefined || index === refKeys.length ? valBuilder[key] : valBuilder;
272
321
  }
273
322
  return getFormattedValue(valBuilder, inColKey);
274
323
  }
@@ -276,21 +325,25 @@ export default function SimpleTableManual(props: PropsWithChildren<SimpleTableMa
276
325
  const formatRowsData = (data) => {
277
326
  if (!data) return {};
278
327
 
279
- return data.map((item) => {
280
- return displayedColumns.reduce((dataForRow, colKey) => {
281
- dataForRow[colKey] = getRowValue(item, colKey);
282
- return dataForRow;
283
- }, {});
328
+ return data.map((item, idx) => {
329
+ const dataForRow = displayedColumns.reduce((acc, colKey) => {
330
+ acc[colKey] = getRowValue(item, colKey);
331
+ return acc;
332
+ }, {} as any);
333
+ dataForRow.__originalIndex = idx;
334
+ return dataForRow;
284
335
  });
285
336
  };
286
337
 
287
338
  function generateRowsData() {
339
+ myRowsRef.current = [];
340
+
288
341
  // if referenceList is empty and dataPageName property value exists then make a datapage fetch call and get the list of data.
289
342
  if (!referenceList.length && dataPageName) {
290
343
  getDataPage(dataPageName, parameters, context)
291
344
  .then((listData) => {
292
345
  const data = formatRowsData(listData);
293
- myRows = data;
346
+ myRowsRef.current = data || [];
294
347
  setRowData(data);
295
348
  })
296
349
  .catch((e) => {
@@ -301,16 +354,19 @@ export default function SimpleTableManual(props: PropsWithChildren<SimpleTableMa
301
354
  // in the table. So, iterate over referenceList to create the dataRows that
302
355
  // we're using as the table's dataSource
303
356
  const data: any = [];
304
- for (const row of referenceList) {
305
- const dataForRow: object = {};
357
+ referenceList.forEach((row, idx) => {
358
+ const dataForRow: any = {};
306
359
  for (const col of displayedColumns) {
307
360
  const colKey: string = col;
308
361
  const theVal = getRowValue(row, colKey);
309
362
  dataForRow[colKey] = theVal || '';
310
363
  }
364
+ // Preserve the original position so stableSort can look up the right
365
+ // entry in `elements` even after filtering shrinks rowData.
366
+ dataForRow.__originalIndex = idx;
311
367
  data.push(dataForRow);
312
- myRows = data;
313
- }
368
+ });
369
+ myRowsRef.current = data;
314
370
  setRowData(data);
315
371
  }
316
372
  }
@@ -331,19 +387,27 @@ export default function SimpleTableManual(props: PropsWithChildren<SimpleTableMa
331
387
  // console.log(JSON.stringify(rowData));
332
388
 
333
389
  const addRecord = () => {
334
- if (allowEditingInModal && defaultView) {
390
+ if (allowEditingInModal && (defaultView || defaultActionId)) {
335
391
  pConn
336
392
  .getActionsApi()
337
- // @ts-expect-error
393
+
338
394
  .openEmbeddedDataModal(
339
395
  defaultView,
396
+ // @ts-expect-error
340
397
  pConn,
341
398
  referenceListStr,
342
399
  referenceList.length,
343
400
  PCore.getConstants().RESOURCE_STATUS.CREATE,
401
+ targetClassLabel,
402
+ editType,
403
+ defaultActionId,
344
404
  );
345
405
  } else {
346
- pConn.getListActions().insert({ classID: contextClass }, referenceList.length);
406
+ const payload: any = { classID: contextClass };
407
+ if (normalizedUniqueField) {
408
+ payload[normalizedUniqueField] = crypto.randomUUID();
409
+ }
410
+ pConn.getListActions().insert(payload, referenceList.length);
347
411
  }
348
412
 
349
413
  getPConnect().clearErrorMessages({
@@ -356,13 +420,17 @@ export default function SimpleTableManual(props: PropsWithChildren<SimpleTableMa
356
420
  if (typeof selectedRowIndex.current === 'number') {
357
421
  pConn
358
422
  .getActionsApi()
359
- // @ts-expect-error
423
+
360
424
  .openEmbeddedDataModal(
361
425
  bUseSeparateViewForEdit ? editView : defaultView,
426
+ // @ts-expect-error
362
427
  pConn,
363
428
  referenceListStr,
364
429
  selectedRowIndex.current,
365
430
  PCore.getConstants().RESOURCE_STATUS.UPDATE,
431
+ targetClassLabel,
432
+ editType,
433
+ editActionId,
366
434
  );
367
435
  }
368
436
  };
@@ -380,7 +448,7 @@ export default function SimpleTableManual(props: PropsWithChildren<SimpleTableMa
380
448
  const eleData: any = [];
381
449
  referenceList.forEach((element, index) => {
382
450
  const data: any = [];
383
- rawFields.forEach((item) => {
451
+ configFields.forEach((item) => {
384
452
  // removing label field from config to hide title in the table cell
385
453
  if (!item.config.hide) {
386
454
  item = {
@@ -388,14 +456,14 @@ export default function SimpleTableManual(props: PropsWithChildren<SimpleTableMa
388
456
  config: {
389
457
  ...item.config,
390
458
  label: '',
391
- displayMode: readOnlyMode || allowEditingInModal ? 'DISPLAY_ONLY' : undefined,
459
+ displayMode: readOnlyMode || allowEditingInModal || hideEditRow ? 'DISPLAY_ONLY' : undefined,
392
460
  },
393
461
  };
394
462
  const referenceListData = getReferenceList(pConn);
395
463
  const isDatapage = referenceListData.startsWith('D_');
396
464
  const pageReferenceValue = isDatapage
397
465
  ? `${referenceListData}[${index}]`
398
- : `${pConn.getPageReference()}${referenceListData.substring(referenceListData.lastIndexOf('.'))}[${index}]`;
466
+ : `${pConn.getPageReference()}${referenceListData}[${index}]`;
399
467
  const config = {
400
468
  meta: item,
401
469
  options: {
@@ -460,11 +528,7 @@ export default function SimpleTableManual(props: PropsWithChildren<SimpleTableMa
460
528
  return a[1] - b[1];
461
529
  });
462
530
 
463
- const newElements = new Array(stabilizedThis.length);
464
- stabilizedThis.forEach((el, index) => {
465
- newElements[index] = elements[el[1]];
466
- });
467
- return newElements;
531
+ return stabilizedThis.map(([el]) => el);
468
532
  }
469
533
 
470
534
  function _menuClick(event, columnId: string, columnType: string, labelValue: string) {
@@ -490,7 +554,7 @@ export default function SimpleTableManual(props: PropsWithChildren<SimpleTableMa
490
554
 
491
555
  let bFound = false;
492
556
 
493
- for (const filterObj of filterByColumns) {
557
+ for (const filterObj of filterByColumnsRef.current) {
494
558
  if (filterObj.ref === menuColumnId) {
495
559
  setFilterBy(menuColumnLabel);
496
560
  if (filterObj.type === 'Date' || filterObj.type === 'DateTime' || filterObj.type === 'Time') {
@@ -556,10 +620,10 @@ export default function SimpleTableManual(props: PropsWithChildren<SimpleTableMa
556
620
 
557
621
  function filterSortGroupBy() {
558
622
  // get original data set
559
- let theData: any = myRows.slice();
623
+ let theData: any = myRowsRef.current?.slice();
560
624
 
561
625
  // last filter config data is global
562
- theData = theData.filter(filterData(filterByColumns));
626
+ theData = theData?.filter(filterData(filterByColumnsRef.current));
563
627
 
564
628
  // move data to array and then sort
565
629
  setRowData(theData);
@@ -567,7 +631,7 @@ export default function SimpleTableManual(props: PropsWithChildren<SimpleTableMa
567
631
 
568
632
  function updateFilterWithInfo() {
569
633
  let bFound = false;
570
- for (const filterObj of filterByColumns) {
634
+ for (const filterObj of filterByColumnsRef.current) {
571
635
  if (filterObj.ref === menuColumnId) {
572
636
  filterObj.type = filterType;
573
637
  if (containsDateOrTime) {
@@ -595,7 +659,7 @@ export default function SimpleTableManual(props: PropsWithChildren<SimpleTableMa
595
659
  filterObj.containsFilterValue = displayDialogContainsValue;
596
660
  }
597
661
 
598
- filterByColumns.push(filterObj);
662
+ filterByColumnsRef.current.push(filterObj);
599
663
  }
600
664
  }
601
665
 
@@ -607,7 +671,7 @@ export default function SimpleTableManual(props: PropsWithChildren<SimpleTableMa
607
671
  }
608
672
 
609
673
  function _showFilteredIcon(columnId) {
610
- for (const filterObj of filterByColumns) {
674
+ for (const filterObj of filterByColumnsRef.current) {
611
675
  if (filterObj.ref === columnId) {
612
676
  if (filterObj.containsFilterValue !== '') {
613
677
  return true;
@@ -620,7 +684,7 @@ export default function SimpleTableManual(props: PropsWithChildren<SimpleTableMa
620
684
  }
621
685
 
622
686
  function results() {
623
- const len = editableMode ? elements.length : rowData.length;
687
+ const len = editableMode ? elements?.length : rowData?.length;
624
688
 
625
689
  return len ? (
626
690
  <span style={{ fontSize: '0.9em', opacity: '0.7' }}>
@@ -629,6 +693,10 @@ export default function SimpleTableManual(props: PropsWithChildren<SimpleTableMa
629
693
  ) : null;
630
694
  }
631
695
 
696
+ if (!rawFields) {
697
+ return null;
698
+ }
699
+
632
700
  return (
633
701
  <>
634
702
  <TableContainer component={Paper} style={{ margin: '4px 0px' }} id="simple-table-manual">
@@ -647,7 +715,7 @@ export default function SimpleTableManual(props: PropsWithChildren<SimpleTableMa
647
715
  }
648
716
  return (
649
717
  <TableCell key={`head-${displayedColumns[index]}`} className={classes.tableCell}>
650
- {(readOnlyMode || allowEditingInModal) && field.cellRenderer !== 'DeleteIcon' ? (
718
+ {(readOnlyMode || allowEditingInModal || hideEditRow) && field.cellRenderer !== 'DeleteIcon' ? (
651
719
  <div style={{ display: 'flex' }}>
652
720
  <TableSortLabel
653
721
  style={{ width: '75%' }}
@@ -682,11 +750,12 @@ export default function SimpleTableManual(props: PropsWithChildren<SimpleTableMa
682
750
  <TableBody>
683
751
  {editableMode &&
684
752
  !allowEditingInModal &&
753
+ !hideEditRow &&
685
754
  elements.map((row: any, index) => {
686
755
  const theKey = `row-${index}`;
687
756
  return (
688
757
  <TableRow key={theKey}>
689
- {row.map((item, childIndex) => {
758
+ {row?.map((item, childIndex) => {
690
759
  const theColKey = `data-${index}-${childIndex}`;
691
760
  return (
692
761
  <TableCell key={theColKey} className={classes.tableCell}>
@@ -696,66 +765,71 @@ export default function SimpleTableManual(props: PropsWithChildren<SimpleTableMa
696
765
  })}
697
766
  {showDeleteButton && (
698
767
  <TableCell>
699
- <button
700
- type="button"
701
- className="psdk-utility-button"
702
- id="delete-button"
703
- aria-label="Delete Cell"
704
- onClick={() => deleteRecordFromInlineEditable(index)}
705
- >
706
- <img className="psdk-utility-card-action-svg-icon" src={menuIconOverride$} />
707
- </button>
768
+ {isDeleteAllowedForRow(index) && (
769
+ <button
770
+ type="button"
771
+ className="psdk-utility-button"
772
+ id="delete-button"
773
+ aria-label="Delete Cell"
774
+ onClick={() => deleteRecordFromInlineEditable(index)}
775
+ >
776
+ <img className="psdk-utility-card-action-svg-icon" src={menuIconOverride$} />
777
+ </button>
778
+ )}
708
779
  </TableCell>
709
780
  )}
710
781
  </TableRow>
711
782
  );
712
783
  })}
713
- {(readOnlyMode || allowEditingInModal) &&
784
+ {(readOnlyMode || allowEditingInModal || hideEditRow) &&
714
785
  rowData &&
715
786
  rowData.length > 0 &&
716
- stableSort(rowData, getComparator(order, orderBy))
717
- .slice(0)
718
- .map((row, index) => {
719
- return (
720
- <TableRow key={index}>
721
- {row.map((item, childIndex) => {
722
- const theColKey = displayedColumns[childIndex];
723
- return (
724
- <TableCell key={theColKey} className={classes.tableCell}>
725
- {item}
726
- </TableCell>
727
- );
728
- })}
729
- {showDeleteButton && (
730
- <TableCell key="DeleteIcon" className={classes.tableCell}>
731
- <div>
732
- <MoreIcon
733
- id="table-edit-menu-icon"
734
- className={classes.moreIcon}
735
- onClick={(event) => {
736
- editMenuClick(event, index);
737
- }}
738
- />
739
- <Menu
740
- id="table-edit-menu"
741
- anchorEl={editAnchorEl}
742
- keepMounted
743
- open={Boolean(editAnchorEl)}
744
- onClose={_menuClose}
745
- >
746
- <MenuItem onClick={() => editRecord()}>Edit</MenuItem>
747
- <MenuItem onClick={() => deleteRecord()}>Delete</MenuItem>
748
- </Menu>
749
- </div>
787
+ stableSort(rowData, getComparator(order, orderBy)).map((row: any, displayIndex) => {
788
+ const originalIndex = row.__originalIndex;
789
+ return (
790
+ <TableRow key={displayIndex}>
791
+ {(elements as any[])[originalIndex]?.map((item, childIndex) => {
792
+ const theColKey = displayedColumns[childIndex];
793
+ return (
794
+ <TableCell key={theColKey} className={classes.tableCell}>
795
+ {item}
750
796
  </TableCell>
751
- )}
752
- </TableRow>
753
- );
754
- })}
797
+ );
798
+ })}
799
+ {(showDeleteButton || showEditButton) && (
800
+ <TableCell key="DeleteIcon" className={classes.tableCell}>
801
+ <div>
802
+ <MoreIcon
803
+ id="table-edit-menu-icon"
804
+ className={classes.moreIcon}
805
+ onClick={(event) => {
806
+ editMenuClick(event, originalIndex);
807
+ }}
808
+ />
809
+ <Menu
810
+ id="table-edit-menu"
811
+ anchorEl={editAnchorEl}
812
+ keepMounted
813
+ open={Boolean(editAnchorEl)}
814
+ onClose={_menuClose}
815
+ >
816
+ {showEditButton && <MenuItem onClick={() => editRecord()}>Edit</MenuItem>}
817
+ {isDeleteAllowedForRow(originalIndex) && (
818
+ <MenuItem onClick={() => deleteRecord()}>Delete</MenuItem>
819
+ )}
820
+ </Menu>
821
+ </div>
822
+ </TableCell>
823
+ )}
824
+ </TableRow>
825
+ );
826
+ })}
755
827
  </TableBody>
756
828
  </Table>
757
829
  {((readOnlyMode && (!rowData || rowData?.length === 0)) ||
758
- (editableMode && (!referenceList || referenceList?.length === 0))) && (
830
+ (editableMode && !hideEditRow && (!referenceList || referenceList?.length === 0)) ||
831
+ (allowEditingInModal && (!rowData || rowData?.length === 0)) ||
832
+ (hideEditRow && (!rowData || rowData?.length === 0))) && (
759
833
  <div className="no-records" id="no-records">
760
834
  {getGenericFieldsLocalizedValue('COSMOSFIELDS.lists', 'No records found.')}
761
835
  </div>
@@ -764,7 +838,7 @@ export default function SimpleTableManual(props: PropsWithChildren<SimpleTableMa
764
838
  {showAddRowButton && (
765
839
  <div style={{ fontSize: '1rem' }}>
766
840
  <Link style={{ cursor: 'pointer' }} onClick={addRecord} underline="hover">
767
- + {localizedVal('Add', localeCategory)}
841
+ + {localizedVal(addLabel, localeCategory)}
768
842
  </Link>
769
843
  </div>
770
844
  )}