@arquimedes.co/eureka-forms 2.0.58 → 2.0.60
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/Form/FormTypes/ColumnForm/ColumnForm.js +18 -3
- package/dist/Form/FormTypes/StepperForm/StepperForm.js +4 -0
- package/dist/FormSteps/MapperStep/MaterialMapperStep/MaterialMapperStep.js +3 -2
- package/dist/States/SiteSlice.d.ts +1 -0
- package/dist/States/SiteSlice.js +1 -1
- package/package.json +1 -1
|
@@ -51,10 +51,14 @@ import styles from './ColumnForm.module.css';
|
|
|
51
51
|
import React from 'react';
|
|
52
52
|
import Terms from '../../Terms/Terms';
|
|
53
53
|
import { useFormContext } from 'react-hook-form';
|
|
54
|
-
import { useAppSelector } from '../../../hooks';
|
|
54
|
+
import { useAppDispatch, useAppSelector } from '../../../hooks';
|
|
55
55
|
import Section from '../../Section/Section';
|
|
56
56
|
import CustomContext from '../../../Contexts/CustomContext';
|
|
57
57
|
import CustomBtn from '../../../Shared/CustomBtn/CustomBtn';
|
|
58
|
+
import FormContext from '../../../Contexts/FormContext';
|
|
59
|
+
import { addPagedValues } from '../../../States/SiteSlice';
|
|
60
|
+
import { getAppState } from '../../../Utils/store';
|
|
61
|
+
import { IdFormContext } from '../../../App/App';
|
|
58
62
|
function ColumnForm(_a) {
|
|
59
63
|
var _this = this;
|
|
60
64
|
var onSubmit = _a.onSubmit, customSubmitBtns = _a.customSubmitBtns;
|
|
@@ -62,14 +66,18 @@ function ColumnForm(_a) {
|
|
|
62
66
|
var _c = useAppSelector(function (state) { return state.global; }), postview = _c.postview, editable = _c.editable, formStyle = _c.formStyle;
|
|
63
67
|
var _d = useFormContext(), trigger = _d.trigger, getValues = _d.getValues, handleSubmit = _d.handleSubmit;
|
|
64
68
|
var sendLabel = useContext(CustomContext).sendLabel;
|
|
69
|
+
var form = useContext(FormContext);
|
|
70
|
+
var dispatch = useAppDispatch();
|
|
71
|
+
var idForm = useContext(IdFormContext);
|
|
65
72
|
var previous = useAppSelector(function (state) { return state.site.previousSections; });
|
|
66
73
|
var next = useAppSelector(function (state) { return state.site.nextSections; });
|
|
74
|
+
var idCurrent = useAppSelector(function (state) { return state.site.idCurrentSection; });
|
|
67
75
|
/** Esto se usa para no tener que escuchar todo el tiempo los errores del formulario */
|
|
68
76
|
var handleErrors = handleSubmit(function () { }, function (errors) {
|
|
69
77
|
console.error('Errors:', errors);
|
|
70
78
|
});
|
|
71
79
|
var submit = useCallback(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
72
|
-
var valid, values;
|
|
80
|
+
var valid, values, state;
|
|
73
81
|
return __generator(this, function (_a) {
|
|
74
82
|
switch (_a.label) {
|
|
75
83
|
case 0:
|
|
@@ -82,8 +90,15 @@ function ColumnForm(_a) {
|
|
|
82
90
|
handleErrors();
|
|
83
91
|
return [2 /*return*/, setLoading(false)];
|
|
84
92
|
}
|
|
85
|
-
|
|
93
|
+
values = getValues();
|
|
94
|
+
if (!idCurrent) return [3 /*break*/, 3];
|
|
95
|
+
return [4 /*yield*/, dispatch(getAppState({ idForm: idForm })).unwrap()];
|
|
86
96
|
case 2:
|
|
97
|
+
state = _a.sent();
|
|
98
|
+
addPagedValues(form.steps, values, state.site.values.sections[idCurrent]);
|
|
99
|
+
_a.label = 3;
|
|
100
|
+
case 3: return [4 /*yield*/, onSubmit(values)];
|
|
101
|
+
case 4:
|
|
87
102
|
values = _a.sent();
|
|
88
103
|
setLoading(false);
|
|
89
104
|
return [2 /*return*/, values];
|
|
@@ -58,6 +58,7 @@ import { getAppState } from '../../../Utils/store';
|
|
|
58
58
|
import { IdFormContext } from '../../../App/App';
|
|
59
59
|
import CustomBtn from '../../../Shared/CustomBtn/CustomBtn';
|
|
60
60
|
import FormContext from '../../../Contexts/FormContext';
|
|
61
|
+
import { addPagedValues } from '../../../States/SiteSlice';
|
|
61
62
|
function StepperForm(_a) {
|
|
62
63
|
var _this = this;
|
|
63
64
|
var _b, _c;
|
|
@@ -108,6 +109,9 @@ function StepperForm(_a) {
|
|
|
108
109
|
values = state.site.previousSections.reduce(function (v, idSection) { return (__assign(__assign({}, v), state.site.values.sections[idSection])); }, {});
|
|
109
110
|
/** Add the current section's values */
|
|
110
111
|
values = __assign(__assign({}, values), getValues());
|
|
112
|
+
if (idCurrent) {
|
|
113
|
+
addPagedValues(form.steps, values, state.site.values.sections[idCurrent]);
|
|
114
|
+
}
|
|
111
115
|
return [4 /*yield*/, onSubmit(values)];
|
|
112
116
|
case 3:
|
|
113
117
|
response = _a.sent();
|
|
@@ -110,10 +110,11 @@ function MapperStep(props) {
|
|
|
110
110
|
var _a = useFormStep(step, {
|
|
111
111
|
defaultValue: { elements: [], page: 0 },
|
|
112
112
|
rules: {
|
|
113
|
-
validate: function (
|
|
113
|
+
validate: function (_a) {
|
|
114
|
+
var elements = _a.elements;
|
|
114
115
|
return !step.required ||
|
|
115
116
|
(step.required &&
|
|
116
|
-
|
|
117
|
+
elements.filter(function (elem) { return !elem.deleted; }).length > 0);
|
|
117
118
|
},
|
|
118
119
|
},
|
|
119
120
|
}), ref = _a.ref, value = _a.value, onChange = _a.onChange, error = _a.error;
|
|
@@ -92,3 +92,4 @@ export declare const focusStep: import("@reduxjs/toolkit").ActionCreatorWithOpti
|
|
|
92
92
|
values: Record<string, any>;
|
|
93
93
|
}, "site/updateNestedValues">;
|
|
94
94
|
export default SiteSlice;
|
|
95
|
+
export declare function addPagedValues(steps: Record<string, FormStep>, values: Record<string, any>, original: Record<string, any>, path?: string): void;
|
package/dist/States/SiteSlice.js
CHANGED
|
@@ -144,7 +144,7 @@ export var SiteSlice = createSlice({
|
|
|
144
144
|
});
|
|
145
145
|
export var focusStep = (_a = SiteSlice.actions, _a.focusStep), clearDependency = _a.clearDependency, setStepDependency = _a.setStepDependency, addStepsDependencies = _a.addStepsDependencies, setEmptyDependency = _a.setEmptyDependency, handlePrevious = _a.handlePrevious, handleNext = _a.handleNext, updateNestedValues = _a.updateNestedValues;
|
|
146
146
|
export default SiteSlice;
|
|
147
|
-
function addPagedValues(steps, values, original, path) {
|
|
147
|
+
export function addPagedValues(steps, values, original, path) {
|
|
148
148
|
if (path === void 0) { path = ''; }
|
|
149
149
|
for (var _i = 0, _a = Object.values(steps); _i < _a.length; _i++) {
|
|
150
150
|
var step = _a[_i];
|