@evoke-platform/ui-components 1.11.1-dev.3 → 1.11.1-dev.4

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.
@@ -4,7 +4,7 @@ import { FieldValues, SubmitErrorHandler } from 'react-hook-form';
4
4
  import { BodyProps } from './components/Body';
5
5
  import { FooterProps } from './components/Footer';
6
6
  import { HeaderProps } from './components/Header';
7
- import { BaseProps, Document, SimpleEditorProps } from './components/types';
7
+ import { BaseProps, SimpleEditorProps } from './components/types';
8
8
  import ValidationErrors from './components/ValidationFiles/ValidationErrors';
9
9
  export type FormRendererProps = BaseProps & {
10
10
  richTextEditor?: ComponentType<SimpleEditorProps>;
@@ -15,7 +15,7 @@ export type FormRendererProps = BaseProps & {
15
15
  fieldHeight?: 'small' | 'medium';
16
16
  form: EvokeForm;
17
17
  title?: string | React.ReactNode;
18
- instance?: ObjectInstance | Document;
18
+ instance?: ObjectInstance;
19
19
  onChange: (id: string, value: unknown) => void | Promise<void>;
20
20
  onAutosave?: (fieldId: string) => void | Promise<void>;
21
21
  associatedObject?: {
@@ -8,7 +8,7 @@ import { Body } from './components/Body';
8
8
  import { Footer, FooterActions } from './components/Footer';
9
9
  import { FormContext } from './components/FormContext';
10
10
  import Header, { AccordionActions, Title } from './components/Header';
11
- import { assignIdsToSectionsAndRichText, convertDocToParameters, convertPropertiesToParams, entryIsVisible, getEntryId, getNestedParameterIds, isAddressProperty, obfuscateValue, } from './components/utils';
11
+ import { assignIdsToSectionsAndRichText, convertPropertiesToParams, entryIsVisible, getEntryId, getNestedParameterIds, isAddressProperty, obfuscateValue, } from './components/utils';
12
12
  import { handleValidation } from './components/ValidationFiles/Validation';
13
13
  import ValidationErrors from './components/ValidationFiles/ValidationErrors';
14
14
  const FormRendererInternal = (props) => {
@@ -55,10 +55,7 @@ const FormRendererInternal = (props) => {
55
55
  const action = object?.actions?.find((a) => a.id === actionId);
56
56
  setObject(object);
57
57
  setAction(action);
58
- if (form.id === 'documentForm') {
59
- setParameters(convertDocToParameters(instance));
60
- }
61
- else if (action?.parameters) {
58
+ if (action?.parameters) {
62
59
  setParameters(action.parameters);
63
60
  }
64
61
  else if (object) {
@@ -244,9 +241,7 @@ const FormRendererInternal = (props) => {
244
241
  expandedSections,
245
242
  hasAccordions: hasSections && isSmallerThanMd,
246
243
  } })),
247
- (action || form.id === 'documentForm') &&
248
- onSubmit &&
249
- (renderFooter ? renderFooter(footerProps) : React.createElement(Footer, { ...footerProps }))))));
244
+ action && onSubmit && (renderFooter ? renderFooter(footerProps) : React.createElement(Footer, { ...footerProps }))))));
250
245
  };
251
246
  export const FormRenderer = Object.assign(FormRendererInternal, {
252
247
  Header,
@@ -18,8 +18,7 @@ export type FormRendererContainerProps = BaseProps & {
18
18
  instanceId?: string;
19
19
  defaultPages?: Record<string, string>;
20
20
  pageNavigation?: string;
21
- documentId?: string;
22
- dataType?: 'documents' | 'objectInstances';
21
+ dataType?: 'objectInstances';
23
22
  display?: {
24
23
  fieldHeight?: 'small' | 'medium';
25
24
  };
@@ -7,18 +7,16 @@ import { Box } from '../../layout';
7
7
  import ErrorComponent from '../ErrorComponent';
8
8
  import { evalDefaultVals, processValueUpdate } from './components/DefaultValues';
9
9
  import Header from './components/Header';
10
- import { convertDocToEntries, convertPropertiesToParams, deleteDocuments, encodePageSlug, formatDataToDoc, formatSubmission, getEntryId, getPrefixedUrl, getUnnestedEntries, isAddressProperty, isEmptyWithDefault, plainTextToRtf, } from './components/utils';
10
+ import { convertPropertiesToParams, deleteDocuments, encodePageSlug, formatSubmission, getEntryId, getPrefixedUrl, getUnnestedEntries, isAddressProperty, isEmptyWithDefault, plainTextToRtf, } from './components/utils';
11
11
  import FormRenderer from './FormRenderer';
12
12
  function FormRendererContainer(props) {
13
- const { instanceId, pageNavigation, documentId, dataType, display, formId, objectId, actionId, richTextEditor, onSubmit, onDiscardChanges: onDiscardChangesOverride, associatedObject, renderContainer, onSubmitError, sx, renderHeader, renderBody, renderFooter, } = props;
13
+ const { instanceId, pageNavigation, dataType, display, formId, objectId, actionId, richTextEditor, onSubmit, onDiscardChanges: onDiscardChangesOverride, associatedObject, renderContainer, onSubmitError, sx, renderHeader, renderBody, renderFooter, } = props;
14
14
  const apiServices = useApiServices();
15
15
  const navigateTo = useNavigate();
16
16
  const { id: appId } = useApp();
17
- const [hasDocumentUpdateAccess, setHasDocumentUpdateAccess] = useState();
18
17
  const [sanitizedObject, setSanitizedObject] = useState();
19
18
  const [navigationSlug, setNavigationSlug] = useState();
20
19
  const [parameters, setParameters] = useState();
21
- const [document, setDocument] = useState();
22
20
  const [instance, setInstance] = useState();
23
21
  const formDataRef = useRef();
24
22
  // We only need the setter to force a re-render when form data updates; the value itself
@@ -58,41 +56,29 @@ function FormRendererContainer(props) {
58
56
  useEffect(() => {
59
57
  (async () => {
60
58
  try {
61
- if (dataType === 'documents') {
62
- const object = await objectStore.get({ sanitized: true });
63
- const document = await apiServices.get(getPrefixedUrl(`/objects/${objectId}/instances/${instanceId}/documents/${documentId}`));
64
- if (document) {
65
- setDocument(document);
66
- const accessCheck = await apiServices.get(getPrefixedUrl(`/objects/${objectId}/instances/${instanceId}/documents/${documentId}/checkAccess?action=update`));
67
- setHasDocumentUpdateAccess(accessCheck.result);
68
- }
69
- setSanitizedObject(omit(object, 'properties'));
59
+ if (instanceId) {
60
+ const instance = await objectStore.getInstance(instanceId);
61
+ setInstance(instance);
62
+ }
63
+ const object = await apiServices.get(getPrefixedUrl(`/objects/${form?.objectId || objectId}${instanceId ? `/instances/${instanceId}/object` : '/effective'}`), { params: { sanitizedVersion: true } });
64
+ setSanitizedObject(object);
65
+ const action = object?.actions?.find((a) => a.id === (form?.actionId || actionId));
66
+ if (action && (instanceId || action.type === 'create')) {
67
+ setAction(action);
68
+ // Clear error if action is found after being missing
69
+ // TODO: This entire effect should take place after form is fetched to avoid an error flickering
70
+ // That is, this effect should be merged with the one below that fetches the form
71
+ setError((prevError) => prevError === 'Action could not be found' ? undefined : prevError);
70
72
  }
71
73
  else {
72
- if (instanceId) {
73
- const instance = await objectStore.getInstance(instanceId);
74
- setInstance(instance);
75
- }
76
- const object = await apiServices.get(getPrefixedUrl(`/objects/${form?.objectId || objectId}${instanceId ? `/instances/${instanceId}/object` : '/effective'}`), { params: { sanitizedVersion: true } });
77
- setSanitizedObject(object);
78
- const action = object?.actions?.find((a) => a.id === (form?.actionId || actionId));
79
- if (action && (instanceId || action.type === 'create')) {
80
- setAction(action);
81
- // Clear error if action is found after being missing
82
- // TODO: This entire effect should take place after form is fetched to avoid an error flickering
83
- // That is, this effect should be merged with the one below that fetches the form
84
- setError((prevError) => prevError === 'Action could not be found' ? undefined : prevError);
85
- }
86
- else {
87
- setError('Action could not be found');
88
- }
74
+ setError('Action could not be found');
89
75
  }
90
76
  }
91
77
  catch (error) {
92
78
  onError(error);
93
79
  }
94
80
  })();
95
- }, [dataType, form, instanceId, documentId]);
81
+ }, [dataType, form, instanceId]);
96
82
  useEffect(() => {
97
83
  if (pageNavigation) {
98
84
  apiServices
@@ -106,9 +92,7 @@ function FormRendererContainer(props) {
106
92
  const needsInstance = action?.type !== 'create' && !!instanceId;
107
93
  // Instance and Action are loaded in the side effect above; wait for them to complete.
108
94
  const loading = (actionId && !action) || (needsInstance && !instance);
109
- if (dataType === 'documents' || form)
110
- return;
111
- if (loading)
95
+ if (form || loading)
112
96
  return;
113
97
  if ((formId || action?.defaultFormId) && formId !== '_auto_') {
114
98
  apiServices
@@ -157,21 +141,7 @@ function FormRendererContainer(props) {
157
141
  }, [form, action?.parameters, sanitizedObject]);
158
142
  useEffect(() => {
159
143
  const getInitialValues = async () => {
160
- if (document && objectId) {
161
- const defaultValues = await getDefaultValues(convertDocToEntries(document), document);
162
- setFormData(defaultValues);
163
- // Deep clone to avoid reference issues
164
- setLastSavedData(cloneDeep(defaultValues));
165
- if (!form) {
166
- setForm({
167
- id: 'documentForm',
168
- name: 'Document Form',
169
- entries: convertDocToEntries(document),
170
- objectId: objectId,
171
- });
172
- }
173
- }
174
- else if (form && (instance || !instanceId)) {
144
+ if (form && (instance || !instanceId)) {
175
145
  const defaultValues = await getDefaultValues(form.entries, instance || {});
176
146
  setFormData(defaultValues);
177
147
  // Deep clone to avoid reference issues
@@ -187,12 +157,7 @@ function FormRendererContainer(props) {
187
157
  isError: false,
188
158
  });
189
159
  if (navigationSlug) {
190
- if (navigationSlug.includes(':instanceId') && navigationSlug.includes(':documentId')) {
191
- navigateTo(`/${appId}/${navigationSlug
192
- .replace(':instanceId', instanceId ?? ':instanceId')
193
- .replace(':documentId', documentId ?? ':documentId')}`);
194
- }
195
- else if (navigationSlug.includes(':instanceId')) {
160
+ if (navigationSlug.includes(':instanceId')) {
196
161
  const navigateInstanceId = action?.type === 'create' ? updatedInstance?.id : instanceId;
197
162
  navigateTo(`/${appId}/${navigationSlug.replace(':instanceId', navigateInstanceId ?? ':instanceId')}`);
198
163
  }
@@ -206,23 +171,8 @@ function FormRendererContainer(props) {
206
171
  if (!form)
207
172
  return;
208
173
  submission = await formatSubmission(submission, apiServices, objectId, instanceId, form, setSnackbarError);
209
- if (document) {
210
- submission = formatDataToDoc(submission);
211
- }
212
174
  try {
213
- if (dataType === 'documents' && !!document) {
214
- await apiServices.patch(getPrefixedUrl(`/objects/${form.objectId}/instances/${instanceId}/documents/${documentId}`), pick(submission, ['metadata']).metadata ?? submission);
215
- setDocument((prev) => ({
216
- ...prev,
217
- metadata: submission.metadata,
218
- }));
219
- setSnackbarError({
220
- showAlert: true,
221
- message: 'Your changes have been submitted',
222
- isError: false,
223
- });
224
- }
225
- else if (action?.type === 'create') {
175
+ if (action?.type === 'create') {
226
176
  const response = await apiServices.post(getPrefixedUrl(`/objects/${form.objectId}/instances/actions`), {
227
177
  actionId: form.actionId,
228
178
  input: omit(submission, sanitizedObject?.properties
@@ -263,12 +213,12 @@ function FormRendererContainer(props) {
263
213
  const result = {};
264
214
  const unnestedEntries = getUnnestedEntries(entries);
265
215
  for (const entry of unnestedEntries) {
216
+ const fieldId = getEntryId(entry);
217
+ if (!fieldId)
218
+ continue;
219
+ const fieldValue = get(instanceData, fieldId);
266
220
  if ((entry.type === 'input' || entry.type === 'inputField') &&
267
221
  isAddressProperty(entry.parameterId || entry.input?.id)) {
268
- const fieldId = getEntryId(entry);
269
- if (!fieldId)
270
- continue;
271
- const fieldValue = get(instanceData, fieldId);
272
222
  if ((isEmpty(instanceData) || fieldValue === undefined || fieldValue === null || fieldValue === '') &&
273
223
  entry?.display?.defaultValue &&
274
224
  parameters) {
@@ -284,56 +234,47 @@ function FormRendererContainer(props) {
284
234
  }
285
235
  }
286
236
  else if (entry.type !== 'sections' && entry.type !== 'columns' && entry.type !== 'content') {
287
- const fieldId = entry.type === 'input'
288
- ? entry.parameterId
289
- : entry.type === 'inputField'
290
- ? entry.input?.id
291
- : undefined;
292
- if (fieldId) {
293
- const fieldValue = instanceData?.[fieldId] ??
294
- instanceData?.metadata?.[fieldId];
295
- const parameter = parameters?.find((param) => param.id === fieldId);
296
- if (associatedObject?.propertyId === fieldId &&
297
- associatedObject?.instanceId &&
298
- parameter &&
299
- action?.type === 'create') {
300
- try {
301
- const instance = await apiServices.get(getPrefixedUrl(`/objects/${parameter.objectId}/instances/${associatedObject.instanceId}`));
302
- result[associatedObject.propertyId] = instance;
303
- }
304
- catch (error) {
305
- console.error(error);
306
- }
237
+ const parameter = parameters?.find((param) => param.id === fieldId);
238
+ if (associatedObject?.propertyId === fieldId &&
239
+ associatedObject?.instanceId &&
240
+ parameter &&
241
+ action?.type === 'create') {
242
+ try {
243
+ const instance = await apiServices.get(getPrefixedUrl(`/objects/${parameter.objectId}/instances/${associatedObject.instanceId}`));
244
+ result[associatedObject.propertyId] = instance;
307
245
  }
308
- else if (entry.type !== 'readonlyField' && isEmptyWithDefault(fieldValue, entry, instanceData)) {
309
- if (fieldId && parameters && parameters.length > 0) {
310
- const defaultValuesArray = await evalDefaultVals(parameters, unnestedEntries, entry, fieldValue, fieldId, apiServices, userAccount, instanceData);
311
- for (const { fieldId, fieldValue } of defaultValuesArray) {
312
- const parameter = parameters?.find((param) => param.id === fieldId);
313
- if (parameter?.type === 'object') {
314
- const dependentFields = await processValueUpdate(unnestedEntries, parameters, fieldValue, apiServices, fieldId, formDataRef.current, userAccount);
315
- for (const field of dependentFields) {
316
- set(result, field.fieldId, field.fieldValue);
317
- }
246
+ catch (error) {
247
+ console.error(error);
248
+ }
249
+ }
250
+ else if (entry.type !== 'readonlyField' && isEmptyWithDefault(fieldValue, entry, instanceData)) {
251
+ if (fieldId && parameters && parameters.length > 0) {
252
+ const defaultValuesArray = await evalDefaultVals(parameters, unnestedEntries, entry, fieldValue, fieldId, apiServices, userAccount, instanceData);
253
+ for (const { fieldId, fieldValue } of defaultValuesArray) {
254
+ const parameter = parameters?.find((param) => param.id === fieldId);
255
+ if (parameter?.type === 'object') {
256
+ const dependentFields = await processValueUpdate(unnestedEntries, parameters, fieldValue, apiServices, fieldId, formDataRef.current, userAccount);
257
+ for (const field of dependentFields) {
258
+ set(result, field.fieldId, field.fieldValue);
318
259
  }
319
- set(result, fieldId, fieldValue);
320
260
  }
261
+ set(result, fieldId, fieldValue);
321
262
  }
322
263
  }
323
- else if (parameter?.type === 'boolean' && (fieldValue === undefined || fieldValue === null)) {
324
- result[fieldId] = false;
325
- }
326
- else if (fieldValue !== undefined && fieldValue !== null) {
327
- if (parameter?.type === 'richText' && typeof fieldValue === 'string') {
328
- let RTFFieldValue = fieldValue;
329
- if (!fieldValue.trim().startsWith('{\\rtf')) {
330
- RTFFieldValue = plainTextToRtf(fieldValue);
331
- }
332
- result[fieldId] = RTFFieldValue;
333
- }
334
- else {
335
- result[fieldId] = fieldValue;
264
+ }
265
+ else if (parameter?.type === 'boolean' && (fieldValue === undefined || fieldValue === null)) {
266
+ result[fieldId] = false;
267
+ }
268
+ else if (fieldValue !== undefined && fieldValue !== null) {
269
+ if (parameter?.type === 'richText' && typeof fieldValue === 'string') {
270
+ let RTFFieldValue = fieldValue;
271
+ if (!fieldValue.trim().startsWith('{\\rtf')) {
272
+ RTFFieldValue = plainTextToRtf(fieldValue);
336
273
  }
274
+ result[fieldId] = RTFFieldValue;
275
+ }
276
+ else {
277
+ result[fieldId] = fieldValue;
337
278
  }
338
279
  }
339
280
  }
@@ -369,16 +310,8 @@ function FormRendererContainer(props) {
369
310
  setIsSaving(true);
370
311
  const cleanedData = removeUneditedProtectedValues(formDataRef.current);
371
312
  const submission = await formatSubmission(cleanedData, apiServices, objectId, instanceId, form, setSnackbarError);
372
- // Handle document autosave
373
- if (dataType === 'documents' && document) {
374
- await apiServices.patch(getPrefixedUrl(`/objects/${objectId}/instances/${instanceId}/documents/${documentId}`), pick(submission, ['metadata']).metadata ?? submission);
375
- setDocument((prev) => ({
376
- ...prev,
377
- metadata: submission.metadata,
378
- }));
379
- }
380
313
  // Handle object instance autosave
381
- else if (instanceId && action?.type === 'update') {
314
+ if (instanceId && action?.type === 'update') {
382
315
  await apiServices.post(getPrefixedUrl(`/objects/${objectId}/instances/${instanceId}/actions`), {
383
316
  actionId: form.autosaveActionId,
384
317
  input: pick(submission, sanitizedObject?.properties
@@ -423,7 +356,7 @@ function FormRendererContainer(props) {
423
356
  setFormData(newData);
424
357
  }
425
358
  }
426
- const isLoading = (instanceId && !formDataRef.current && !document) || !form || !sanitizedObject;
359
+ const isLoading = (instanceId && !formDataRef.current) || !form || !sanitizedObject;
427
360
  const status = error ? 'error' : isLoading ? 'loading' : 'ready';
428
361
  // Compose a header renderer that injects the saving indicator into the rendered header
429
362
  const composedRenderHeader = (props) => {
@@ -435,11 +368,7 @@ function FormRendererContainer(props) {
435
368
  const onDiscardChanges = onDiscardChangesOverride
436
369
  ? onDiscardChangesOverride
437
370
  : async () => {
438
- if (document) {
439
- const defaultValues = await getDefaultValues(convertDocToEntries(document), document);
440
- setFormData(defaultValues);
441
- }
442
- else if (form) {
371
+ if (form) {
443
372
  const defaultValues = await getDefaultValues(form.entries, instance || {});
444
373
  setFormData(defaultValues);
445
374
  }
@@ -451,7 +380,7 @@ function FormRendererContainer(props) {
451
380
  border: !isLoading ? '1px solid #dbe0e4' : undefined,
452
381
  ...sx,
453
382
  } }, !isLoading ? (React.createElement(React.Fragment, null,
454
- React.createElement(FormRenderer, { onSubmit: onSubmit ? (data) => onSubmit(data, saveHandler) : saveHandler, onSubmitError: onSubmitError, onDiscardChanges: onDiscardChanges, richTextEditor: richTextEditor, fieldHeight: display?.fieldHeight ?? 'medium', value: formDataRef.current, form: form, instance: dataType !== 'documents' ? instance : document, onChange: onChange, onAutosave: onAutosave, associatedObject: associatedObject, renderHeader: composedRenderHeader, renderBody: renderBody, renderFooter: document && !hasDocumentUpdateAccess ? () => React.createElement(React.Fragment, null) : renderFooter }))) : (React.createElement(Box, { sx: { padding: '20px' } },
383
+ React.createElement(FormRenderer, { onSubmit: onSubmit ? (data) => onSubmit(data, saveHandler) : saveHandler, onSubmitError: onSubmitError, onDiscardChanges: onDiscardChanges, richTextEditor: richTextEditor, fieldHeight: display?.fieldHeight ?? 'medium', value: formDataRef.current, form: form, instance: instance, onChange: onChange, onAutosave: onAutosave, associatedObject: associatedObject, renderHeader: composedRenderHeader, renderBody: renderBody, renderFooter: renderFooter }))) : (React.createElement(Box, { sx: { padding: '20px' } },
455
384
  React.createElement(Box, { display: 'flex', width: '100%', justifyContent: 'space-between' },
456
385
  React.createElement(Skeleton, { width: '78%', sx: { borderRadius: '8px', height: '40px' } }),
457
386
  React.createElement(Skeleton, { width: '20%', sx: { borderRadius: '8px', height: '40px' } })),
@@ -38,7 +38,7 @@ function getFieldWrapperProps(fieldDefinition, entry, entryId, fieldValue, displ
38
38
  }
39
39
  export function RecursiveEntryRenderer(props) {
40
40
  const { entry } = props;
41
- const { fetchedOptions, setFetchedOptions, object, getValues, errors, instance, richTextEditor: RichTextEditor, parameters, handleChange, onAutosave, fieldHeight, triggerFieldReset, associatedObject, form, width, } = useFormContext();
41
+ const { fetchedOptions, setFetchedOptions, object, getValues, errors, instance, richTextEditor: RichTextEditor, parameters, handleChange, onAutosave, fieldHeight, triggerFieldReset, associatedObject, width, } = useFormContext();
42
42
  const { isBelow, breakpoints } = useWidgetSize({
43
43
  scroll: false,
44
44
  defaultWidth: width,
@@ -55,7 +55,7 @@ export function RecursiveEntryRenderer(props) {
55
55
  const fieldDefinition = useMemo(() => {
56
56
  if (!object)
57
57
  return undefined;
58
- return getFieldDefinition(entry, object, parameters, form?.id === 'documentForm');
58
+ return getFieldDefinition(entry, object, parameters);
59
59
  }, [entry, parameters, object]);
60
60
  const validation = fieldDefinition?.validation || {};
61
61
  useEffect(() => {
@@ -97,16 +97,6 @@ export type SectionsProps = {
97
97
  entry: ExpandedSections;
98
98
  readOnly?: boolean;
99
99
  };
100
- export type DocumentData = {
101
- id: string;
102
- name: string;
103
- contentType: string;
104
- size: number;
105
- uploadedDate: string;
106
- versionId: string;
107
- type: string;
108
- view_permission: string;
109
- };
110
100
  export type RichTextFormEntry = FormEntry & {
111
101
  uniqueId: string;
112
102
  };
@@ -4,7 +4,7 @@ import { LocalDateTime } from '@js-joda/core';
4
4
  import { FieldErrors, FieldValues } from 'react-hook-form';
5
5
  import { ObjectProperty } from '../../../../types';
6
6
  import { AutocompleteOption } from '../../../core';
7
- import { Document, DocumentData, SavedDocumentReference } from './types';
7
+ import { SavedDocumentReference } from './types';
8
8
  export declare const scrollIntoViewWithOffset: (el: HTMLElement, offset: number, container?: HTMLElement) => void;
9
9
  export declare const normalizeDateTime: (dateTime: LocalDateTime) => string;
10
10
  export declare function isAddressProperty(key: string): boolean;
@@ -43,23 +43,9 @@ export declare function getDefaultPages(parameters: InputParameter[], defaultPag
43
43
  export declare function updateCriteriaInputs(criteria: Record<string, unknown>, data: Record<string, unknown>, user?: UserAccount): Record<string, unknown>;
44
44
  export declare function fetchCollectionData(apiServices: ApiServices, fieldDefinition: InputParameter | Property, setFetchedOptions: (newData: FieldValues) => void, instanceId?: string, fetchedOptions?: Record<string, unknown>, initialMiddleObjectInstances?: ObjectInstance[]): Promise<void>;
45
45
  export declare const getErrorCountForSection: (section: Section | Column, errors?: FieldErrors) => number;
46
- export declare const convertDocToParameters: (obj: Document) => InputParameter[];
47
46
  export declare const propertyToParameter: (property: Property) => InputParameter;
48
47
  export declare const propertyValidationToParameterValidation: (property: Property) => InputParameter['validation'];
49
48
  export declare const convertPropertiesToParams: (object: Obj) => InputParameter[] | undefined;
50
- export declare function convertDocToEntries(document: Document): FormEntry[];
51
- export declare function formatDataToDoc(data: DocumentData): {
52
- id: string;
53
- name: string;
54
- contentType: string;
55
- size: number;
56
- uploadedDate: string;
57
- versionId: string;
58
- metadata: {
59
- type: string;
60
- view_permission: string;
61
- };
62
- };
63
49
  export declare function getUnnestedEntries(entries: FormEntry[]): FormEntry[];
64
50
  export declare const isEmptyWithDefault: (fieldValue: unknown, entry: InputParameterReference | InputField, instance: Record<string, unknown> | object) => boolean | "" | 0 | undefined;
65
51
  export declare const docProperties: Property[];
@@ -105,5 +91,5 @@ export declare function assignIdsToSectionsAndRichText(entries: FormEntry[], obj
105
91
  * This ensures that any plain text input will be safely represented in RTF without losing formatting or characters.
106
92
  */
107
93
  export declare function plainTextToRtf(plainText: string): string;
108
- export declare function getFieldDefinition(entry: FormEntry, object: Obj, parameters?: InputParameter[], isDocument?: boolean): InputParameter | Property | undefined;
94
+ export declare function getFieldDefinition(entry: FormEntry, object: Obj, parameters?: InputParameter[]): InputParameter | Property | undefined;
109
95
  export declare function obfuscateValue(value: unknown, property?: Partial<Property> | Partial<ObjectProperty>): unknown;
@@ -377,27 +377,6 @@ export const getErrorCountForSection = (section, errors) => {
377
377
  }, 0)
378
378
  : 0;
379
379
  };
380
- // to convert the properties of the current instances doc into a mappable object
381
- export const convertDocToParameters = (obj) => {
382
- return Object.entries(obj).flatMap(([key, value]) => {
383
- if (key === 'metadata') {
384
- return [
385
- {
386
- id: 'type',
387
- name: 'Type',
388
- type: 'string',
389
- },
390
- {
391
- id: 'view_permission',
392
- name: 'View Permission',
393
- type: 'string',
394
- enum: ['Public', 'Private', 'Portal'],
395
- },
396
- ];
397
- }
398
- return [];
399
- });
400
- };
401
380
  export const propertyToParameter = (property) => {
402
381
  return {
403
382
  ...omit(property, ['searchable', 'formula', 'formulaType', 'mask', 'textTransform']),
@@ -438,86 +417,6 @@ export const convertPropertiesToParams = (object) => {
438
417
  .sort((a, b) => a.name.localeCompare(b.name))
439
418
  .map(propertyToParameter);
440
419
  };
441
- export function convertDocToEntries(document) {
442
- const entries = [
443
- {
444
- type: 'readonlyField',
445
- propertyId: 'id',
446
- display: {
447
- label: 'Id',
448
- },
449
- },
450
- {
451
- type: 'readonlyField',
452
- propertyId: 'name',
453
- display: {
454
- label: 'Name',
455
- },
456
- },
457
- {
458
- type: 'readonlyField',
459
- propertyId: 'contentType',
460
- display: {
461
- label: 'Content Type',
462
- },
463
- },
464
- {
465
- type: 'readonlyField',
466
- propertyId: 'size',
467
- display: {
468
- label: 'Size',
469
- },
470
- },
471
- {
472
- type: 'readonlyField',
473
- propertyId: 'uploadedDate',
474
- display: {
475
- label: 'Uploaded Date',
476
- },
477
- },
478
- ];
479
- if (!isEmpty(document.metadata)) {
480
- entries.push({
481
- type: 'input',
482
- parameterId: 'type',
483
- display: {
484
- label: 'Type',
485
- },
486
- }, {
487
- type: 'input',
488
- parameterId: 'view_permission',
489
- display: {
490
- label: 'View Permission',
491
- choicesDisplay: {
492
- type: 'dropdown',
493
- sortBy: 'ASC',
494
- },
495
- },
496
- });
497
- }
498
- entries.push({
499
- type: 'readonlyField',
500
- propertyId: 'versionId',
501
- display: {
502
- label: 'Version Id',
503
- },
504
- });
505
- return entries;
506
- }
507
- export function formatDataToDoc(data) {
508
- return {
509
- id: data.id,
510
- name: data.name,
511
- contentType: data.contentType,
512
- size: data.size,
513
- uploadedDate: data.uploadedDate,
514
- versionId: data.versionId,
515
- metadata: {
516
- type: data.type ?? '',
517
- view_permission: data.view_permission ?? '',
518
- },
519
- };
520
- }
521
420
  export function getUnnestedEntries(entries) {
522
421
  return entries?.flatMap((entry) => {
523
422
  if (entry.type === 'columns' && isArray(entry.columns)) {
@@ -821,17 +720,15 @@ export function plainTextToRtf(plainText) {
821
720
  });
822
721
  return `{\\rtf1\\ansi\\deff0 {\\fonttbl {\\f0 Calibri;}} \\f0\\fs22 ${escaped}}`;
823
722
  }
824
- export function getFieldDefinition(entry, object, parameters, isDocument) {
723
+ export function getFieldDefinition(entry, object, parameters) {
825
724
  let def;
826
725
  if (entry.type === 'input') {
827
726
  def = parameters?.find((param) => param.id === entry.parameterId);
828
727
  }
829
728
  else if (entry.type === 'readonlyField') {
830
- def = isDocument
831
- ? docProperties.find((prop) => prop.id === entry.propertyId)
832
- : isAddressProperty(entry.propertyId)
833
- ? object.properties?.find((prop) => prop.id === entry.propertyId.split('.')[0])
834
- : object.properties?.find((prop) => prop.id === entry.propertyId);
729
+ def = isAddressProperty(entry.propertyId)
730
+ ? object.properties?.find((prop) => prop.id === entry.propertyId.split('.')[0])
731
+ : object.properties?.find((prop) => prop.id === entry.propertyId);
835
732
  }
836
733
  else if (entry.type === 'inputField') {
837
734
  def = entry.input;
@@ -8,7 +8,7 @@ declare const _default: import("@storybook/types").ComponentAnnotations<import("
8
8
  fieldHeight?: "medium" | "small" | undefined;
9
9
  form: import("@evoke-platform/context").EvokeForm;
10
10
  title?: React.ReactNode;
11
- instance?: import("../components/custom/FormV2/components/types").Document | import("@evoke-platform/context").ObjectInstance | undefined;
11
+ instance?: import("@evoke-platform/context").ObjectInstance | undefined;
12
12
  onChange: (id: string, value: unknown) => void | Promise<void>;
13
13
  onAutosave?: ((fieldId: string) => void | Promise<void>) | undefined;
14
14
  associatedObject?: {
@@ -29,7 +29,7 @@ export declare const Editable: import("@storybook/types").AnnotatedStoryFn<impor
29
29
  fieldHeight?: "medium" | "small" | undefined;
30
30
  form: import("@evoke-platform/context").EvokeForm;
31
31
  title?: React.ReactNode;
32
- instance?: import("../components/custom/FormV2/components/types").Document | import("@evoke-platform/context").ObjectInstance | undefined;
32
+ instance?: import("@evoke-platform/context").ObjectInstance | undefined;
33
33
  onChange: (id: string, value: unknown) => void | Promise<void>;
34
34
  onAutosave?: ((fieldId: string) => void | Promise<void>) | undefined;
35
35
  associatedObject?: {
@@ -49,27 +49,7 @@ export declare const NoButtons: import("@storybook/types").AnnotatedStoryFn<impo
49
49
  fieldHeight?: "medium" | "small" | undefined;
50
50
  form: import("@evoke-platform/context").EvokeForm;
51
51
  title?: React.ReactNode;
52
- instance?: import("../components/custom/FormV2/components/types").Document | import("@evoke-platform/context").ObjectInstance | undefined;
53
- onChange: (id: string, value: unknown) => void | Promise<void>;
54
- onAutosave?: ((fieldId: string) => void | Promise<void>) | undefined;
55
- associatedObject?: {
56
- instanceId: string;
57
- propertyId: string;
58
- } | undefined;
59
- renderHeader?: ((props: import("../components/custom").HeaderProps) => React.ReactNode) | undefined;
60
- renderBody?: ((props: import("../components/custom").BodyProps) => React.ReactNode) | undefined;
61
- renderFooter?: ((props: import("../components/custom").FooterProps) => React.ReactNode) | undefined;
62
- }>;
63
- export declare const DocumentForm: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, import("../components/custom/FormV2/components/types").BaseProps & {
64
- richTextEditor?: React.ComponentType<import("../components/custom/FormV2/components/types").SimpleEditorProps> | undefined;
65
- value?: import("react-hook-form").FieldValues | undefined;
66
- onSubmit?: ((data: import("react-hook-form").FieldValues) => void) | undefined;
67
- onDiscardChanges?: (() => void) | undefined;
68
- onSubmitError?: import("react-hook-form").SubmitErrorHandler<import("react-hook-form").FieldValues> | undefined;
69
- fieldHeight?: "medium" | "small" | undefined;
70
- form: import("@evoke-platform/context").EvokeForm;
71
- title?: React.ReactNode;
72
- instance?: import("../components/custom/FormV2/components/types").Document | import("@evoke-platform/context").ObjectInstance | undefined;
52
+ instance?: import("@evoke-platform/context").ObjectInstance | undefined;
73
53
  onChange: (id: string, value: unknown) => void | Promise<void>;
74
54
  onAutosave?: ((fieldId: string) => void | Promise<void>) | undefined;
75
55
  associatedObject?: {
@@ -4,7 +4,7 @@ import React from 'react';
4
4
  import { MemoryRouter } from 'react-router-dom';
5
5
  import { FormRenderer } from '../components/custom';
6
6
  import { formatSubmission } from '../components/custom/FormV2/components/utils';
7
- import { docFormData, documentInstance, formData, instance, mockDocEvokeForm, mockEvokeForm } from './FormRendererData';
7
+ import { formData, instance, mockEvokeForm } from './FormRendererData';
8
8
  export default {
9
9
  title: 'Custom/FormRenderer',
10
10
  component: FormRenderer,
@@ -29,7 +29,7 @@ const mockProps = {
29
29
  instance: instance,
30
30
  };
31
31
  const Template = (args) => {
32
- const [formDataState, setFormDataState] = React.useState(args.form.id === 'documentForm' ? docFormData : formData);
32
+ const [formDataState, setFormDataState] = React.useState(formData);
33
33
  const handleChange = React.useCallback((field, value) => {
34
34
  setFormDataState((prev) => {
35
35
  const newData = { ...prev };
@@ -49,9 +49,3 @@ NoButtons.args = {
49
49
  ...mockProps,
50
50
  renderFooter: () => null,
51
51
  };
52
- export const DocumentForm = Template.bind({});
53
- DocumentForm.args = {
54
- ...mockProps,
55
- form: mockDocEvokeForm,
56
- instance: documentInstance,
57
- };
@@ -4,8 +4,7 @@ declare const _default: import("@storybook/types").ComponentAnnotations<import("
4
4
  instanceId?: string | undefined;
5
5
  defaultPages?: Record<string, string> | undefined;
6
6
  pageNavigation?: string | undefined;
7
- documentId?: string | undefined;
8
- dataType?: "documents" | "objectInstances" | undefined;
7
+ dataType?: "objectInstances" | undefined;
9
8
  display?: {
10
9
  fieldHeight?: "medium" | "small" | undefined;
11
10
  } | undefined;
@@ -31,8 +30,7 @@ export declare const Editable: import("@storybook/types").AnnotatedStoryFn<impor
31
30
  instanceId?: string | undefined;
32
31
  defaultPages?: Record<string, string> | undefined;
33
32
  pageNavigation?: string | undefined;
34
- documentId?: string | undefined;
35
- dataType?: "documents" | "objectInstances" | undefined;
33
+ dataType?: "objectInstances" | undefined;
36
34
  display?: {
37
35
  fieldHeight?: "medium" | "small" | undefined;
38
36
  } | undefined;
@@ -57,8 +55,7 @@ export declare const DefaultForm: import("@storybook/types").AnnotatedStoryFn<im
57
55
  instanceId?: string | undefined;
58
56
  defaultPages?: Record<string, string> | undefined;
59
57
  pageNavigation?: string | undefined;
60
- documentId?: string | undefined;
61
- dataType?: "documents" | "objectInstances" | undefined;
58
+ dataType?: "objectInstances" | undefined;
62
59
  display?: {
63
60
  fieldHeight?: "medium" | "small" | undefined;
64
61
  } | undefined;
@@ -83,34 +80,7 @@ export declare const NoButtons: import("@storybook/types").AnnotatedStoryFn<impo
83
80
  instanceId?: string | undefined;
84
81
  defaultPages?: Record<string, string> | undefined;
85
82
  pageNavigation?: string | undefined;
86
- documentId?: string | undefined;
87
- dataType?: "documents" | "objectInstances" | undefined;
88
- display?: {
89
- fieldHeight?: "medium" | "small" | undefined;
90
- } | undefined;
91
- actionId?: string | undefined;
92
- objectId: string;
93
- richTextEditor?: React.ComponentType<import("../components/custom/FormV2/components/types").SimpleEditorProps> | undefined;
94
- onSubmit?: ((submission: Record<string, unknown>, defaultSubmitHandler: (submission: Record<string, unknown>) => Promise<void>) => Promise<void>) | undefined;
95
- onDiscardChanges?: (() => void) | undefined;
96
- onSubmitError?: import("react-hook-form").SubmitErrorHandler<import("react-hook-form").FieldValues> | undefined;
97
- associatedObject?: {
98
- instanceId: string;
99
- propertyId: string;
100
- } | undefined;
101
- renderContainer?: ((state: import("../components/custom/FormV2/FormRendererContainer").FormRendererState) => React.ReactNode) | undefined;
102
- renderHeader?: ((props: import("../components/custom").HeaderProps) => React.ReactNode) | undefined;
103
- renderBody?: ((props: import("../components/custom").BodyProps) => React.ReactNode) | undefined;
104
- renderFooter?: ((props: import("../components/custom").FooterProps) => React.ReactNode) | undefined;
105
- sx?: import("@mui/material").SxProps<{}> | undefined;
106
- }>;
107
- export declare const DocumentForm: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, import("../components/custom/FormV2/components/types").BaseProps & {
108
- formId?: string | undefined;
109
- instanceId?: string | undefined;
110
- defaultPages?: Record<string, string> | undefined;
111
- pageNavigation?: string | undefined;
112
- documentId?: string | undefined;
113
- dataType?: "documents" | "objectInstances" | undefined;
83
+ dataType?: "objectInstances" | undefined;
114
84
  display?: {
115
85
  fieldHeight?: "medium" | "small" | undefined;
116
86
  } | undefined;
@@ -135,8 +105,7 @@ export declare const FormWithSections: import("@storybook/types").AnnotatedStory
135
105
  instanceId?: string | undefined;
136
106
  defaultPages?: Record<string, string> | undefined;
137
107
  pageNavigation?: string | undefined;
138
- documentId?: string | undefined;
139
- dataType?: "documents" | "objectInstances" | undefined;
108
+ dataType?: "objectInstances" | undefined;
140
109
  display?: {
141
110
  fieldHeight?: "medium" | "small" | undefined;
142
111
  } | undefined;
@@ -1,9 +1,7 @@
1
1
  import { Box } from '@mui/material';
2
- import { http, HttpResponse } from 'msw';
3
2
  import React from 'react';
4
3
  import { MemoryRouter } from 'react-router-dom';
5
4
  import { FormRenderer, FormRendererContainer } from '../components/custom';
6
- import { documentInstance } from './FormRendererData';
7
5
  import { sharedObjectHandlers } from './sharedMswHandlers';
8
6
  export default {
9
7
  title: 'Custom/FormRendererContainer',
@@ -11,11 +9,7 @@ export default {
11
9
  parameters: {
12
10
  layout: 'fullscreen',
13
11
  msw: {
14
- handlers: [
15
- ...sharedObjectHandlers,
16
- // Document fetch
17
- http.get('api/data/objects/genericEvokeForm/instances/updateGenericEvokeFormInstanceId/documents/documentInstanceId', () => HttpResponse.json(documentInstance)),
18
- ],
12
+ handlers: [sharedObjectHandlers],
19
13
  },
20
14
  },
21
15
  decorators: [
@@ -56,13 +50,6 @@ NoButtons.args = {
56
50
  ...mockProps,
57
51
  renderFooter: () => null,
58
52
  };
59
- export const DocumentForm = Template.bind({});
60
- DocumentForm.args = {
61
- ...mockProps,
62
- formId: 'documentForm',
63
- documentId: 'documentInstanceId',
64
- dataType: 'documents',
65
- };
66
53
  export const FormWithSections = Template.bind({});
67
54
  FormWithSections.args = {
68
55
  ...mockProps,
@@ -1,5 +1,4 @@
1
1
  import { EvokeForm, Obj, ObjectInstance } from '@evoke-platform/context';
2
- import { Document } from '../components/custom/FormV2/components/types';
3
2
  export declare const formData: {
4
3
  name: string;
5
4
  multiSelect: string[];
@@ -8,17 +7,6 @@ export declare const formData: {
8
7
  };
9
8
  };
10
9
  export declare const instance: ObjectInstance;
11
- export declare const documentInstance: Document;
12
- export declare const docFormData: {
13
- id: string;
14
- name: string;
15
- contentType: string;
16
- size: number;
17
- uploadedDate: string;
18
- type: string;
19
- view_permission: string;
20
- versionId: string;
21
- };
22
10
  export declare const mockGenericEvokeFormObject: Obj;
23
11
  export declare const mockMovieObject: Obj;
24
12
  export declare const mockCustomerObject: Obj;
@@ -15,28 +15,6 @@ export const instance = {
15
15
  },
16
16
  objectId: 'genericEvokeForm',
17
17
  };
18
- export const documentInstance = {
19
- id: 'documentInstanceId',
20
- name: 'Document.pdf',
21
- contentType: 'application/pdf',
22
- size: 161596,
23
- metadata: {
24
- type: 'PNG',
25
- view_permission: 'Portal',
26
- },
27
- uploadedDate: '2025-06-24T17:56:49.000Z',
28
- versionId: '2025-06-24T17:56:49.0660713Z',
29
- };
30
- export const docFormData = {
31
- id: 'documentInstanceId',
32
- name: 'Document.pdf',
33
- contentType: 'application/pdf',
34
- size: 161596,
35
- uploadedDate: '2025-06-24T17:56:49.000Z',
36
- type: 'PNG',
37
- view_permission: 'Portal',
38
- versionId: '2025-06-24T17:56:49.0660713Z',
39
- };
40
18
  // Object definitions for FormRenderer and FormRendererContainer stories
41
19
  export const mockGenericEvokeFormObject = {
42
20
  id: 'genericEvokeForm',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evoke-platform/ui-components",
3
- "version": "1.11.1-dev.3",
3
+ "version": "1.11.1-dev.4",
4
4
  "description": "",
5
5
  "main": "dist/published/index.js",
6
6
  "module": "dist/published/index.js",