@arquimedes.co/eureka-forms 2.0.39 → 2.0.41
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.
|
@@ -3,6 +3,7 @@ import { FormStep, Mapper } from '../@Types/FormStep';
|
|
|
3
3
|
import { SiteState, ValuesStore } from '../States/SiteSlice';
|
|
4
4
|
import { CustomStep } from '../FormSteps/CustomStep';
|
|
5
5
|
import { MapperElement } from '../@Types/MapperElement';
|
|
6
|
+
import { Condition } from '../@Types/Condition';
|
|
6
7
|
export declare const calcValuesStore: (form: Readonly<Form>, originalValues?: Record<string, any>, postview?: boolean, customSteps?: Record<string, CustomStep>) => ValuesStore;
|
|
7
8
|
export declare const addMapperStep: <Type>(step: Mapper, customSteps: Record<string, CustomStep>) => {
|
|
8
9
|
element: MapperElement<Type>;
|
|
@@ -12,5 +13,6 @@ export declare const addMapperStep: <Type>(step: Mapper, customSteps: Record<str
|
|
|
12
13
|
steps: Record<string, FormStep>;
|
|
13
14
|
};
|
|
14
15
|
export declare function calcRecursiveData<Type>(element: Readonly<MapperElement<Type>>, newSteps: Record<string, FormStep>, customSteps: Record<string, CustomStep>): void;
|
|
16
|
+
export declare const calcRecursiveCondition: (condition: Condition, ids: Record<string, string>) => void;
|
|
15
17
|
export declare const mapOriginalValue: (step: FormStep, value: any, values: ValuesStore, form?: Readonly<Form>) => any;
|
|
16
18
|
export declare const calcInitialSections: (form: Form) => Pick<SiteState, 'previousSections' | 'idCurrentSection' | 'nextSections'>;
|
package/dist/App/AppFunctions.js
CHANGED
|
@@ -13,6 +13,7 @@ import { nanoid } from 'nanoid';
|
|
|
13
13
|
import StepTypes, { FormTypes } from '../constants/FormStepTypes';
|
|
14
14
|
import { getRawText, stringToDraft } from '../Utils/DraftFunctions';
|
|
15
15
|
import { calcSubSteps } from '../FormSteps/StepFunctions';
|
|
16
|
+
import ConditionTypes from '../constants/ConditionTypes';
|
|
16
17
|
export var calcValuesStore = function (form, originalValues, postview, customSteps) {
|
|
17
18
|
var _a;
|
|
18
19
|
var _b, _c;
|
|
@@ -106,9 +107,31 @@ export function calcRecursiveData(element, newSteps, customSteps) {
|
|
|
106
107
|
if (custom === null || custom === void 0 ? void 0 : custom.calcRecursiveData) {
|
|
107
108
|
custom.calcRecursiveData(step, element.ids);
|
|
108
109
|
}
|
|
110
|
+
if (step.condition) {
|
|
111
|
+
calcRecursiveCondition(step.condition, element.ids);
|
|
112
|
+
}
|
|
109
113
|
calcSubSteps(step.id, newSteps, function (idStep) { var _a; return (_a = element.ids[idStep]) !== null && _a !== void 0 ? _a : idStep; });
|
|
110
114
|
}
|
|
111
115
|
}
|
|
116
|
+
export var calcRecursiveCondition = function (condition, ids) {
|
|
117
|
+
switch (condition.type) {
|
|
118
|
+
case ConditionTypes.EXPRESSION:
|
|
119
|
+
for (var _i = 0, _a = condition.conditions; _i < _a.length; _i++) {
|
|
120
|
+
var subCondition = _a[_i];
|
|
121
|
+
calcRecursiveCondition(subCondition, ids);
|
|
122
|
+
}
|
|
123
|
+
break;
|
|
124
|
+
case ConditionTypes.FORM_STEP: {
|
|
125
|
+
var newId = ids[condition.idStep];
|
|
126
|
+
if (newId) {
|
|
127
|
+
condition.idStep = newId;
|
|
128
|
+
}
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
default:
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
};
|
|
112
135
|
export var mapOriginalValue = function (step, value, values, form) {
|
|
113
136
|
var _a, _b, _c, _d, _e, _f;
|
|
114
137
|
if (!value)
|
package/dist/App/AppHooks.js
CHANGED
|
@@ -154,8 +154,7 @@ export var useSetupApp = function (isEmbedded, _a) {
|
|
|
154
154
|
for (var _b = 0, _c = section.steps; _b < _c.length; _b++) {
|
|
155
155
|
var idStep = _c[_b];
|
|
156
156
|
iterateNestedSteps(idStep, form.steps, function (step) {
|
|
157
|
-
|
|
158
|
-
step.idSection = section.id;
|
|
157
|
+
step.idSection = section.id;
|
|
159
158
|
});
|
|
160
159
|
}
|
|
161
160
|
};
|
|
@@ -130,15 +130,15 @@ export function calcDependencies(steps, customSteps, allSteps, dependencies, val
|
|
|
130
130
|
sections: {},
|
|
131
131
|
}; }
|
|
132
132
|
if (addDependents === void 0) { addDependents = true; }
|
|
133
|
-
|
|
134
|
-
var step = _c[_i];
|
|
133
|
+
var _loop_1 = function (step) {
|
|
135
134
|
var idDeps = calcStepDeps(step);
|
|
136
135
|
for (var _d = 0, idDeps_1 = idDeps; _d < idDeps_1.length; _d++) {
|
|
137
136
|
var idDep = idDeps_1[_d];
|
|
138
137
|
if (dependencies[idDep] === undefined &&
|
|
139
138
|
(addDependents || allSteps[idDep]))
|
|
140
139
|
dependencies[idDep] = calcStepDependency(idDep, allSteps, values, customSteps);
|
|
141
|
-
if (addDependents
|
|
140
|
+
if (addDependents &&
|
|
141
|
+
!dependencies[idDep].dependents.find(function (dep) { return dep.id === step.id; }))
|
|
142
142
|
dependencies[idDep].dependents.push(step);
|
|
143
143
|
}
|
|
144
144
|
if (step.type === StepTypes.ENTITYVALUEPICKER) {
|
|
@@ -161,6 +161,10 @@ export function calcDependencies(steps, customSteps, allSteps, dependencies, val
|
|
|
161
161
|
var hasSubSteps = Object.keys(subSteps).length > 0;
|
|
162
162
|
calcDependencies(hasSubSteps ? subSteps : step.steps, customSteps, __assign(__assign({}, allSteps), subSteps), dependencies, values, hasSubSteps);
|
|
163
163
|
}
|
|
164
|
+
};
|
|
165
|
+
for (var _i = 0, _c = Object.values(steps); _i < _c.length; _i++) {
|
|
166
|
+
var step = _c[_i];
|
|
167
|
+
_loop_1(step);
|
|
164
168
|
}
|
|
165
169
|
return dependencies;
|
|
166
170
|
}
|
|
@@ -8,7 +8,7 @@ export type FillerSteps = FormSelector | ClassifierSelector | EntityValuePicker
|
|
|
8
8
|
export declare function calcFillerSize(step: FillerSteps, steps: Record<string, FormStep>, values: Record<string, unknown>, size: FormSize): number;
|
|
9
9
|
export declare const calcStepWidth: (stepSize: 1 | 2 | 3 | 4, size: FormSize) => number;
|
|
10
10
|
export declare const calcDefaultValue: (step: FormStep | CBRFormStep) => any;
|
|
11
|
-
export declare const iterateNestedSteps: (idStep: string, steps: Record<string, FormStep>, iteration: (step: FormStep
|
|
11
|
+
export declare const iterateNestedSteps: (idStep: string, steps: Record<string, FormStep>, iteration: (step: FormStep) => void) => void;
|
|
12
12
|
/**
|
|
13
13
|
* Utility function to calc the substeps of a step
|
|
14
14
|
* @param step step to calc the substeps
|
|
@@ -148,6 +148,10 @@ export var calcDefaultValue = function (step) {
|
|
|
148
148
|
};
|
|
149
149
|
export var iterateNestedSteps = function (idStep, steps, iteration) {
|
|
150
150
|
var step = steps[idStep];
|
|
151
|
+
if (!step) {
|
|
152
|
+
console.error('Missing Step:', idStep);
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
151
155
|
iteration(step);
|
|
152
156
|
if (step.type === StepTypes.MAPPER) {
|
|
153
157
|
for (var _i = 0, _a = step.rootSteps; _i < _a.length; _i++) {
|