@evoke-platform/ui-components 1.10.1-dev.2 → 1.10.1-dev.3
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.
- package/dist/published/components/custom/FormV2/FormRenderer.d.ts +2 -2
- package/dist/published/components/custom/FormV2/FormRenderer.js +7 -1
- package/dist/published/components/custom/FormV2/FormRendererContainer.d.ts +2 -2
- package/dist/published/components/custom/FormV2/components/FormContext.d.ts +2 -2
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/CollectionFiles/ActionDialog.d.ts +2 -2
- package/dist/published/components/custom/FormV2/components/FormFieldTypes/CollectionFiles/RepeatableField.js +12 -4
- package/dist/published/components/custom/FormV2/components/utils.d.ts +4 -1
- package/dist/published/components/custom/FormV2/components/utils.js +4 -1
- package/dist/published/stories/FormRenderer.stories.d.ts +8 -8
- package/dist/published/stories/FormRendererContainer.stories.d.ts +12 -12
- package/dist/published/theme/hooks.d.ts +3 -3
- package/package.json +1 -1
|
@@ -19,8 +19,8 @@ export type FormRendererProps = BaseProps & {
|
|
|
19
19
|
onChange: (id: string, value: unknown) => void | Promise<void>;
|
|
20
20
|
onAutosave?: (fieldId: string) => void | Promise<void>;
|
|
21
21
|
associatedObject?: {
|
|
22
|
-
instanceId
|
|
23
|
-
propertyId
|
|
22
|
+
instanceId: string;
|
|
23
|
+
propertyId: string;
|
|
24
24
|
};
|
|
25
25
|
renderHeader?: (props: HeaderProps) => React.ReactNode;
|
|
26
26
|
renderBody?: (props: BodyProps) => React.ReactNode;
|
|
@@ -171,7 +171,13 @@ const FormRendererInternal = (props) => {
|
|
|
171
171
|
async function unregisterHiddenFieldsAndSubmit() {
|
|
172
172
|
unregisterHiddenFields(entries ?? []);
|
|
173
173
|
removeUneditedProtectedValues();
|
|
174
|
-
await handleSubmit((data) =>
|
|
174
|
+
await handleSubmit((data) => {
|
|
175
|
+
if (onSubmit) {
|
|
176
|
+
onSubmit(action?.type === 'delete' ? {} : data);
|
|
177
|
+
// clear fetched options after successful submit to allow re-evaluation with the new instance data
|
|
178
|
+
setFetchedOptions({});
|
|
179
|
+
}
|
|
180
|
+
}, (errors) => onSubmitError(errors))();
|
|
175
181
|
}
|
|
176
182
|
const headerProps = {
|
|
177
183
|
title,
|
|
@@ -30,8 +30,8 @@ export type FormRendererContainerProps = BaseProps & {
|
|
|
30
30
|
onDiscardChanges?: FormRendererProps['onDiscardChanges'];
|
|
31
31
|
onSubmitError?: FormRendererProps['onSubmitError'];
|
|
32
32
|
associatedObject?: {
|
|
33
|
-
instanceId
|
|
34
|
-
propertyId
|
|
33
|
+
instanceId: string;
|
|
34
|
+
propertyId: string;
|
|
35
35
|
};
|
|
36
36
|
renderContainer?: (state: FormRendererState) => React.ReactNode;
|
|
37
37
|
renderHeader?: FormRendererProps['renderHeader'];
|
|
@@ -11,8 +11,8 @@ export type ActionDialogProps = {
|
|
|
11
11
|
relatedParameter: InputParameter;
|
|
12
12
|
relatedFormId?: string;
|
|
13
13
|
associatedObject?: {
|
|
14
|
-
instanceId
|
|
15
|
-
propertyId
|
|
14
|
+
instanceId: string;
|
|
15
|
+
propertyId: string;
|
|
16
16
|
};
|
|
17
17
|
};
|
|
18
18
|
export declare const ActionDialog: (props: ActionDialogProps) => React.JSX.Element;
|
|
@@ -249,8 +249,10 @@ const RepeatableField = (props) => {
|
|
|
249
249
|
};
|
|
250
250
|
}
|
|
251
251
|
};
|
|
252
|
-
const checkCreateAccess = (relatedObject) => {
|
|
253
|
-
if (fieldDefinition.objectId &&
|
|
252
|
+
const checkCreateAccess = useCallback((relatedObject) => {
|
|
253
|
+
if (fieldDefinition.objectId &&
|
|
254
|
+
canUpdateProperty &&
|
|
255
|
+
!fetchedOptions[`${fieldDefinition.id}HasCreateAction`]) {
|
|
254
256
|
apiServices
|
|
255
257
|
.get(getPrefixedUrl(`/objects/${fieldDefinition.objectId}/instances/checkAccess`), {
|
|
256
258
|
params: { action: 'execute', field: entry.display?.createActionId, scope: 'data' },
|
|
@@ -272,7 +274,11 @@ const RepeatableField = (props) => {
|
|
|
272
274
|
}
|
|
273
275
|
});
|
|
274
276
|
}
|
|
275
|
-
};
|
|
277
|
+
}, [fieldDefinition, canUpdateProperty, fetchedOptions, entry.display?.createActionId, instance, apiServices]);
|
|
278
|
+
useEffect(() => {
|
|
279
|
+
// Re-check create access when instance changes to re-evaluate the criteria
|
|
280
|
+
relatedObject && checkCreateAccess(relatedObject);
|
|
281
|
+
}, [relatedObject, checkCreateAccess]);
|
|
276
282
|
useEffect(() => {
|
|
277
283
|
const updatedOptions = {};
|
|
278
284
|
if ((relatedInstances && !fetchedOptions[`${fieldDefinition.id}Options`]) ||
|
|
@@ -336,7 +342,9 @@ const RepeatableField = (props) => {
|
|
|
336
342
|
? entry.display?.updateActionId
|
|
337
343
|
: entry.display?.deleteActionId));
|
|
338
344
|
// when save is called we know that fieldDefinition is a parameter and fieldDefinition.objectId is defined
|
|
339
|
-
input = await formatSubmission(input, apiServices, fieldDefinition.objectId, selectedInstanceId, action?.type === 'update' ? updateForm : undefined
|
|
345
|
+
input = await formatSubmission(input, apiServices, fieldDefinition.objectId, selectedInstanceId, action?.type === 'update' ? updateForm : undefined, undefined, instance?.id && fieldDefinition.relatedPropertyId
|
|
346
|
+
? { instanceId: instance.id, propertyId: fieldDefinition.relatedPropertyId }
|
|
347
|
+
: undefined);
|
|
340
348
|
if (action?.type === 'create' && entry.display?.createActionId) {
|
|
341
349
|
const updatedInput = {
|
|
342
350
|
...input,
|
|
@@ -86,7 +86,10 @@ export declare function formatSubmission(submission: FieldValues, apiServices?:
|
|
|
86
86
|
showAlert: boolean;
|
|
87
87
|
message?: string;
|
|
88
88
|
isError: boolean;
|
|
89
|
-
}
|
|
89
|
+
}>>, associatedObject?: {
|
|
90
|
+
instanceId: string;
|
|
91
|
+
propertyId: string;
|
|
92
|
+
}): Promise<FieldValues>;
|
|
90
93
|
export declare function filterEmptySections(entry: Sections | Columns, instance?: FieldValues, formData?: FieldValues): Sections | Columns | null;
|
|
91
94
|
export declare function assignIdsToSectionsAndRichText(entries: FormEntry[], object: Obj, parameters?: InputParameter[]): FormEntry[];
|
|
92
95
|
/**
|
|
@@ -621,7 +621,10 @@ export const deleteDocuments = async (submittedFields, requestSuccess, apiServic
|
|
|
621
621
|
*
|
|
622
622
|
* Returns the cleaned submission ready for submitting.
|
|
623
623
|
*/
|
|
624
|
-
export async function formatSubmission(submission, apiServices, objectId, instanceId, form, setSnackbarError) {
|
|
624
|
+
export async function formatSubmission(submission, apiServices, objectId, instanceId, form, setSnackbarError, associatedObject) {
|
|
625
|
+
if (associatedObject) {
|
|
626
|
+
delete submission[associatedObject.propertyId];
|
|
627
|
+
}
|
|
625
628
|
const allEntries = getUnnestedEntries(form?.entries ?? []) ?? [];
|
|
626
629
|
for (const [key, value] of Object.entries(submission)) {
|
|
627
630
|
const entry = allEntries?.find((entry) => getEntryId(entry) === key);
|
|
@@ -12,8 +12,8 @@ declare const _default: import("@storybook/types").ComponentAnnotations<import("
|
|
|
12
12
|
onChange: (id: string, value: unknown) => void | Promise<void>;
|
|
13
13
|
onAutosave?: ((fieldId: string) => void | Promise<void>) | undefined;
|
|
14
14
|
associatedObject?: {
|
|
15
|
-
instanceId
|
|
16
|
-
propertyId
|
|
15
|
+
instanceId: string;
|
|
16
|
+
propertyId: string;
|
|
17
17
|
} | undefined;
|
|
18
18
|
renderHeader?: ((props: import("../components/custom").HeaderProps) => React.ReactNode) | undefined;
|
|
19
19
|
renderBody?: ((props: import("../components/custom").BodyProps) => React.ReactNode) | undefined;
|
|
@@ -33,8 +33,8 @@ export declare const Editable: import("@storybook/types").AnnotatedStoryFn<impor
|
|
|
33
33
|
onChange: (id: string, value: unknown) => void | Promise<void>;
|
|
34
34
|
onAutosave?: ((fieldId: string) => void | Promise<void>) | undefined;
|
|
35
35
|
associatedObject?: {
|
|
36
|
-
instanceId
|
|
37
|
-
propertyId
|
|
36
|
+
instanceId: string;
|
|
37
|
+
propertyId: string;
|
|
38
38
|
} | undefined;
|
|
39
39
|
renderHeader?: ((props: import("../components/custom").HeaderProps) => React.ReactNode) | undefined;
|
|
40
40
|
renderBody?: ((props: import("../components/custom").BodyProps) => React.ReactNode) | undefined;
|
|
@@ -53,8 +53,8 @@ export declare const NoButtons: import("@storybook/types").AnnotatedStoryFn<impo
|
|
|
53
53
|
onChange: (id: string, value: unknown) => void | Promise<void>;
|
|
54
54
|
onAutosave?: ((fieldId: string) => void | Promise<void>) | undefined;
|
|
55
55
|
associatedObject?: {
|
|
56
|
-
instanceId
|
|
57
|
-
propertyId
|
|
56
|
+
instanceId: string;
|
|
57
|
+
propertyId: string;
|
|
58
58
|
} | undefined;
|
|
59
59
|
renderHeader?: ((props: import("../components/custom").HeaderProps) => React.ReactNode) | undefined;
|
|
60
60
|
renderBody?: ((props: import("../components/custom").BodyProps) => React.ReactNode) | undefined;
|
|
@@ -73,8 +73,8 @@ export declare const DocumentForm: import("@storybook/types").AnnotatedStoryFn<i
|
|
|
73
73
|
onChange: (id: string, value: unknown) => void | Promise<void>;
|
|
74
74
|
onAutosave?: ((fieldId: string) => void | Promise<void>) | undefined;
|
|
75
75
|
associatedObject?: {
|
|
76
|
-
instanceId
|
|
77
|
-
propertyId
|
|
76
|
+
instanceId: string;
|
|
77
|
+
propertyId: string;
|
|
78
78
|
} | undefined;
|
|
79
79
|
renderHeader?: ((props: import("../components/custom").HeaderProps) => React.ReactNode) | undefined;
|
|
80
80
|
renderBody?: ((props: import("../components/custom").BodyProps) => React.ReactNode) | undefined;
|
|
@@ -16,8 +16,8 @@ declare const _default: import("@storybook/types").ComponentAnnotations<import("
|
|
|
16
16
|
onDiscardChanges?: (() => void) | undefined;
|
|
17
17
|
onSubmitError?: import("react-hook-form").SubmitErrorHandler<import("react-hook-form").FieldValues> | undefined;
|
|
18
18
|
associatedObject?: {
|
|
19
|
-
instanceId
|
|
20
|
-
propertyId
|
|
19
|
+
instanceId: string;
|
|
20
|
+
propertyId: string;
|
|
21
21
|
} | undefined;
|
|
22
22
|
renderContainer?: ((state: import("../components/custom/FormV2/FormRendererContainer").FormRendererState) => React.ReactNode) | undefined;
|
|
23
23
|
renderHeader?: ((props: import("../components/custom").HeaderProps) => React.ReactNode) | undefined;
|
|
@@ -43,8 +43,8 @@ export declare const Editable: import("@storybook/types").AnnotatedStoryFn<impor
|
|
|
43
43
|
onDiscardChanges?: (() => void) | undefined;
|
|
44
44
|
onSubmitError?: import("react-hook-form").SubmitErrorHandler<import("react-hook-form").FieldValues> | undefined;
|
|
45
45
|
associatedObject?: {
|
|
46
|
-
instanceId
|
|
47
|
-
propertyId
|
|
46
|
+
instanceId: string;
|
|
47
|
+
propertyId: string;
|
|
48
48
|
} | undefined;
|
|
49
49
|
renderContainer?: ((state: import("../components/custom/FormV2/FormRendererContainer").FormRendererState) => React.ReactNode) | undefined;
|
|
50
50
|
renderHeader?: ((props: import("../components/custom").HeaderProps) => React.ReactNode) | undefined;
|
|
@@ -69,8 +69,8 @@ export declare const DefaultForm: import("@storybook/types").AnnotatedStoryFn<im
|
|
|
69
69
|
onDiscardChanges?: (() => void) | undefined;
|
|
70
70
|
onSubmitError?: import("react-hook-form").SubmitErrorHandler<import("react-hook-form").FieldValues> | undefined;
|
|
71
71
|
associatedObject?: {
|
|
72
|
-
instanceId
|
|
73
|
-
propertyId
|
|
72
|
+
instanceId: string;
|
|
73
|
+
propertyId: string;
|
|
74
74
|
} | undefined;
|
|
75
75
|
renderContainer?: ((state: import("../components/custom/FormV2/FormRendererContainer").FormRendererState) => React.ReactNode) | undefined;
|
|
76
76
|
renderHeader?: ((props: import("../components/custom").HeaderProps) => React.ReactNode) | undefined;
|
|
@@ -95,8 +95,8 @@ export declare const NoButtons: import("@storybook/types").AnnotatedStoryFn<impo
|
|
|
95
95
|
onDiscardChanges?: (() => void) | undefined;
|
|
96
96
|
onSubmitError?: import("react-hook-form").SubmitErrorHandler<import("react-hook-form").FieldValues> | undefined;
|
|
97
97
|
associatedObject?: {
|
|
98
|
-
instanceId
|
|
99
|
-
propertyId
|
|
98
|
+
instanceId: string;
|
|
99
|
+
propertyId: string;
|
|
100
100
|
} | undefined;
|
|
101
101
|
renderContainer?: ((state: import("../components/custom/FormV2/FormRendererContainer").FormRendererState) => React.ReactNode) | undefined;
|
|
102
102
|
renderHeader?: ((props: import("../components/custom").HeaderProps) => React.ReactNode) | undefined;
|
|
@@ -121,8 +121,8 @@ export declare const DocumentForm: import("@storybook/types").AnnotatedStoryFn<i
|
|
|
121
121
|
onDiscardChanges?: (() => void) | undefined;
|
|
122
122
|
onSubmitError?: import("react-hook-form").SubmitErrorHandler<import("react-hook-form").FieldValues> | undefined;
|
|
123
123
|
associatedObject?: {
|
|
124
|
-
instanceId
|
|
125
|
-
propertyId
|
|
124
|
+
instanceId: string;
|
|
125
|
+
propertyId: string;
|
|
126
126
|
} | undefined;
|
|
127
127
|
renderContainer?: ((state: import("../components/custom/FormV2/FormRendererContainer").FormRendererState) => React.ReactNode) | undefined;
|
|
128
128
|
renderHeader?: ((props: import("../components/custom").HeaderProps) => React.ReactNode) | undefined;
|
|
@@ -147,8 +147,8 @@ export declare const FormWithSections: import("@storybook/types").AnnotatedStory
|
|
|
147
147
|
onDiscardChanges?: (() => void) | undefined;
|
|
148
148
|
onSubmitError?: import("react-hook-form").SubmitErrorHandler<import("react-hook-form").FieldValues> | undefined;
|
|
149
149
|
associatedObject?: {
|
|
150
|
-
instanceId
|
|
151
|
-
propertyId
|
|
150
|
+
instanceId: string;
|
|
151
|
+
propertyId: string;
|
|
152
152
|
} | undefined;
|
|
153
153
|
renderContainer?: ((state: import("../components/custom/FormV2/FormRendererContainer").FormRendererState) => React.ReactNode) | undefined;
|
|
154
154
|
renderHeader?: ((props: import("../components/custom").HeaderProps) => React.ReactNode) | undefined;
|
|
@@ -153,9 +153,9 @@ export declare function useFormContext(): {
|
|
|
153
153
|
triggerFieldReset?: boolean | undefined;
|
|
154
154
|
showSubmitError?: boolean | undefined;
|
|
155
155
|
associatedObject?: {
|
|
156
|
-
instanceId
|
|
157
|
-
propertyId
|
|
158
|
-
} | undefined;
|
|
156
|
+
instanceId: string;
|
|
157
|
+
propertyId: string; /** Extra large screens (1536px and up) */
|
|
158
|
+
} | undefined; /** Extra large screens (1536px and up) */
|
|
159
159
|
form?: import("@evoke-platform/context").EvokeForm | undefined;
|
|
160
160
|
width: number;
|
|
161
161
|
};
|