@arquimedes.co/eureka-forms 2.0.41 → 2.0.43
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 +51 -9
- package/dist/Form/FormFunctions.js +2 -1
- package/dist/FormSteps/CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxStep.js +7 -5
- package/dist/FormSteps/CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxStep.module.css +4 -0
- package/dist/FormSteps/CollapsibleStep/MaterialTitleStep/MaterialCollapsibleStep.js +13 -8
- package/dist/FormSteps/CollapsibleStep/MaterialTitleStep/MaterialCollapsibleStep.module.css +6 -0
- package/dist/FormSteps/StepFunctions.js +4 -2
- package/dist/FormSteps/Utils/@StepFiller/StepFiller.js +2 -2
- package/package.json +1 -1
package/dist/App/AppFunctions.js
CHANGED
|
@@ -9,6 +9,15 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
13
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
14
|
+
if (ar || !(i in from)) {
|
|
15
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
16
|
+
ar[i] = from[i];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
20
|
+
};
|
|
12
21
|
import { nanoid } from 'nanoid';
|
|
13
22
|
import StepTypes, { FormTypes } from '../constants/FormStepTypes';
|
|
14
23
|
import { getRawText, stringToDraft } from '../Utils/DraftFunctions';
|
|
@@ -133,7 +142,7 @@ export var calcRecursiveCondition = function (condition, ids) {
|
|
|
133
142
|
}
|
|
134
143
|
};
|
|
135
144
|
export var mapOriginalValue = function (step, value, values, form) {
|
|
136
|
-
var _a, _b, _c, _d, _e, _f;
|
|
145
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
137
146
|
if (!value)
|
|
138
147
|
return value;
|
|
139
148
|
switch (step === null || step === void 0 ? void 0 : step.type) {
|
|
@@ -152,8 +161,8 @@ export var mapOriginalValue = function (step, value, values, form) {
|
|
|
152
161
|
if (element.value) {
|
|
153
162
|
mappedElement.value = element.value;
|
|
154
163
|
}
|
|
155
|
-
for (var
|
|
156
|
-
var idStep = _h
|
|
164
|
+
for (var _h = 0, _j = Object.keys(step.steps); _h < _j.length; _h++) {
|
|
165
|
+
var idStep = _j[_h];
|
|
157
166
|
var newIdStep = step.id + '-' + idStep + '-' + idElement;
|
|
158
167
|
mappedElement.ids[idStep] = newIdStep;
|
|
159
168
|
var value_1 = mapOriginalValue(step.steps[idStep], element[idStep], values, form);
|
|
@@ -163,8 +172,25 @@ export var mapOriginalValue = function (step, value, values, form) {
|
|
|
163
172
|
values.sections[step.idSection][newIdStep] = value_1;
|
|
164
173
|
}
|
|
165
174
|
}
|
|
166
|
-
for (var
|
|
167
|
-
var
|
|
175
|
+
for (var _k = 0, _l = Object.values(step.steps); _k < _l.length; _k++) {
|
|
176
|
+
var subStep = _l[_k];
|
|
177
|
+
var dependencies = (_b = subStep.dependencies) !== null && _b !== void 0 ? _b : [];
|
|
178
|
+
if (subStep.condition) {
|
|
179
|
+
dependencies = __spreadArray(__spreadArray([], dependencies, true), calcNestedConditionSteps(subStep.condition), true).filter(function (item, i, ar) { return ar.indexOf(item) === i; });
|
|
180
|
+
}
|
|
181
|
+
for (var _m = 0, dependencies_1 = dependencies; _m < dependencies_1.length; _m++) {
|
|
182
|
+
var idDep = dependencies_1[_m];
|
|
183
|
+
var mappedIdDep = step.id + '-' + idDep + '-' + idElement;
|
|
184
|
+
if (!values.sections[step.idSection][idDep] &&
|
|
185
|
+
!values.global[mappedIdDep] &&
|
|
186
|
+
element[idDep]) {
|
|
187
|
+
values.global[mappedIdDep] = element[idDep];
|
|
188
|
+
mappedElement.ids[idDep] = mappedIdDep;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
for (var _o = 0, _p = Object.keys(element); _o < _p.length; _o++) {
|
|
193
|
+
var key = _p[_o];
|
|
168
194
|
if (step.steps[key] || key === 'id')
|
|
169
195
|
continue;
|
|
170
196
|
mappedElement.originalValues[key] = element[key];
|
|
@@ -180,12 +206,12 @@ export var mapOriginalValue = function (step, value, values, form) {
|
|
|
180
206
|
}
|
|
181
207
|
return getRawText(value === null || value === void 0 ? void 0 : value.draft, value === null || value === void 0 ? void 0 : value.text);
|
|
182
208
|
}
|
|
183
|
-
var defaultValue = (
|
|
209
|
+
var defaultValue = (_c = value.value) !== null && _c !== void 0 ? _c : value;
|
|
184
210
|
if (typeof defaultValue === 'string') {
|
|
185
211
|
return defaultValue;
|
|
186
212
|
}
|
|
187
213
|
else {
|
|
188
|
-
return (
|
|
214
|
+
return (_d = defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.text) !== null && _d !== void 0 ? _d : '';
|
|
189
215
|
}
|
|
190
216
|
}
|
|
191
217
|
case StepTypes.SELECTOR: {
|
|
@@ -195,9 +221,9 @@ export var mapOriginalValue = function (step, value, values, form) {
|
|
|
195
221
|
return value;
|
|
196
222
|
}
|
|
197
223
|
case StepTypes.CLASSIFIER_SELECTOR: {
|
|
198
|
-
var stepClassifier = (
|
|
224
|
+
var stepClassifier = (_e = form === null || form === void 0 ? void 0 : form.classifiers) === null || _e === void 0 ? void 0 : _e[(_f = step.idClassifier) !== null && _f !== void 0 ? _f : ''];
|
|
199
225
|
if (stepClassifier && !value.value) {
|
|
200
|
-
var classifier = (
|
|
226
|
+
var classifier = (_g = form.classifiers) === null || _g === void 0 ? void 0 : _g[value];
|
|
201
227
|
return { value: value, label: classifier === null || classifier === void 0 ? void 0 : classifier.name };
|
|
202
228
|
}
|
|
203
229
|
break;
|
|
@@ -211,6 +237,22 @@ export var mapOriginalValue = function (step, value, values, form) {
|
|
|
211
237
|
return value;
|
|
212
238
|
}
|
|
213
239
|
};
|
|
240
|
+
function calcNestedConditionSteps(condition) {
|
|
241
|
+
var steps = [];
|
|
242
|
+
if (!condition)
|
|
243
|
+
return steps;
|
|
244
|
+
switch (condition.type) {
|
|
245
|
+
case ConditionTypes.EXPRESSION:
|
|
246
|
+
return condition.conditions
|
|
247
|
+
.map(function (condition) { return calcNestedConditionSteps(condition); })
|
|
248
|
+
.flat();
|
|
249
|
+
case ConditionTypes.FORM_STEP:
|
|
250
|
+
return [condition.idStep];
|
|
251
|
+
default:
|
|
252
|
+
break;
|
|
253
|
+
}
|
|
254
|
+
return steps;
|
|
255
|
+
}
|
|
214
256
|
export var calcInitialSections = function (form) {
|
|
215
257
|
var previousSections = [];
|
|
216
258
|
var nextSections = calcNextSections(form.firstSection, form);
|
|
@@ -191,8 +191,9 @@ function calcStepDependency(idStep, steps, values, customSteps) {
|
|
|
191
191
|
var _a;
|
|
192
192
|
var depStep = steps[idStep];
|
|
193
193
|
if (!depStep) {
|
|
194
|
-
console.error('Missing Step Dependency:', idStep);
|
|
195
194
|
var originalValue_1 = values.global[idStep];
|
|
195
|
+
if (!originalValue_1)
|
|
196
|
+
console.error('Missing Step Dependency:', idStep);
|
|
196
197
|
return {
|
|
197
198
|
type: originalValue_1 ? 'ORIGINAL' : 'MISSING',
|
|
198
199
|
value: originalValue_1 !== null && originalValue_1 !== void 0 ? originalValue_1 : null,
|
|
@@ -38,10 +38,12 @@ function CheckBoxStep(_a) {
|
|
|
38
38
|
return (_jsx(StepComponent, { editable: editable, step: subStep }, idStep));
|
|
39
39
|
}) }));
|
|
40
40
|
};
|
|
41
|
-
return (_jsxs(StepFillerContainer, __assign({ step: step }, { children: [
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
return (_jsxs(StepFillerContainer, __assign({ step: step }, { children: [_jsx(MaterialInputContainer, __assign({ step: step, editable: editable }, { children: _jsxs("div", __assign({ className: styles.container }, { children: [_jsxs("div", __assign({ className: styles.labelCheckBoxContainer }, { children: [step.label && (_jsxs("div", __assign({ className: styles.checkboxLbl }, { children: [step.label, step.required ? ' *' : '', ":"] }))), _jsx(RoundedCheckBox, __assign({}, field, { inputRef: ref, onChange: onChange, "data-testid": step.id, padding: "0px", size: "1.6rem", error: !!error, cantEdit: !editable || postview, checkedColor: formStyle.primaryColor, uncheckedColor: formStyle.outlineColor, checked: value }))] })), (step.description || !!error) && (_jsx("div", __assign({ className: styles.descriptionPar, style: {
|
|
42
|
+
color: error
|
|
43
|
+
? formStyle.errorColor
|
|
44
|
+
: formStyle.descriptionTextColor,
|
|
45
|
+
} }, { children: error
|
|
46
|
+
? 'Este campo es obligatorio'
|
|
47
|
+
: step.description })))] })) })), renderNested()] })));
|
|
46
48
|
}
|
|
47
49
|
export default CheckBoxStep;
|
|
@@ -22,7 +22,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
22
22
|
};
|
|
23
23
|
import { createElement as _createElement } from "react";
|
|
24
24
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
25
|
-
import React, { useContext, useEffect } from 'react';
|
|
25
|
+
import React, { useContext, useEffect, useState } from 'react';
|
|
26
26
|
import styles from './MaterialCollapsibleStep.module.css';
|
|
27
27
|
import { Controller, useFormContext } from 'react-hook-form';
|
|
28
28
|
import StepComponent from '../../Step';
|
|
@@ -31,8 +31,9 @@ import ExpandLessRoundedIcon from '@material-ui/icons/ExpandLessRounded';
|
|
|
31
31
|
import FormContext from '../../../Contexts/FormContext';
|
|
32
32
|
import { useAppSelector } from '../../../hooks';
|
|
33
33
|
function Collapsible(_a) {
|
|
34
|
-
var _b, _c, _d
|
|
34
|
+
var _b, _c, _d;
|
|
35
35
|
var step = _a.step, open = _a.open, setOpen = _a.setOpen, others = __rest(_a, ["step", "open", "setOpen"]);
|
|
36
|
+
var _e = useState(true), firstTime = _e[0], setFirstTime = _e[1];
|
|
36
37
|
var formStyle = useAppSelector(function (state) { return state.global; }).formStyle;
|
|
37
38
|
var form = useContext(FormContext);
|
|
38
39
|
var errors = useFormContext().formState.errors;
|
|
@@ -47,15 +48,19 @@ function Collapsible(_a) {
|
|
|
47
48
|
color: formStyle.textColor,
|
|
48
49
|
borderColor: formStyle.primaryColor,
|
|
49
50
|
} }, { children: [_jsx("div", __assign({ className: styles.collapsibleLabel, onClick: function () {
|
|
51
|
+
if (firstTime)
|
|
52
|
+
setFirstTime(false);
|
|
50
53
|
setOpen(!open);
|
|
51
54
|
} }, { children: step.label })), _jsx("div", __assign({ className: styles.expand, onClick: function () {
|
|
55
|
+
if (firstTime)
|
|
56
|
+
setFirstTime(false);
|
|
52
57
|
setOpen(!open);
|
|
53
58
|
} }, { children: _jsx("div", __assign({ className: styles.expandIcon }, { children: open ? (_jsx(ExpandLessRoundedIcon, { fontSize: "inherit" })) : (_jsx(ExpandMoreRoundedIcon, { fontSize: "inherit" })) })) }))] })), _jsx("div", __assign({ className: styles.content, style: {
|
|
54
|
-
height: open
|
|
55
|
-
?
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
+
height: open
|
|
60
|
+
? firstTime
|
|
61
|
+
? 'auto'
|
|
62
|
+
: (_d = contentRef.current) === null || _d === void 0 ? void 0 : _d.offsetHeight
|
|
63
|
+
: 0,
|
|
59
64
|
} }, { children: _jsx("div", __assign({ className: styles.contentContainer, ref: contentRef }, { children: step.steps.map(function (idSubStep) {
|
|
60
65
|
var subStep = form.steps[idSubStep];
|
|
61
66
|
return (_createElement(StepComponent, __assign({}, others, { step: subStep, key: idSubStep })));
|
|
@@ -67,7 +72,7 @@ function CollapsibleStep(props) {
|
|
|
67
72
|
var _a;
|
|
68
73
|
var postview = useAppSelector(function (state) { return state.global; }).postview;
|
|
69
74
|
var _b = useFormContext(), clearErrors = _b.clearErrors, errors = _b.formState.errors;
|
|
70
|
-
return (_jsx(Controller, { name: props.step.id, defaultValue: (
|
|
75
|
+
return (_jsx(Controller, { name: props.step.id, defaultValue: (_a = props.step.defaultValue) !== null && _a !== void 0 ? _a : (postview ? false : true), render: function (_a) {
|
|
71
76
|
var _b = _a.field, value = _b.value, onChange = _b.onChange;
|
|
72
77
|
return (_jsx(Collapsible, __assign({}, props, { open: value, setOpen: function (open) {
|
|
73
78
|
var _a;
|
|
@@ -300,6 +300,7 @@ export var evaluateCondition = function (condition, dependencies) {
|
|
|
300
300
|
return boolFactor;
|
|
301
301
|
return !boolFactor;
|
|
302
302
|
}
|
|
303
|
+
var dependency = dependencies[condition.idStep];
|
|
303
304
|
var value = dependencies[condition.idStep].value;
|
|
304
305
|
switch (condition.stepType) {
|
|
305
306
|
// case FormStepTypes.AGENTPICKER:
|
|
@@ -332,11 +333,12 @@ export var evaluateCondition = function (condition, dependencies) {
|
|
|
332
333
|
}
|
|
333
334
|
}
|
|
334
335
|
case FormStepTypes.SELECTOR: {
|
|
336
|
+
var val = dependency.type === 'ORIGINAL' ? value : value.value;
|
|
335
337
|
if (condition.operator === OperatorTypes.EQUAL) {
|
|
336
|
-
return condition.value ===
|
|
338
|
+
return condition.value === val;
|
|
337
339
|
}
|
|
338
340
|
else {
|
|
339
|
-
return !(condition.value ===
|
|
341
|
+
return !(condition.value === val);
|
|
340
342
|
}
|
|
341
343
|
}
|
|
342
344
|
case FormStepTypes.TEXTINPUT: {
|
|
@@ -29,9 +29,9 @@ function StepFiller(_a) {
|
|
|
29
29
|
if (step.maxSize && step.maxSize < form.size.blockNum) {
|
|
30
30
|
return (_jsxs("div", __assign({ className: styles.firstLvlContainer, style: {
|
|
31
31
|
width: currentBreakPoint <= step.size ? '100%' : 'fit-content',
|
|
32
|
-
} }, { children: [_jsx(SizeChangeContext.Provider, __assign({ value: handleSizeChange }, { children: children })), _jsx("div", { className: styles.smallSeparator, style: {
|
|
32
|
+
} }, { children: [_jsx(SizeChangeContext.Provider, __assign({ value: handleSizeChange }, { children: children })), fillerSize > 0 && (_jsx("div", { className: styles.smallSeparator, style: {
|
|
33
33
|
width: fillerSize,
|
|
34
|
-
} })] })));
|
|
34
|
+
} }))] })));
|
|
35
35
|
}
|
|
36
36
|
else {
|
|
37
37
|
return (_jsxs(SizeChangeContext.Provider, __assign({ value: handleSizeChange }, { children: [children, step.maxSize && _jsx("div", { className: styles.separator })] })));
|