@arquimedes.co/eureka-forms 2.0.6-test → 2.0.8-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/AppFunctions.js +3 -3
- package/dist/App/AppHooks.js +1 -1
- package/dist/Form/FormFunctions.d.ts +3 -3
- package/dist/Form/FormFunctions.js +21 -17
- package/dist/FormSteps/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.js +4 -3
- package/dist/States/SiteStateReducer.js +1 -1
- package/package.json +1 -1
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
|
@@ -174,7 +174,7 @@ export var useSetupApp = function (isEmbedded, _a) {
|
|
|
174
174
|
values = calcValuesStore(valuesData !== null && valuesData !== void 0 ? valuesData : {}, form, dependencies, customSteps !== null && customSteps !== void 0 ? customSteps : {});
|
|
175
175
|
dispatch(reset(__assign(__assign({ formStyle: internal
|
|
176
176
|
? 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,
|
|
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) })));
|
|
178
178
|
return [2 /*return*/];
|
|
179
179
|
}
|
|
180
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
|
}
|
|
@@ -87,7 +87,7 @@ export function SmartSelect(_a) {
|
|
|
87
87
|
var isEmpty = useAppSelector(function (state) { var _a; return (_a = state.site.dependencies[step.id]) === null || _a === void 0 ? void 0 : _a.empty; });
|
|
88
88
|
var disabled = emptyDep;
|
|
89
89
|
useEffect(function () {
|
|
90
|
-
if (!postview) {
|
|
90
|
+
if (!postview && editable) {
|
|
91
91
|
calcOptions(firstTime);
|
|
92
92
|
if (firstTime)
|
|
93
93
|
setFirstTime(false);
|
|
@@ -116,9 +116,10 @@ export function SmartSelect(_a) {
|
|
|
116
116
|
newValue = resp.find(function (option) {
|
|
117
117
|
return getValueString(option) === getValueString(value);
|
|
118
118
|
});
|
|
119
|
-
|
|
119
|
+
if (!firstTime || newValue)
|
|
120
|
+
onChange(newValue);
|
|
120
121
|
}
|
|
121
|
-
else
|
|
122
|
+
else if (!firstTime)
|
|
122
123
|
onChange(null);
|
|
123
124
|
}
|
|
124
125
|
setOptions(resp);
|
|
@@ -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