@arquimedes.co/eureka-forms 2.0.58 → 2.0.59

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.
@@ -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
- return [4 /*yield*/, onSubmit(getValues())];
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();
@@ -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;
@@ -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];
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.58",
4
+ "version": "2.0.59",
5
5
  "scripts": {
6
6
  "start": "react-scripts start",
7
7
  "build": "react-scripts build",