@arquimedes.co/eureka-forms 1.7.1 → 1.7.3-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.js +24 -12
- package/dist/FormComponents/Step/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/MaterialCBRIncidentsStep.js +6 -1
- package/dist/FormComponents/Step/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.js +6 -1
- package/dist/shared/RoundedSmartSelect/RoundedSmartSelect.js +3 -4
- package/dist/utils/CbrFunctions.d.ts +8 -0
- package/dist/utils/CbrFunctions.js +53 -0
- package/package.json +1 -1
package/dist/App.js
CHANGED
|
@@ -66,6 +66,7 @@ import StepTypes from './constants/FormStepTypes';
|
|
|
66
66
|
import axiosInstance from './AxiosAPI';
|
|
67
67
|
import widgetInstance from './AxiosWidget';
|
|
68
68
|
import InternalFormStyle from './constants/InternalFormStyle';
|
|
69
|
+
import { calcCbrForm } from './utils/CbrFunctions';
|
|
69
70
|
function App(_a) {
|
|
70
71
|
var _this = this;
|
|
71
72
|
var _b, _c, _d, _e;
|
|
@@ -73,7 +74,24 @@ function App(_a) {
|
|
|
73
74
|
var _g = useState(undefined), form = _g[0], setForm = _g[1];
|
|
74
75
|
var _h = useState({}), originalValues = _h[0], setOriginalValues = _h[1];
|
|
75
76
|
var _j = useState(undefined), organizationInfo = _j[0], setOrganizationInfo = _j[1];
|
|
76
|
-
function
|
|
77
|
+
var migrateFormData = function (formData, valuesData) {
|
|
78
|
+
var form = migrateForm(formData);
|
|
79
|
+
var steps = Object.values(form.steps);
|
|
80
|
+
var hasCBR = steps.find(function (step) {
|
|
81
|
+
return step.type.startsWith('CBR');
|
|
82
|
+
});
|
|
83
|
+
if (hasCBR !== undefined) {
|
|
84
|
+
var CBRForm = calcCbrForm(form, valuesData !== null && valuesData !== void 0 ? valuesData : {});
|
|
85
|
+
setForm(CBRForm);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
setForm(form);
|
|
89
|
+
}
|
|
90
|
+
if (valuesData !== undefined) {
|
|
91
|
+
setOriginalValues(valuesData);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
function fetchPreview(formData, valuesData) {
|
|
77
95
|
return __awaiter(this, void 0, void 0, function () {
|
|
78
96
|
var response;
|
|
79
97
|
return __generator(this, function (_a) {
|
|
@@ -83,7 +101,7 @@ function App(_a) {
|
|
|
83
101
|
response = _a.sent();
|
|
84
102
|
if (response.data) {
|
|
85
103
|
setOrganizationInfo(response.data);
|
|
86
|
-
|
|
104
|
+
migrateFormData(formData, valuesData);
|
|
87
105
|
}
|
|
88
106
|
return [2 /*return*/];
|
|
89
107
|
}
|
|
@@ -93,15 +111,12 @@ function App(_a) {
|
|
|
93
111
|
useEffect(function () {
|
|
94
112
|
if (formData !== undefined) {
|
|
95
113
|
if (preview && formData.isStandAlone) {
|
|
96
|
-
fetchPreview(formData);
|
|
114
|
+
fetchPreview(formData, valuesData);
|
|
97
115
|
}
|
|
98
116
|
else {
|
|
99
|
-
|
|
117
|
+
migrateFormData(__assign({}, formData), valuesData);
|
|
100
118
|
setOrganizationInfo(null);
|
|
101
119
|
}
|
|
102
|
-
if (valuesData !== undefined) {
|
|
103
|
-
setOriginalValues(valuesData);
|
|
104
|
-
}
|
|
105
120
|
}
|
|
106
121
|
else if (!isWidget && apiKey) {
|
|
107
122
|
//Is iframe
|
|
@@ -212,10 +227,7 @@ function App(_a) {
|
|
|
212
227
|
case 1:
|
|
213
228
|
response = _a.sent();
|
|
214
229
|
if (response) {
|
|
215
|
-
|
|
216
|
-
if (valuesData !== undefined) {
|
|
217
|
-
setOriginalValues(valuesData);
|
|
218
|
-
}
|
|
230
|
+
migrateFormData(response.data, valuesData);
|
|
219
231
|
}
|
|
220
232
|
return [3 /*break*/, 3];
|
|
221
233
|
case 2:
|
|
@@ -273,7 +285,7 @@ export var SizesToNum = (_a = {},
|
|
|
273
285
|
_a[SIZES.MEDIUM] = 2,
|
|
274
286
|
_a[SIZES.SMALL] = 1,
|
|
275
287
|
_a);
|
|
276
|
-
var
|
|
288
|
+
var migrateForm = function (form) {
|
|
277
289
|
var steps = __assign({}, form.steps);
|
|
278
290
|
for (var _i = 0, _a = Object.keys(form.steps); _i < _a.length; _i++) {
|
|
279
291
|
var idStep = _a[_i];
|
|
@@ -31,7 +31,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
31
31
|
};
|
|
32
32
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
33
33
|
/* eslint-disable no-console */
|
|
34
|
-
import { useState } from 'react';
|
|
34
|
+
import { useEffect, useState } from 'react';
|
|
35
35
|
import { Controller } from 'react-hook-form';
|
|
36
36
|
import CBRFormStepTypes from '../../../../../constants/CBRFormStepTypes';
|
|
37
37
|
import IncidentComponent from './Incident/Incident';
|
|
@@ -42,6 +42,11 @@ function Incidents(_a) {
|
|
|
42
42
|
var step = _a.step, form = _a.form, btnRef = _a.btnRef, editable = _a.editable, postview = _a.postview, onChange = _a.onChange, incidents = _a.incidents, formStyle = _a.formStyle, dependencyStore = _a.dependencyStore, setDependencyStore = _a.setDependencyStore, others = __rest(_a, ["step", "form", "btnRef", "editable", "postview", "onChange", "incidents", "formStyle", "dependencyStore", "setDependencyStore"]);
|
|
43
43
|
/** Form to pass down with aditional steps */
|
|
44
44
|
var _b = useState(__assign(__assign({}, form), { steps: __assign({}, form.steps) })), localForm = _b[0], setLocalForm = _b[1];
|
|
45
|
+
useEffect(function () {
|
|
46
|
+
if (incidents.length === 0 && !postview && editable) {
|
|
47
|
+
handleAddIncident();
|
|
48
|
+
}
|
|
49
|
+
}, []);
|
|
45
50
|
var handleAddIncident = function () {
|
|
46
51
|
var _a, _b;
|
|
47
52
|
var current = incidents.filter(function (incident) { return !incident.deleted; });
|
package/dist/FormComponents/Step/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.js
CHANGED
|
@@ -80,6 +80,7 @@ function SmartSelect(_a) {
|
|
|
80
80
|
var _g = useState(true), first = _g[0], setFirst = _g[1];
|
|
81
81
|
var _h = useState(), options = _h[0], setOptions = _h[1];
|
|
82
82
|
var _j = useState(), error = _j[0], setError = _j[1];
|
|
83
|
+
var _k = useState(false), loading = _k[0], setLoading = _k[1];
|
|
83
84
|
var calcOptions = function (currentValue, invalidDeps) { return __awaiter(_this, void 0, void 0, function () {
|
|
84
85
|
var resp, currentOption, invalids;
|
|
85
86
|
var _a;
|
|
@@ -105,6 +106,7 @@ function SmartSelect(_a) {
|
|
|
105
106
|
}
|
|
106
107
|
}
|
|
107
108
|
setOptions(resp);
|
|
109
|
+
setLoading(false);
|
|
108
110
|
return [2 /*return*/];
|
|
109
111
|
}
|
|
110
112
|
});
|
|
@@ -132,6 +134,9 @@ function SmartSelect(_a) {
|
|
|
132
134
|
if (invalids.length > 0) {
|
|
133
135
|
trigger(invalids, { shouldFocus: true });
|
|
134
136
|
}
|
|
137
|
+
else {
|
|
138
|
+
setLoading(true);
|
|
139
|
+
}
|
|
135
140
|
}
|
|
136
141
|
}
|
|
137
142
|
return [2 /*return*/];
|
|
@@ -147,7 +152,7 @@ function SmartSelect(_a) {
|
|
|
147
152
|
if (options === null) {
|
|
148
153
|
handleMissingDep();
|
|
149
154
|
}
|
|
150
|
-
}, "data-testid": step.id }, { children: _jsx(RoundedSmartSelect, { value: value, onBlur: onBlur, disabled: options === null, loading:
|
|
155
|
+
}, "data-testid": step.id }, { children: _jsx(RoundedSmartSelect, { value: value, onBlur: onBlur, disabled: options === null, loading: loading, options: options !== null && options !== void 0 ? options : [], inputRef: inputRef, cantEdit: !editable || postview, fullWidth: true, backgroundColor: "transparent", innerBackgroundColor: (_d = formStyle.stepBackgroundColor) !== null && _d !== void 0 ? _d : 'white', label: step.label, required: step.required, height: '31px', searchable: step.searchable, icon: step.showIcon ? icon : undefined, iconComponent: step.showIcon ? iconComponent : undefined, helperTextColor: formStyle.descriptionTextColor, focusColor: formStyle.primaryColor, outlineColor: formStyle.outlineColor, errorColor: formStyle.errorColor, color: formStyle.textColor, containerMargin: "0px", handleUpdate: function (value) {
|
|
151
156
|
var _a;
|
|
152
157
|
if (dependencyStore[step.id] !== undefined) {
|
|
153
158
|
setDependencyStore(__assign(__assign({}, dependencyStore), (_a = {}, _a[step.id] = value, _a)));
|
|
@@ -26,6 +26,7 @@ import { makeStyles } from '@material-ui/core/styles';
|
|
|
26
26
|
import TextField from '@material-ui/core/TextField';
|
|
27
27
|
import { MenuItem, Popper } from '@material-ui/core';
|
|
28
28
|
import RoundedSelect from '../RoundedSelect/RoundedSelect';
|
|
29
|
+
import CircularProgress from '@material-ui/core/CircularProgress';
|
|
29
30
|
var filter = createFilterOptions();
|
|
30
31
|
var useTextfieldStyles = function (props) {
|
|
31
32
|
return makeStyles(function () { return ({
|
|
@@ -83,7 +84,7 @@ var useTextfieldStyles = function (props) {
|
|
|
83
84
|
marginTop: -10,
|
|
84
85
|
},
|
|
85
86
|
'& .EF-MuiAutocomplete-input::placeholder': {
|
|
86
|
-
color: '
|
|
87
|
+
color: '#787878',
|
|
87
88
|
opacity: 1,
|
|
88
89
|
},
|
|
89
90
|
},
|
|
@@ -139,9 +140,7 @@ export default function RoundedSmartSelect(_a) {
|
|
|
139
140
|
};
|
|
140
141
|
var textFieldClasses = useTextfieldStyles(props)();
|
|
141
142
|
if (searchable) {
|
|
142
|
-
return (_jsx(Autocomplete, { size: "small", fullWidth: true, openOnFocus: true, disabled: cantEdit || disabled, popupIcon: showIcon && icon ? icon : undefined, onOpen: function () {
|
|
143
|
-
//Show loading icon if loading
|
|
144
|
-
}, loading: loading, loadingText: 'Cargando...', closeIcon: false, options: options, getOptionLabel: function (option) {
|
|
143
|
+
return (_jsx(Autocomplete, { size: "small", fullWidth: true, openOnFocus: true, disabled: cantEdit || disabled, popupIcon: loading ? (_jsx(CircularProgress, { size: 22, style: { color: '#757575' } }, void 0)) : showIcon && icon ? (icon) : undefined, onOpen: function () { }, loading: loading, loadingText: 'Cargando...', closeIcon: false, options: options, getOptionLabel: function (option) {
|
|
145
144
|
var _a, _b;
|
|
146
145
|
// Value selected with enter, right from the input
|
|
147
146
|
if (typeof option === 'string') {
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import CBRFormStepTypes from '../constants/CBRFormStepTypes';
|
|
13
|
+
export var calcCbrForm = function (form, formValues) {
|
|
14
|
+
var _a;
|
|
15
|
+
for (var _i = 0, _b = Object.values(form.steps); _i < _b.length; _i++) {
|
|
16
|
+
var step = _b[_i];
|
|
17
|
+
if (step.type === CBRFormStepTypes.CBR_INCIDENCIAS) {
|
|
18
|
+
var incidentStep = step;
|
|
19
|
+
var incValue = formValues[(_a = incidentStep.id) !== null && _a !== void 0 ? _a : ''];
|
|
20
|
+
if (incValue) {
|
|
21
|
+
for (var _c = 0, incValue_1 = incValue; _c < incValue_1.length; _c++) {
|
|
22
|
+
var incident = incValue_1[_c];
|
|
23
|
+
handleAddIncident(incident, incidentStep, form.steps, formValues);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return form;
|
|
29
|
+
};
|
|
30
|
+
var handleAddIncident = function (incident, step, steps, formValues) {
|
|
31
|
+
var _a, _b;
|
|
32
|
+
var spaceStep = __assign(__assign({}, step.spaceStep), { id: incident.idSpaceStep, type: CBRFormStepTypes.CBR_TIPO_ESPACIO, dependencies: step.dependencies });
|
|
33
|
+
steps[incident.idSpaceStep] = spaceStep;
|
|
34
|
+
var commentStep = __assign(__assign({}, step.commentStep), { id: incident.idCommentStep, type: CBRFormStepTypes.CBR_COMENTARIO });
|
|
35
|
+
steps[incident.idCommentStep] = commentStep;
|
|
36
|
+
addRecursiveElementStep(incident.idElementStep, step.elementStep, null, steps, (_b = (_a = step.dependencies) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : '', formValues);
|
|
37
|
+
};
|
|
38
|
+
var addRecursiveElementStep = function (idStep, step, idParent, steps, idProjectDep, formValues) {
|
|
39
|
+
var _a, _b, _c;
|
|
40
|
+
var idSubStep = (_a = formValues[idStep]) === null || _a === void 0 ? void 0 : _a.subStep;
|
|
41
|
+
var newSubStep = step.subStep ? __assign({}, step.subStep) : undefined;
|
|
42
|
+
var newStep = __assign(__assign({}, step), { id: idStep, type: CBRFormStepTypes.CBR_LOCATIVAS, parentStep: idParent, dependencies: [idProjectDep], subStep: null });
|
|
43
|
+
if (newSubStep) {
|
|
44
|
+
newStep.subStep = idSubStep;
|
|
45
|
+
}
|
|
46
|
+
if (idParent) {
|
|
47
|
+
(_c = (_b = newStep.dependencies) === null || _b === void 0 ? void 0 : _b.push) === null || _c === void 0 ? void 0 : _c.call(_b, idParent);
|
|
48
|
+
}
|
|
49
|
+
steps[idStep] = newStep;
|
|
50
|
+
if (newSubStep) {
|
|
51
|
+
addRecursiveElementStep(idSubStep, newSubStep, idStep, steps, idProjectDep, formValues);
|
|
52
|
+
}
|
|
53
|
+
};
|
package/package.json
CHANGED