@arquimedes.co/eureka-forms 2.0.84 → 2.0.86-test
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/@Types/FormStep.d.ts +5 -1
- package/dist/App/App.d.ts +4 -0
- package/dist/App/App.js +1 -0
- package/dist/Contexts/CustomContext.d.ts +2 -1
- package/dist/FormSteps/EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValuePickerStep.js +87 -57
- package/dist/FormSteps/FileUploadStep/MaterialFileUploadStep/FileComponent/FileComponent.d.ts +2 -1
- package/dist/FormSteps/FileUploadStep/MaterialFileUploadStep/FileComponent/FileComponent.js +3 -3
- package/dist/FormSteps/FileUploadStep/MaterialFileUploadStep/MaterialFileUploadStep.js +4 -6
- package/dist/States/GlobalSlice.d.ts +1 -1
- package/dist/constants/FormStepTypes.d.ts +2 -1
- package/dist/constants/FormStepTypes.js +1 -0
- package/package.json +1 -1
|
@@ -148,7 +148,7 @@ export interface ValueEntityValuePickerPath {
|
|
|
148
148
|
type: EntityValueDataTypes.VALUE;
|
|
149
149
|
idEntityValue: string | null;
|
|
150
150
|
}
|
|
151
|
-
export type EntityValuePickerFilter = StepEntityValuePickerFilter | ValueEntityValuePickerFilter;
|
|
151
|
+
export type EntityValuePickerFilter = StepEntityValuePickerFilter | ValueEntityValuePickerFilter | IntegrationEntityValuePickerFilter;
|
|
152
152
|
export interface StepEntityValuePickerFilter {
|
|
153
153
|
idProperty: string;
|
|
154
154
|
type: EntityValueDataTypes.STEP;
|
|
@@ -161,6 +161,10 @@ export interface ValueEntityValuePickerFilter {
|
|
|
161
161
|
type: EntityValueDataTypes.VALUE;
|
|
162
162
|
value: any;
|
|
163
163
|
}
|
|
164
|
+
export interface IntegrationEntityValuePickerFilter {
|
|
165
|
+
idProperty: string;
|
|
166
|
+
type: EntityValueDataTypes.INTEGRATION;
|
|
167
|
+
}
|
|
164
168
|
export interface ApiSelector extends GSteps.GSmartSelect {
|
|
165
169
|
type: FormStepTypes.API_SELECTOR;
|
|
166
170
|
icon: string | null;
|
package/dist/App/App.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Classifier, Form } from '../@Types/Form';
|
|
3
3
|
import './App.css';
|
|
4
|
+
import { DependencyStore } from '../Form/Form';
|
|
4
5
|
import { CustomStep, CustomStepProps } from '../FormSteps/CustomStep';
|
|
5
6
|
import { EditorState } from 'draft-js';
|
|
7
|
+
import { IntegrationEntityValuePickerFilter } from '../@Types/FormStep';
|
|
6
8
|
export interface AppProps {
|
|
7
9
|
/** If the app is currently a widget */
|
|
8
10
|
isWidget?: boolean;
|
|
@@ -50,6 +52,8 @@ export interface AppProps {
|
|
|
50
52
|
handleConfirmed?: () => void;
|
|
51
53
|
/** Function called to scroll to the top */
|
|
52
54
|
scrollToTop?: () => void;
|
|
55
|
+
/** Function to call to reload the form */
|
|
56
|
+
calcEntityValueIntegrationFilter?: (filter: IntegrationEntityValuePickerFilter, store: DependencyStore) => Promise<string | null>;
|
|
53
57
|
}
|
|
54
58
|
export declare const IdFormContext: React.Context<string>;
|
|
55
59
|
declare function AppComponent({ formData, valuesData, ...props }: AppProps): JSX.Element;
|
package/dist/App/App.js
CHANGED
|
@@ -75,6 +75,7 @@ function App(_a) {
|
|
|
75
75
|
fetchDownloadUrl: props.fetchDownloadUrl,
|
|
76
76
|
customStepProps: (_g = props.customStepProps) !== null && _g !== void 0 ? _g : {},
|
|
77
77
|
customClientInfoStep: props.customClientInfoStep,
|
|
78
|
+
calcEntityValueIntegrationFilter: props.calcEntityValueIntegrationFilter,
|
|
78
79
|
} }, { children: _jsx("div", __assign({ className: styles.container }, { children: _jsx(FormComponent, { form: form, reload: reload, branding: branding, apiKey: props.apiKey, isWidget: !!isWidget, customSteps: customSteps, containerRef: containerRef, setSubmit: props.setSubmit, customSubmit: props.customSubmit, scrollToTop: props.scrollToTop, customSubmitBtns: props.customSubmitBtns, customConfirmation: props.customConfirmation }) })) })));
|
|
79
80
|
}
|
|
80
81
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { CustomStep, CustomStepProps } from '../FormSteps/CustomStep';
|
|
3
|
-
|
|
3
|
+
import { AppProps } from '../App/App';
|
|
4
|
+
export interface CustomContextData extends Pick<AppProps, 'calcEntityValueIntegrationFilter'> {
|
|
4
5
|
sendLabel?: string;
|
|
5
6
|
customStepProps: Record<string, unknown>;
|
|
6
7
|
customSteps: Record<string, CustomStep>;
|
|
@@ -67,10 +67,12 @@ import { evaluateCondition } from '../../StepFunctions';
|
|
|
67
67
|
import { recursivelyCalcConditionSteps, selectDependencies, } from '../../StepHooks';
|
|
68
68
|
import { useAppSelector } from '../../../hooks';
|
|
69
69
|
import MaterialEntityValueDialog from './MaterialEntityValueDialog/MaterialEntityValueDialog';
|
|
70
|
+
import CustomContext from '../../../Contexts/CustomContext';
|
|
70
71
|
function EntityValuePickerStep(_a) {
|
|
71
72
|
var _b, _c;
|
|
72
73
|
var step = _a.step, editable = _a.editable;
|
|
73
74
|
var form = useContext(FormContext);
|
|
75
|
+
var calcEntityValueIntegrationFilter = useContext(CustomContext).calcEntityValueIntegrationFilter;
|
|
74
76
|
var _d = useState(), dialogs = _d[0], setDialogs = _d[1];
|
|
75
77
|
var dialogsIdStepDeps = useMemo(function () {
|
|
76
78
|
var ids = [];
|
|
@@ -96,6 +98,9 @@ function EntityValuePickerStep(_a) {
|
|
|
96
98
|
: undefined;
|
|
97
99
|
});
|
|
98
100
|
}, []);
|
|
101
|
+
var getEntityValueOptions = useMemo(function () {
|
|
102
|
+
return generateGetEntityValueOptionsFunction(calcEntityValueIntegrationFilter);
|
|
103
|
+
}, [calcEntityValueIntegrationFilter]);
|
|
99
104
|
return (_jsxs(React.Fragment, { children: [dialogs !== undefined && ((_b = form.entities) === null || _b === void 0 ? void 0 : _b[step.idEntity]) && (_jsx(MaterialEntityValueDialog, { type: dialogs.current.type, entity: (_c = form.entities) === null || _c === void 0 ? void 0 : _c[step.idEntity], entityValue: dialogs.value, message: dialogs.current.message, handleClose: handleCloseDialog })), _jsx(StepFillerContainer, __assign({ step: step }, { children: _jsx(SmartSelect, { editable: editable, step: step, icon: step.icon ? _jsx(InputIcon, { icon: step.icon }) : undefined, getOptions: getEntityValueOptions, getOptionSelected: function (option, value) {
|
|
100
105
|
return option._id === value._id;
|
|
101
106
|
}, calcDepError: function (steps) {
|
|
@@ -171,65 +176,90 @@ function EntityValuePickerStep(_a) {
|
|
|
171
176
|
} }) }))] }));
|
|
172
177
|
}
|
|
173
178
|
export default EntityValuePickerStep;
|
|
174
|
-
var
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
idEntityValue = currentValue;
|
|
193
|
-
else
|
|
194
|
-
idEntityValue = (_e = currentValue._id) !== null && _e !== void 0 ? _e : currentValue.id;
|
|
195
|
-
break;
|
|
196
|
-
}
|
|
197
|
-
case EntityValueDataTypes.VALUE:
|
|
198
|
-
default:
|
|
199
|
-
idEntityValue = (_f = path.idEntityValue) !== null && _f !== void 0 ? _f : 'null';
|
|
200
|
-
break;
|
|
201
|
-
}
|
|
202
|
-
urlPath +=
|
|
203
|
-
'/' + path.idEntity + (idEntityValue ? '/' + idEntityValue : '');
|
|
204
|
-
}
|
|
205
|
-
params = new URLSearchParams({});
|
|
206
|
-
for (_b = 0, _c = step.filters; _b < _c.length; _b++) {
|
|
207
|
-
filter = _c[_b];
|
|
208
|
-
switch (filter.type) {
|
|
209
|
-
case EntityValueDataTypes.STEP: {
|
|
210
|
-
currentValue = (_g = dependencyStore[filter.idStep]) === null || _g === void 0 ? void 0 : _g.value;
|
|
211
|
-
if (currentValue) {
|
|
179
|
+
var generateGetEntityValueOptionsFunction = function (calcEntityValueIntegrationFilter) {
|
|
180
|
+
return function (idOrganization, step, dependencyStore) { return __awaiter(void 0, void 0, void 0, function () {
|
|
181
|
+
var urlPath, _i, _a, path, idEntityValue, currentValue, params, _b, _c, filter, _d, currentValue, value, url, response;
|
|
182
|
+
var _e, _f, _g, _h, _j;
|
|
183
|
+
return __generator(this, function (_k) {
|
|
184
|
+
switch (_k.label) {
|
|
185
|
+
case 0:
|
|
186
|
+
if (!idOrganization)
|
|
187
|
+
return [2 /*return*/, null];
|
|
188
|
+
urlPath = '';
|
|
189
|
+
for (_i = 0, _a = step.path; _i < _a.length; _i++) {
|
|
190
|
+
path = _a[_i];
|
|
191
|
+
idEntityValue = 'null';
|
|
192
|
+
switch (path.type) {
|
|
193
|
+
case EntityValueDataTypes.STEP: {
|
|
194
|
+
currentValue = (_e = dependencyStore[path.idStep]) === null || _e === void 0 ? void 0 : _e.value;
|
|
195
|
+
if (!currentValue)
|
|
196
|
+
return [2 /*return*/, null];
|
|
212
197
|
if (typeof currentValue === 'string')
|
|
213
|
-
|
|
198
|
+
idEntityValue = currentValue;
|
|
214
199
|
else
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
else if (filter.required) {
|
|
218
|
-
return [2 /*return*/, null];
|
|
200
|
+
idEntityValue = (_f = currentValue._id) !== null && _f !== void 0 ? _f : currentValue.id;
|
|
201
|
+
break;
|
|
219
202
|
}
|
|
220
|
-
|
|
203
|
+
case EntityValueDataTypes.VALUE:
|
|
204
|
+
default:
|
|
205
|
+
idEntityValue = (_g = path.idEntityValue) !== null && _g !== void 0 ? _g : 'null';
|
|
206
|
+
break;
|
|
221
207
|
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
208
|
+
urlPath +=
|
|
209
|
+
'/' +
|
|
210
|
+
path.idEntity +
|
|
211
|
+
(idEntityValue ? '/' + idEntityValue : '');
|
|
226
212
|
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
213
|
+
params = new URLSearchParams({});
|
|
214
|
+
_b = 0, _c = step.filters;
|
|
215
|
+
_k.label = 1;
|
|
216
|
+
case 1:
|
|
217
|
+
if (!(_b < _c.length)) return [3 /*break*/, 8];
|
|
218
|
+
filter = _c[_b];
|
|
219
|
+
_d = filter.type;
|
|
220
|
+
switch (_d) {
|
|
221
|
+
case EntityValueDataTypes.STEP: return [3 /*break*/, 2];
|
|
222
|
+
case EntityValueDataTypes.INTEGRATION: return [3 /*break*/, 3];
|
|
223
|
+
case EntityValueDataTypes.VALUE: return [3 /*break*/, 6];
|
|
224
|
+
}
|
|
225
|
+
return [3 /*break*/, 6];
|
|
226
|
+
case 2:
|
|
227
|
+
{
|
|
228
|
+
currentValue = (_h = dependencyStore[filter.idStep]) === null || _h === void 0 ? void 0 : _h.value;
|
|
229
|
+
if (currentValue) {
|
|
230
|
+
if (typeof currentValue === 'string')
|
|
231
|
+
params.set(filter.idProperty, currentValue);
|
|
232
|
+
else
|
|
233
|
+
params.set(filter.idProperty, (_j = currentValue._id) !== null && _j !== void 0 ? _j : currentValue.id);
|
|
234
|
+
}
|
|
235
|
+
else if (filter.required) {
|
|
236
|
+
return [2 /*return*/, null];
|
|
237
|
+
}
|
|
238
|
+
return [3 /*break*/, 7];
|
|
239
|
+
}
|
|
240
|
+
_k.label = 3;
|
|
241
|
+
case 3:
|
|
242
|
+
if (!calcEntityValueIntegrationFilter) return [3 /*break*/, 5];
|
|
243
|
+
return [4 /*yield*/, calcEntityValueIntegrationFilter(filter, dependencyStore)];
|
|
244
|
+
case 4:
|
|
245
|
+
value = _k.sent();
|
|
246
|
+
if (value)
|
|
247
|
+
params.set(filter.idProperty, value);
|
|
248
|
+
_k.label = 5;
|
|
249
|
+
case 5: return [3 /*break*/, 7];
|
|
250
|
+
case 6:
|
|
251
|
+
params.set(filter.idProperty, filter.value);
|
|
252
|
+
return [3 /*break*/, 7];
|
|
253
|
+
case 7:
|
|
254
|
+
_b++;
|
|
255
|
+
return [3 /*break*/, 1];
|
|
256
|
+
case 8:
|
|
257
|
+
url = "".concat(idOrganization, "/entities/").concat(step.idEntity).concat(urlPath, "?").concat(params.toString());
|
|
258
|
+
return [4 /*yield*/, widgetInstance.get(url)];
|
|
259
|
+
case 9:
|
|
260
|
+
response = _k.sent();
|
|
261
|
+
return [2 /*return*/, response.data.filter(function (option) { var _a; return ((_a = step.options[option._id]) === null || _a === void 0 ? void 0 : _a.type) !== EntityValueOptionTypes.HIDE; })];
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
}); };
|
|
265
|
+
};
|
package/dist/FormSteps/FileUploadStep/MaterialFileUploadStep/FileComponent/FileComponent.d.ts
CHANGED
|
@@ -5,9 +5,10 @@ interface FileComponentProps {
|
|
|
5
5
|
file: FileObject | UploadedFileObject;
|
|
6
6
|
formStyle: FormStyle;
|
|
7
7
|
error: boolean;
|
|
8
|
+
editable: boolean;
|
|
8
9
|
handleRemove: () => void;
|
|
9
10
|
/** Function to call on postview to fetch the download url of a file */
|
|
10
11
|
fetchDownloadUrl?: (S3Key: string, fileName: string) => Promise<string>;
|
|
11
12
|
}
|
|
12
|
-
declare function FileUploadComponent({ file, formStyle, error, handleRemove, fetchDownloadUrl, }: FileComponentProps): JSX.Element;
|
|
13
|
+
declare function FileUploadComponent({ file, formStyle, error, editable, handleRemove, fetchDownloadUrl, }: FileComponentProps): JSX.Element;
|
|
13
14
|
export default FileUploadComponent;
|
|
@@ -56,7 +56,7 @@ import { useState } from 'react';
|
|
|
56
56
|
function FileUploadComponent(_a) {
|
|
57
57
|
var _this = this;
|
|
58
58
|
var _b, _c;
|
|
59
|
-
var file = _a.file, formStyle = _a.formStyle, error = _a.error, handleRemove = _a.handleRemove, fetchDownloadUrl = _a.fetchDownloadUrl;
|
|
59
|
+
var file = _a.file, formStyle = _a.formStyle, error = _a.error, editable = _a.editable, handleRemove = _a.handleRemove, fetchDownloadUrl = _a.fetchDownloadUrl;
|
|
60
60
|
var _d = useState(false), downloading = _d[0], setDownloading = _d[1];
|
|
61
61
|
if (!file) {
|
|
62
62
|
return _jsx("div", {});
|
|
@@ -124,8 +124,8 @@ function FileUploadComponent(_a) {
|
|
|
124
124
|
else if (fetchDownloadUrl !== undefined && file.S3Key) {
|
|
125
125
|
downloadFile();
|
|
126
126
|
}
|
|
127
|
-
} }, { children: (_c = (_b = file.file) === null || _b === void 0 ? void 0 : _b.name) !== null && _c !== void 0 ? _c : file.fileName })), _jsx("div", __assign({ className: styles.deletBtn, onClick: function () {
|
|
127
|
+
} }, { children: (_c = (_b = file.file) === null || _b === void 0 ? void 0 : _b.name) !== null && _c !== void 0 ? _c : file.fileName })), editable && (_jsx("div", __assign({ className: styles.deletBtn, onClick: function () {
|
|
128
128
|
handleRemove();
|
|
129
|
-
} }, { children:
|
|
129
|
+
} }, { children: _jsx(ClearRoundedIcon, { fontSize: "inherit" }) })))] })));
|
|
130
130
|
}
|
|
131
131
|
export default FileUploadComponent;
|
|
@@ -247,18 +247,16 @@ function FileUploadStep(_a) {
|
|
|
247
247
|
}
|
|
248
248
|
} })] })), _jsx("div", __assign({ className: styles.filesContainer }, { children: value.map(function (file, index) { return (_jsx(FileComponent, { formStyle: formStyle, file: file, error: (!!fieldError &&
|
|
249
249
|
file.state !== 'DONE') ||
|
|
250
|
-
file.state === 'ERROR', handleRemove: function () {
|
|
250
|
+
file.state === 'ERROR', editable: editable && !postview, handleRemove: function () {
|
|
251
251
|
if (value.filter(function (val) {
|
|
252
252
|
return val.state === 'ERROR';
|
|
253
253
|
}).length === 1) {
|
|
254
254
|
clearErrors(step.id);
|
|
255
255
|
setError(undefined);
|
|
256
256
|
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
]);
|
|
261
|
-
}
|
|
257
|
+
setFileChange([
|
|
258
|
+
__assign(__assign({}, file), { state: 'CANCEL' }),
|
|
259
|
+
]);
|
|
262
260
|
}, fetchDownloadUrl: fetchDownloadUrl }, index)); }) })), _jsx("div", __assign({ className: styles.errorMsg, style: { color: formStyle.errorColor } }, { children: error !== null && error !== void 0 ? error : calcErrorMsg() }))] })));
|
|
263
261
|
}
|
|
264
262
|
export default FileUploadStep;
|
|
@@ -26,11 +26,11 @@ export declare const GlobalSlice: import("@reduxjs/toolkit").Slice<GlobalState,
|
|
|
26
26
|
formStyle: FormStyle;
|
|
27
27
|
preview: boolean;
|
|
28
28
|
idOrganization: string;
|
|
29
|
+
internal: boolean;
|
|
29
30
|
confirmation: {
|
|
30
31
|
confirmationMessage: EurekaDraft;
|
|
31
32
|
showLink: boolean;
|
|
32
33
|
};
|
|
33
|
-
internal: boolean;
|
|
34
34
|
dependencies: import("../Form/Form").DependencyStore;
|
|
35
35
|
values: import("./SiteSlice").ValuesStore;
|
|
36
36
|
idCurrentSection: string | null;
|
|
@@ -67,6 +67,7 @@ export var EntityValueDataTypes;
|
|
|
67
67
|
(function (EntityValueDataTypes) {
|
|
68
68
|
EntityValueDataTypes["STEP"] = "STEP";
|
|
69
69
|
EntityValueDataTypes["VALUE"] = "VALUE";
|
|
70
|
+
EntityValueDataTypes["INTEGRATION"] = "INTEGRATION";
|
|
70
71
|
})(EntityValueDataTypes || (EntityValueDataTypes = {}));
|
|
71
72
|
export var ApiSelectorParamTypes;
|
|
72
73
|
(function (ApiSelectorParamTypes) {
|
package/package.json
CHANGED