@arquimedes.co/eureka-forms 2.0.5-test → 2.0.7-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/App/App.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { Classifier, Form } from '../@Types/Form';
|
|
3
3
|
import './App.css';
|
|
4
|
-
import { FormComponentProps } from '../Form/Form';
|
|
5
4
|
import { CustomStep } from '../FormSteps/CustomStep';
|
|
6
5
|
export interface AppProps {
|
|
7
6
|
/** If the app is currently a widget */
|
|
@@ -35,7 +34,7 @@ export interface AppProps {
|
|
|
35
34
|
/** Custom function to call on send */
|
|
36
35
|
customSubmit?: (values: Record<string, unknown>, reload: () => void) => Promise<void>;
|
|
37
36
|
/** Custom submit buttons */
|
|
38
|
-
customSubmitBtns?: (onSubmit:
|
|
37
|
+
customSubmitBtns?: (onSubmit: () => Promise<Record<string, any> | void>, loading: boolean) => JSX.Element;
|
|
39
38
|
/** Function to call on postview to fetch the download url of a file */
|
|
40
39
|
fetchDownloadUrl?: (S3Key: string, fileName: string) => Promise<string>;
|
|
41
40
|
/** Function to call after the confimation dialog has been closed */
|
package/dist/App/AppFunctions.js
CHANGED
|
@@ -47,7 +47,7 @@ export var calcValuesStore = function (originalValues, form, dependencies, custo
|
|
|
47
47
|
values.sections[step.idSection] = {};
|
|
48
48
|
var _f = addMapperStep(step, customSteps), element = _f.element, steps = _f.steps, mappers = _f.mappers;
|
|
49
49
|
values.sections[step.idSection] = __assign(__assign(__assign({}, values.sections[step.idSection]), mappers), (_a = {}, _a[step.id] = [element], _a));
|
|
50
|
-
calcDependencies(steps,
|
|
50
|
+
calcDependencies(steps, customSteps, __assign(__assign({}, form.steps), steps), dependencies, values);
|
|
51
51
|
}
|
|
52
52
|
return values;
|
|
53
53
|
};
|
|
@@ -131,12 +131,12 @@ export var mapOriginalValue = function (step, value, values, form) {
|
|
|
131
131
|
if (value_1 !== undefined) {
|
|
132
132
|
if (!values.sections[step.idSection])
|
|
133
133
|
values.sections[step.idSection] = {};
|
|
134
|
-
values.sections[step.idSection][
|
|
134
|
+
values.sections[step.idSection][newIdStep] = value_1;
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
for (var _j = 0, _k = Object.keys(element); _j < _k.length; _j++) {
|
|
138
138
|
var key = _k[_j];
|
|
139
|
-
if (step.steps[key])
|
|
139
|
+
if (step.steps[key] || key === 'id')
|
|
140
140
|
continue;
|
|
141
141
|
mappedElement.originalValues[key] = element[key];
|
|
142
142
|
}
|
package/dist/App/AppHooks.js
CHANGED
|
@@ -66,6 +66,7 @@ import { useAppDispatch } from '../hooks';
|
|
|
66
66
|
import InternalFormStyle from '../constants/InternalFormStyle';
|
|
67
67
|
import { calcDependencies } from '../Form/FormFunctions';
|
|
68
68
|
import { iterateNestedSteps } from '../FormSteps/StepFunctions';
|
|
69
|
+
import { createNextState } from '@reduxjs/toolkit';
|
|
69
70
|
export var useSetupApp = function (isEmbedded, _a) {
|
|
70
71
|
var preview = _a.preview, internal = _a.internal, postview = _a.postview, partial = _a.partial, editable = _a.editable, handleConfirmed = _a.handleConfirmed, customSteps = _a.customSteps, valuesData = _a.valuesData, apiKey = _a.apiKey, formData = _a.formData, classifiers = _a.classifiers, others = __rest(_a, ["preview", "internal", "postview", "partial", "editable", "handleConfirmed", "customSteps", "valuesData", "apiKey", "formData", "classifiers"]);
|
|
71
72
|
var _b = useState(undefined), form = _b[0], setForm = _b[1];
|
|
@@ -111,11 +112,11 @@ export var useSetupApp = function (isEmbedded, _a) {
|
|
|
111
112
|
});
|
|
112
113
|
}); };
|
|
113
114
|
var loadData = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
114
|
-
var idOrganization, organization, form, match,
|
|
115
|
+
var idOrganization, organization, form, match, dependencies, values;
|
|
116
|
+
var _a;
|
|
115
117
|
var _b;
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
switch (_d.label) {
|
|
118
|
+
return __generator(this, function (_c) {
|
|
119
|
+
switch (_c.label) {
|
|
119
120
|
case 0:
|
|
120
121
|
idOrganization = others.idOrganization;
|
|
121
122
|
organization = null;
|
|
@@ -123,7 +124,7 @@ export var useSetupApp = function (isEmbedded, _a) {
|
|
|
123
124
|
if (!(form && preview && form.isStandAlone)) return [3 /*break*/, 2];
|
|
124
125
|
return [4 /*yield*/, loadOrg()];
|
|
125
126
|
case 1:
|
|
126
|
-
organization =
|
|
127
|
+
organization = _c.sent();
|
|
127
128
|
return [3 /*break*/, 4];
|
|
128
129
|
case 2:
|
|
129
130
|
if (!(!form && apiKey)) return [3 /*break*/, 4];
|
|
@@ -133,8 +134,8 @@ export var useSetupApp = function (isEmbedded, _a) {
|
|
|
133
134
|
])];
|
|
134
135
|
case 3:
|
|
135
136
|
//Is iframe or widget
|
|
136
|
-
|
|
137
|
-
|
|
137
|
+
_a = _c.sent(), organization = _a[0], form = _a[1];
|
|
138
|
+
_c.label = 4;
|
|
138
139
|
case 4:
|
|
139
140
|
if (organization && !idOrganization)
|
|
140
141
|
idOrganization = organization.idOrganization;
|
|
@@ -145,24 +146,26 @@ export var useSetupApp = function (isEmbedded, _a) {
|
|
|
145
146
|
idOrganization = match ? match[1] : '';
|
|
146
147
|
}
|
|
147
148
|
if (form) {
|
|
148
|
-
|
|
149
|
-
form
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
var
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
149
|
+
form = createNextState(form, function (form) {
|
|
150
|
+
if (form && classifiers)
|
|
151
|
+
form.classifiers = classifiers;
|
|
152
|
+
var _loop_1 = function (section) {
|
|
153
|
+
for (var _b = 0, _c = section.steps; _b < _c.length; _b++) {
|
|
154
|
+
var idStep = _c[_b];
|
|
155
|
+
iterateNestedSteps(idStep, form.steps, function (step) {
|
|
156
|
+
step.idSection = section.id;
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
/** Assign the idSection to all the forms steps */
|
|
161
|
+
for (var _i = 0, _a = Object.values(form.sections); _i < _a.length; _i++) {
|
|
162
|
+
var section = _a[_i];
|
|
163
|
+
_loop_1(section);
|
|
156
164
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
_loop_1(section);
|
|
162
|
-
}
|
|
163
|
-
CBRStep = Object.values(form.steps).find(function (step) { return step.type.startsWith('CBR'); });
|
|
164
|
-
if (CBRStep)
|
|
165
|
-
form = calcCbrForm(form, valuesData !== null && valuesData !== void 0 ? valuesData : {});
|
|
165
|
+
var CBRStep = Object.values(form.steps).find(function (step) { return step.type.startsWith('CBR'); });
|
|
166
|
+
if (CBRStep)
|
|
167
|
+
form = calcCbrForm(form, valuesData !== null && valuesData !== void 0 ? valuesData : {});
|
|
168
|
+
});
|
|
166
169
|
}
|
|
167
170
|
setForm(form);
|
|
168
171
|
if (!form || !idOrganization)
|
|
@@ -171,7 +174,7 @@ export var useSetupApp = function (isEmbedded, _a) {
|
|
|
171
174
|
values = calcValuesStore(valuesData !== null && valuesData !== void 0 ? valuesData : {}, form, dependencies, customSteps !== null && customSteps !== void 0 ? customSteps : {});
|
|
172
175
|
dispatch(reset(__assign(__assign({ formStyle: internal
|
|
173
176
|
? InternalFormStyle
|
|
174
|
-
: __assign(__assign({}, InternalFormStyle), ((
|
|
177
|
+
: __assign(__assign({}, InternalFormStyle), ((_b = form === null || form === void 0 ? void 0 : form.style) !== null && _b !== void 0 ? _b : {})), internal: !!internal, idOrganization: idOrganization, preview: !!preview, partial: !!partial, postview: !!postview, editable: !!(editable !== null && editable !== void 0 ? editable : true), values: values }, calcInitialSections(form)), { dependencies: calcDependencies(form.steps, customSteps, form.steps, dependencies, values) })));
|
|
175
178
|
return [2 /*return*/];
|
|
176
179
|
}
|
|
177
180
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FormStep } from '../@Types/FormStep';
|
|
2
|
-
import { DependencyStore
|
|
2
|
+
import { DependencyStore } from './Form';
|
|
3
3
|
import { CustomStep } from '../FormSteps/CustomStep';
|
|
4
4
|
import { CBRFormStep } from '../@Types/CBRFormStep';
|
|
5
|
+
import { ValuesStore } from '../States/SiteStateReducer';
|
|
5
6
|
export declare const calcValue: (idStep: string, steps: Record<string, FormStep>, values: Record<string, any>, customSteps: Record<string, CustomStep> | undefined, deleteIds: string[], value?: any) => any;
|
|
6
|
-
export declare function calcDependencies(steps: Record<string, FormStep | CBRFormStep>,
|
|
7
|
-
export declare function calcStepDependency(idStep: string, steps: Record<string, FormStep | CBRFormStep>, originalValues: Record<string, any>, customSteps: Record<string, CustomStep>): StepDependency;
|
|
7
|
+
export declare function calcDependencies(steps: Record<string, FormStep | CBRFormStep>, customSteps?: Record<string, CustomStep>, allSteps?: Record<string, FormStep | CBRFormStep>, dependencies?: DependencyStore, values?: ValuesStore): DependencyStore;
|
|
@@ -112,19 +112,23 @@ function stringToDraft(text) {
|
|
|
112
112
|
});
|
|
113
113
|
return draftStructure;
|
|
114
114
|
}
|
|
115
|
-
export function calcDependencies(steps,
|
|
115
|
+
export function calcDependencies(steps, customSteps, allSteps, dependencies, values) {
|
|
116
116
|
var _a, _b, _c;
|
|
117
|
-
if (originalValues === void 0) { originalValues = {}; }
|
|
118
117
|
if (customSteps === void 0) { customSteps = {}; }
|
|
119
118
|
if (allSteps === void 0) { allSteps = steps; }
|
|
120
119
|
if (dependencies === void 0) { dependencies = {}; }
|
|
120
|
+
if (values === void 0) { values = {
|
|
121
|
+
global: {},
|
|
122
|
+
sections: {},
|
|
123
|
+
}; }
|
|
121
124
|
for (var _i = 0, _d = Object.values(steps); _i < _d.length; _i++) {
|
|
122
125
|
var step = _d[_i];
|
|
126
|
+
var originalValue = (_a = values.sections[step.idSection]) === null || _a === void 0 ? void 0 : _a[step.id];
|
|
123
127
|
if (step.dependencies) {
|
|
124
128
|
for (var _e = 0, _f = step.dependencies; _e < _f.length; _e++) {
|
|
125
129
|
var idDep = _f[_e];
|
|
126
130
|
if (dependencies[idDep] === undefined)
|
|
127
|
-
dependencies[idDep] = calcStepDependency(idDep, allSteps,
|
|
131
|
+
dependencies[idDep] = calcStepDependency(idDep, allSteps, originalValue, customSteps);
|
|
128
132
|
dependencies[idDep].dependents.push(step);
|
|
129
133
|
}
|
|
130
134
|
}
|
|
@@ -133,17 +137,17 @@ export function calcDependencies(steps, originalValues, customSteps, allSteps, d
|
|
|
133
137
|
var path = _h[_g];
|
|
134
138
|
if (path.type !== EntityValueDataTypes.STEP)
|
|
135
139
|
continue;
|
|
136
|
-
if ((
|
|
140
|
+
if ((_b = step.dependencies) === null || _b === void 0 ? void 0 : _b.includes(path.idStep))
|
|
137
141
|
continue;
|
|
138
142
|
if (dependencies[path.idStep] === undefined) {
|
|
139
|
-
dependencies[path.idStep] = calcStepDependency(path.idStep, allSteps,
|
|
143
|
+
dependencies[path.idStep] = calcStepDependency(path.idStep, allSteps, originalValue, customSteps);
|
|
140
144
|
}
|
|
141
145
|
dependencies[path.idStep].dependents.push(step);
|
|
142
146
|
}
|
|
143
147
|
}
|
|
144
148
|
if (step.type === StepTypes.MAPPER) {
|
|
145
149
|
var newSteps = {};
|
|
146
|
-
var elements =
|
|
150
|
+
var elements = originalValue !== null && originalValue !== void 0 ? originalValue : [];
|
|
147
151
|
var _loop_1 = function (element) {
|
|
148
152
|
for (var _k = 0, _l = Object.keys(step.steps); _k < _l.length; _k++) {
|
|
149
153
|
var idSubStep = _l[_k];
|
|
@@ -159,27 +163,27 @@ export function calcDependencies(steps, originalValues, customSteps, allSteps, d
|
|
|
159
163
|
if (elements.length === 0) {
|
|
160
164
|
newSteps = step.steps;
|
|
161
165
|
}
|
|
162
|
-
calcDependencies(newSteps,
|
|
166
|
+
calcDependencies(newSteps, customSteps, __assign(__assign({}, allSteps), newSteps), dependencies, values);
|
|
163
167
|
}
|
|
164
168
|
}
|
|
165
169
|
return dependencies;
|
|
166
170
|
}
|
|
167
|
-
|
|
168
|
-
var _a
|
|
171
|
+
function calcStepDependency(idStep, steps, originalValue, customSteps) {
|
|
172
|
+
var _a;
|
|
169
173
|
var depStep = steps[idStep];
|
|
170
174
|
return {
|
|
171
175
|
type: (_a = depStep === null || depStep === void 0 ? void 0 : depStep.type) !== null && _a !== void 0 ? _a : 'ORIGINAL',
|
|
172
176
|
value: depStep
|
|
173
|
-
? calcStepDependencyValue(depStep,
|
|
174
|
-
:
|
|
177
|
+
? calcStepDependencyValue(depStep, originalValue, customSteps)
|
|
178
|
+
: originalValue !== null && originalValue !== void 0 ? originalValue : null,
|
|
175
179
|
dependents: [],
|
|
176
180
|
};
|
|
177
181
|
}
|
|
178
|
-
function calcStepDependencyValue(depStep,
|
|
179
|
-
var _a
|
|
182
|
+
function calcStepDependencyValue(depStep, originalValue, customSteps) {
|
|
183
|
+
var _a;
|
|
180
184
|
var custom = customSteps[depStep === null || depStep === void 0 ? void 0 : depStep.type];
|
|
181
185
|
if (custom === null || custom === void 0 ? void 0 : custom.calcDependencyValue) {
|
|
182
|
-
return custom.calcDependencyValue(depStep,
|
|
186
|
+
return custom.calcDependencyValue(depStep, originalValue);
|
|
183
187
|
}
|
|
184
188
|
switch (depStep.type) {
|
|
185
189
|
case StepTypes.TEXTAREA: {
|
|
@@ -187,13 +191,13 @@ function calcStepDependencyValue(depStep, originalValues, customSteps) {
|
|
|
187
191
|
return null;
|
|
188
192
|
}
|
|
189
193
|
else {
|
|
190
|
-
return
|
|
194
|
+
return originalValue === null || originalValue === void 0 ? void 0 : originalValue.value;
|
|
191
195
|
}
|
|
192
196
|
}
|
|
193
197
|
case StepTypes.MAPPER: {
|
|
194
|
-
return ((
|
|
198
|
+
return ((_a = originalValue === null || originalValue === void 0 ? void 0 : originalValue.map(function (mapperValue) { var _a; return (_a = mapperValue.value) !== null && _a !== void 0 ? _a : mapperValue; })) !== null && _a !== void 0 ? _a : null);
|
|
195
199
|
}
|
|
196
200
|
default:
|
|
197
|
-
return
|
|
201
|
+
return originalValue !== null && originalValue !== void 0 ? originalValue : null;
|
|
198
202
|
}
|
|
199
203
|
}
|
|
@@ -50,7 +50,7 @@ export var SiteSlice = createSlice({
|
|
|
50
50
|
},
|
|
51
51
|
addStepsDependencies: function (state, _a) {
|
|
52
52
|
var _b = _a.payload, steps = _b.steps, customSteps = _b.customSteps;
|
|
53
|
-
calcDependencies(steps,
|
|
53
|
+
calcDependencies(steps, customSteps, steps, state.dependencies);
|
|
54
54
|
},
|
|
55
55
|
handlePrevious: function (state, _a) {
|
|
56
56
|
var payload = _a.payload;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arquimedes.co/eureka-forms",
|
|
3
3
|
"repository": "git://github.com/Arquimede5/Eureka-Forms.git",
|
|
4
|
-
"version":"2.0.
|
|
4
|
+
"version":"2.0.7-test",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"start": "react-scripts start",
|
|
7
7
|
"build": "react-scripts build",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"test": "react-scripts test",
|
|
10
10
|
"test-ci": "react-scripts test --reporters=default --reporters=jest-junit --coverage --coverageReporters cobertura html",
|
|
11
11
|
"tsc-build": "tsc --noEmit false --outDir ./dist --incremental false",
|
|
12
|
-
"watch": "tsc
|
|
12
|
+
"watch": "tsc -w --preserveWatchOutput",
|
|
13
13
|
"storybook": "storybook dev -p 6006",
|
|
14
14
|
"build-storybook": "storybook build",
|
|
15
15
|
"cypress": "DISPLAY=:0 cypress open"
|
|
@@ -107,4 +107,4 @@
|
|
|
107
107
|
"/dist"
|
|
108
108
|
],
|
|
109
109
|
"proxy": "https://api.forms.eureka-test.click"
|
|
110
|
-
}
|
|
110
|
+
}
|