@arquimedes.co/eureka-forms 1.4.6-test → 1.4.9-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 +4 -12
- package/dist/FormComponents/Form/ColumnForm/ColumnForm.js +6 -5
- package/dist/FormComponents/Step/@Construction/CBRLocativasStep/CBRLocativasStep.js +15 -6
- package/dist/FormComponents/Step/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.js +46 -30
- package/dist/FormComponents/Step/SmartSelectStep/SmartSelectStep.d.ts +3 -3
- package/dist/shared/RoundedSmartSelect/RoundedSmartSelect.js +3 -2
- package/package.json +1 -1
package/dist/App.js
CHANGED
|
@@ -68,18 +68,10 @@ import widgetInstance from './AxiosWidget';
|
|
|
68
68
|
function App(_a) {
|
|
69
69
|
var _this = this;
|
|
70
70
|
var _b, _c, _d, _e;
|
|
71
|
-
var apiKey = _a.apiKey, domain = _a.domain, preview = _a.preview, formData = _a.formData, postview = _a.postview, isWidget = _a.isWidget, internal = _a.internal, valuesData = _a.valuesData,
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
return [2 /*return*/];
|
|
76
|
-
});
|
|
77
|
-
}); } : _f, customSteps = _a.customSteps, handleConfirmed = _a.handleConfirmed, others = __rest(_a, ["apiKey", "domain", "preview", "formData", "postview", "isWidget", "internal", "valuesData", "customSend", "customSteps", "handleConfirmed"]);
|
|
78
|
-
// eslint-disable-next-line no-console
|
|
79
|
-
console.log(formData, valuesData, customSend);
|
|
80
|
-
var _g = useState(undefined), form = _g[0], setForm = _g[1];
|
|
81
|
-
var _h = useState({}), originalValues = _h[0], setOriginalValues = _h[1];
|
|
82
|
-
var _j = useState(undefined), organizationInfo = _j[0], setOrganizationInfo = _j[1];
|
|
71
|
+
var apiKey = _a.apiKey, domain = _a.domain, preview = _a.preview, formData = _a.formData, postview = _a.postview, isWidget = _a.isWidget, internal = _a.internal, valuesData = _a.valuesData, customSend = _a.customSend, customSteps = _a.customSteps, handleConfirmed = _a.handleConfirmed, others = __rest(_a, ["apiKey", "domain", "preview", "formData", "postview", "isWidget", "internal", "valuesData", "customSend", "customSteps", "handleConfirmed"]);
|
|
72
|
+
var _f = useState(undefined), form = _f[0], setForm = _f[1];
|
|
73
|
+
var _g = useState({}), originalValues = _g[0], setOriginalValues = _g[1];
|
|
74
|
+
var _h = useState(undefined), organizationInfo = _h[0], setOrganizationInfo = _h[1];
|
|
83
75
|
function fetchPreview(formData) {
|
|
84
76
|
return __awaiter(this, void 0, void 0, function () {
|
|
85
77
|
var response;
|
|
@@ -257,12 +257,13 @@ function stringToDraft(text) {
|
|
|
257
257
|
return draftStructure;
|
|
258
258
|
}
|
|
259
259
|
function calcDependencies(steps, originalValues) {
|
|
260
|
+
var _a;
|
|
260
261
|
var dependencies = {};
|
|
261
|
-
for (var _i = 0,
|
|
262
|
-
var step =
|
|
262
|
+
for (var _i = 0, _b = Object.values(steps); _i < _b.length; _i++) {
|
|
263
|
+
var step = _b[_i];
|
|
263
264
|
if (step.dependencies) {
|
|
264
|
-
for (var
|
|
265
|
-
var idDep = _c
|
|
265
|
+
for (var _c = 0, _d = step.dependencies; _c < _d.length; _c++) {
|
|
266
|
+
var idDep = _d[_c];
|
|
266
267
|
var depStep = steps[idDep];
|
|
267
268
|
if (depStep && dependencies[idDep] === undefined) {
|
|
268
269
|
switch (depStep === null || depStep === void 0 ? void 0 : depStep.type) {
|
|
@@ -277,7 +278,7 @@ function calcDependencies(steps, originalValues) {
|
|
|
277
278
|
break;
|
|
278
279
|
}
|
|
279
280
|
default:
|
|
280
|
-
dependencies[idDep] = originalValues[idDep];
|
|
281
|
+
dependencies[idDep] = (_a = originalValues[idDep]) !== null && _a !== void 0 ? _a : null;
|
|
281
282
|
break;
|
|
282
283
|
}
|
|
283
284
|
}
|
|
@@ -58,7 +58,12 @@ function CBRLocativasStep(props) {
|
|
|
58
58
|
} }, void 0), getOptions: getLocativasOptions, getOptionSelected: function (option, value) {
|
|
59
59
|
return option.id === value.id;
|
|
60
60
|
}, calcDepError: calcDepError, calcInvalidDeps: calcInvaidDependencies, valueOverwrite: function (value) {
|
|
61
|
-
|
|
61
|
+
if (value) {
|
|
62
|
+
return __assign(__assign({}, value), { subStep: props.step.subStep });
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
62
67
|
}, iconComponent: LeakIconComponent }, { children: _jsx(LocativasSubStepRenderer, {}, void 0) }), void 0));
|
|
63
68
|
}
|
|
64
69
|
export default CBRLocativasStep;
|
|
@@ -91,18 +96,22 @@ function LeakIconComponent(props) {
|
|
|
91
96
|
}
|
|
92
97
|
var getLocativasOptions = function (step, dependencyStore) { return __awaiter(void 0, void 0, void 0, function () {
|
|
93
98
|
var idProyecto, response, father_1, locativasList;
|
|
94
|
-
var _a
|
|
95
|
-
return __generator(this, function (
|
|
99
|
+
var _a;
|
|
100
|
+
return __generator(this, function (_b) {
|
|
96
101
|
if (step.dependencies) {
|
|
97
102
|
idProyecto = (_a = dependencyStore[step.dependencies[0]]) === null || _a === void 0 ? void 0 : _a.id;
|
|
98
103
|
if (!idProyecto) {
|
|
99
104
|
return [2 /*return*/, null]; //null para indicar que falta la depedency
|
|
100
105
|
}
|
|
101
106
|
response = LocativasData;
|
|
102
|
-
father_1 =
|
|
107
|
+
father_1 = dependencyStore[step.dependencies[1]];
|
|
108
|
+
if (father_1 !== undefined && father_1.id === undefined) {
|
|
109
|
+
return [2 /*return*/, null];
|
|
110
|
+
}
|
|
103
111
|
locativasList = response.lstLocativas.TipoLocativas.filter(function (locativa) {
|
|
104
|
-
if (father_1) {
|
|
105
|
-
return (locativa.Id.startsWith(father_1) &&
|
|
112
|
+
if (father_1 === null || father_1 === void 0 ? void 0 : father_1.id) {
|
|
113
|
+
return (locativa.Id.startsWith(father_1.id) &&
|
|
114
|
+
locativa.Id !== father_1.id);
|
|
106
115
|
}
|
|
107
116
|
else {
|
|
108
117
|
return locativa.Id.length === 2;
|
package/dist/FormComponents/Step/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.js
CHANGED
|
@@ -66,12 +66,22 @@ import React from 'react';
|
|
|
66
66
|
function SmartSelect(_a) {
|
|
67
67
|
var _this = this;
|
|
68
68
|
var _b, _c, _d;
|
|
69
|
-
var icon = _a.icon, step = _a.step, form = _a.form, value = _a.value, onBlur = _a.onBlur, errors = _a.errors, trigger = _a.trigger, children = _a.children, onChange = _a.onChange, inputRef = _a.inputRef, postview = _a.postview, formStyle = _a.formStyle, getOptions = _a.getOptions, widthStats = _a.widthStats, calcDepError = _a.calcDepError, iconComponent = _a.iconComponent, valueOverwrite = _a.valueOverwrite, dependencyStore = _a.dependencyStore,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
69
|
+
var icon = _a.icon, step = _a.step, form = _a.form, value = _a.value, onBlur = _a.onBlur, errors = _a.errors, trigger = _a.trigger, children = _a.children, onChange = _a.onChange, inputRef = _a.inputRef, postview = _a.postview, formStyle = _a.formStyle, getOptions = _a.getOptions, widthStats = _a.widthStats, calcDepError = _a.calcDepError, iconComponent = _a.iconComponent, valueOverwrite = _a.valueOverwrite, dependencyStore = _a.dependencyStore, _e = _a.calcInvalidDeps, calcInvalidDeps = _e === void 0 ? function (step, depStore) {
|
|
70
|
+
var _a;
|
|
71
|
+
var missingDeps = [];
|
|
72
|
+
for (var _i = 0, _b = (_a = step.dependencies) !== null && _a !== void 0 ? _a : []; _i < _b.length; _i++) {
|
|
73
|
+
var idDep = _b[_i];
|
|
74
|
+
if (depStore[idDep] === null) {
|
|
75
|
+
missingDeps.push(idDep);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return missingDeps;
|
|
79
|
+
} : _e, getOptionSelected = _a.getOptionSelected, setDependencyStore = _a.setDependencyStore, others = __rest(_a, ["icon", "step", "form", "value", "onBlur", "errors", "trigger", "children", "onChange", "inputRef", "postview", "formStyle", "getOptions", "widthStats", "calcDepError", "iconComponent", "valueOverwrite", "dependencyStore", "calcInvalidDeps", "getOptionSelected", "setDependencyStore"]);
|
|
80
|
+
var _f = useState(true), first = _f[0], setFirst = _f[1];
|
|
81
|
+
var _g = useState(), options = _g[0], setOptions = _g[1];
|
|
82
|
+
var _h = useState(), error = _h[0], setError = _h[1];
|
|
83
|
+
var calcOptions = function (currentValue, invalidDeps) { return __awaiter(_this, void 0, void 0, function () {
|
|
84
|
+
var resp, currentOption, invalids;
|
|
75
85
|
var _a;
|
|
76
86
|
return __generator(this, function (_b) {
|
|
77
87
|
switch (_b.label) {
|
|
@@ -79,9 +89,19 @@ function SmartSelect(_a) {
|
|
|
79
89
|
case 1:
|
|
80
90
|
resp = _b.sent();
|
|
81
91
|
if (resp !== null) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
92
|
+
if (invalidDeps !== undefined && currentValue) {
|
|
93
|
+
currentOption = resp.find(function (option) {
|
|
94
|
+
return getOptionSelected(option, currentValue);
|
|
95
|
+
});
|
|
96
|
+
if (!currentOption) {
|
|
97
|
+
setError('Este campo es obligatorio');
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
invalids = (_a = calcInvalidDeps === null || calcInvalidDeps === void 0 ? void 0 : calcInvalidDeps(step, dependencyStore)) !== null && _a !== void 0 ? _a : [];
|
|
102
|
+
if (invalids.length === 0) {
|
|
103
|
+
setError(undefined);
|
|
104
|
+
}
|
|
85
105
|
}
|
|
86
106
|
}
|
|
87
107
|
setOptions(resp);
|
|
@@ -90,34 +110,29 @@ function SmartSelect(_a) {
|
|
|
90
110
|
});
|
|
91
111
|
}); };
|
|
92
112
|
useEffect(function () {
|
|
93
|
-
var _a;
|
|
94
113
|
if (first) {
|
|
95
114
|
setFirst(false);
|
|
96
|
-
var
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
115
|
+
var invalids = calcInvalidDeps(step, dependencyStore);
|
|
116
|
+
setError(calcDepError === null || calcDepError === void 0 ? void 0 : calcDepError(invalids.map(function (idDep) { var _a; return (_a = form.steps[idDep]) === null || _a === void 0 ? void 0 : _a.type; })));
|
|
117
|
+
calcOptions(value, invalids);
|
|
100
118
|
}
|
|
101
|
-
else
|
|
102
|
-
|
|
119
|
+
else {
|
|
120
|
+
if (value)
|
|
121
|
+
onChange(null);
|
|
122
|
+
calcOptions(null);
|
|
103
123
|
}
|
|
104
|
-
calcOptions();
|
|
105
124
|
}, (_c = (_b = step.dependencies) === null || _b === void 0 ? void 0 : _b.map(function (dep) { return dependencyStore[dep]; })) !== null && _c !== void 0 ? _c : []);
|
|
106
125
|
var handleMissingDep = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
107
|
-
var
|
|
108
|
-
return __generator(this, function (
|
|
126
|
+
var invalids;
|
|
127
|
+
return __generator(this, function (_a) {
|
|
109
128
|
if (step.dependencies) {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
if (
|
|
114
|
-
|
|
129
|
+
invalids = calcInvalidDeps(step, dependencyStore);
|
|
130
|
+
setError(calcDepError === null || calcDepError === void 0 ? void 0 : calcDepError(invalids.map(function (idDep) { var _a; return (_a = form.steps[idDep]) === null || _a === void 0 ? void 0 : _a.type; })));
|
|
131
|
+
if (!value) {
|
|
132
|
+
if (invalids.length > 0) {
|
|
133
|
+
trigger(invalids, { shouldFocus: true });
|
|
115
134
|
}
|
|
116
135
|
}
|
|
117
|
-
setDepError(calcDepError === null || calcDepError === void 0 ? void 0 : calcDepError(missingDeps.map(function (idDep) { var _a; return (_a = form.steps[idDep]) === null || _a === void 0 ? void 0 : _a.type; })));
|
|
118
|
-
if (missingDeps.length > 0) {
|
|
119
|
-
trigger(missingDeps, { shouldFocus: true });
|
|
120
|
-
}
|
|
121
136
|
}
|
|
122
137
|
return [2 /*return*/];
|
|
123
138
|
});
|
|
@@ -139,9 +154,10 @@ function SmartSelect(_a) {
|
|
|
139
154
|
valueOverwrite
|
|
140
155
|
? onChange(valueOverwrite(value))
|
|
141
156
|
: onChange(value);
|
|
142
|
-
|
|
157
|
+
setError(undefined);
|
|
158
|
+
}, getOptionSelected: getOptionSelected, helperText: error !== null && error !== void 0 ? error : (errors[step.id]
|
|
143
159
|
? errors[step.id].message
|
|
144
|
-
: step.description), error:
|
|
160
|
+
: step.description), error: error !== undefined || !!errors[step.id] }, void 0) }), void 0), children &&
|
|
145
161
|
cloneElement(children, {
|
|
146
162
|
value: value,
|
|
147
163
|
stepProps: __assign({ step: step, form: form, errors: errors, trigger: trigger, postview: postview, formStyle: formStyle, widthStats: widthStats, dependencyStore: dependencyStore, setDependencyStore: setDependencyStore }, others),
|
|
@@ -10,9 +10,9 @@ export interface SmartSelectStepProps extends Omit<StepProps, 'step'> {
|
|
|
10
10
|
/** The iconComponent to display in the selector */
|
|
11
11
|
iconComponent?: any;
|
|
12
12
|
/** Function to call to get the options of the selector, return null if dependency is not met */
|
|
13
|
-
getOptions
|
|
13
|
+
getOptions: (step: GSmartSelect, dependencyStore: Record<string, any>) => Promise<any[] | null>;
|
|
14
14
|
/** Function to determine the currently selected option */
|
|
15
|
-
getOptionSelected
|
|
15
|
+
getOptionSelected: (option: any, value: any) => boolean;
|
|
16
16
|
/** Function that returns the error message based on the types of the missing Dependencies, undefined if no error msg */
|
|
17
17
|
calcDepError?: (types: Types[]) => string | undefined;
|
|
18
18
|
/** Function that returns the missing dependencies based on the current value */
|
|
@@ -20,7 +20,7 @@ export interface SmartSelectStepProps extends Omit<StepProps, 'step'> {
|
|
|
20
20
|
/** children to render */
|
|
21
21
|
children?: React.ReactElement<any, string>;
|
|
22
22
|
/** Function that overwrites the value before setting it */
|
|
23
|
-
valueOverwrite?: (value: any) => any;
|
|
23
|
+
valueOverwrite?: (value: any | null) => any;
|
|
24
24
|
}
|
|
25
25
|
declare function SmartSelectStep(props: SmartSelectStepProps): JSX.Element;
|
|
26
26
|
export default SmartSelectStep;
|
|
@@ -139,16 +139,17 @@ export default function RoundedSmartSelect(_a) {
|
|
|
139
139
|
return (_jsx(Autocomplete, { size: "small", fullWidth: true, openOnFocus: true, disabled: cantEdit || disabled, popupIcon: showIcon && icon ? icon : undefined, onOpen: function () {
|
|
140
140
|
//Show loading icon if loading
|
|
141
141
|
}, loading: loading, loadingText: 'Cargando...', closeIcon: false, options: options, getOptionLabel: function (option) {
|
|
142
|
+
var _a, _b;
|
|
142
143
|
// Value selected with enter, right from the input
|
|
143
144
|
if (typeof option === 'string') {
|
|
144
145
|
return option;
|
|
145
146
|
}
|
|
146
147
|
else if (option === null || option === void 0 ? void 0 : option.inputValue) {
|
|
147
|
-
return option.inputValue;
|
|
148
|
+
return (_a = option.inputValue) !== null && _a !== void 0 ? _a : '';
|
|
148
149
|
}
|
|
149
150
|
else {
|
|
150
151
|
// Regular option
|
|
151
|
-
return option.label;
|
|
152
|
+
return (_b = option.label) !== null && _b !== void 0 ? _b : '';
|
|
152
153
|
}
|
|
153
154
|
}, getOptionSelected: getOptionSelected, PopperComponent: function (_a) {
|
|
154
155
|
var style = _a.style, props = __rest(_a, ["style"]);
|
package/package.json
CHANGED