@arquimedes.co/eureka-forms 2.0.99 → 2.0.101
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/AppHooks.js +28 -9
- package/dist/Form/ConfirmationDialog/ConfirmationDialog.js +1 -1
- package/dist/Form/FormFunctions.js +2 -3
- package/dist/FormSteps/EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValuePickerStep.js +20 -1
- package/dist/FormSteps/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.d.ts +1 -1
- package/dist/FormSteps/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.js +15 -5
- package/dist/FormSteps/SmartSelectStep/SmartSelectStep.d.ts +2 -0
- package/package.json +1 -1
package/dist/App/AppHooks.js
CHANGED
|
@@ -68,11 +68,13 @@ import { calcDependencies } from '../Form/FormFunctions';
|
|
|
68
68
|
import { iterateNestedSteps } from '../FormSteps/StepFunctions';
|
|
69
69
|
import { createNextState } from '@reduxjs/toolkit';
|
|
70
70
|
import { BaseConfirmationMessage } from '../Contexts/FormContext';
|
|
71
|
+
import FormStepTypes from '../constants/FormStepTypes';
|
|
72
|
+
import { draftToString } from '../Utils/DraftFunctions';
|
|
71
73
|
export var useSetupApp = function (isEmbedded, _a) {
|
|
74
|
+
var _b;
|
|
72
75
|
var preview = _a.preview, internal = _a.internal, postview = _a.postview, partial = _a.partial, editable = _a.editable, handleConfirmed = _a.handleConfirmed, customSteps = _a.customSteps, valuesData = _a.valuesData, apiKey = _a.apiKey, formData = _a.formData, classifiers = _a.classifiers, others = __rest(_a, ["preview", "internal", "postview", "partial", "editable", "handleConfirmed", "customSteps", "valuesData", "apiKey", "formData", "classifiers"]);
|
|
73
|
-
var
|
|
74
|
-
var
|
|
75
|
-
var _d = useState(), branding = _d[0], setBranding = _d[1];
|
|
76
|
+
var _c = useState(undefined), form = _c[0], setForm = _c[1];
|
|
77
|
+
var _d = useState(undefined), organization = _d[0], setOrganization = _d[1];
|
|
76
78
|
var dispatch = useAppDispatch();
|
|
77
79
|
var loadOrg = function (idOrganization) { return __awaiter(void 0, void 0, void 0, function () {
|
|
78
80
|
var organization;
|
|
@@ -91,9 +93,6 @@ export var useSetupApp = function (isEmbedded, _a) {
|
|
|
91
93
|
//TODO cambiar el color del navbar en movil
|
|
92
94
|
// eslint-disable-next-line no-console
|
|
93
95
|
}
|
|
94
|
-
if (!organization.customBrandings) {
|
|
95
|
-
setBranding(organization.branding);
|
|
96
|
-
}
|
|
97
96
|
}
|
|
98
97
|
return [2 /*return*/, organization];
|
|
99
98
|
}
|
|
@@ -106,8 +105,6 @@ export var useSetupApp = function (isEmbedded, _a) {
|
|
|
106
105
|
case 0: return [4 /*yield*/, fetchForm(apiKey, idOrganization)];
|
|
107
106
|
case 1:
|
|
108
107
|
form = _a.sent();
|
|
109
|
-
if (form && form.branding)
|
|
110
|
-
setBranding(form.branding);
|
|
111
108
|
return [2 /*return*/, form];
|
|
112
109
|
}
|
|
113
110
|
});
|
|
@@ -161,7 +158,22 @@ export var useSetupApp = function (isEmbedded, _a) {
|
|
|
161
158
|
for (var _b = 0, _c = section.steps; _b < _c.length; _b++) {
|
|
162
159
|
var idStep = _c[_b];
|
|
163
160
|
iterateNestedSteps(idStep, form.steps, function (step) {
|
|
161
|
+
var _a, _b, _c;
|
|
164
162
|
step.idSection = section.id;
|
|
163
|
+
if (step.type === FormStepTypes.TITLE) {
|
|
164
|
+
if ((_a = step.title) === null || _a === void 0 ? void 0 : _a.blocks) {
|
|
165
|
+
if ((_b = step.title) === null || _b === void 0 ? void 0 : _b.blocks)
|
|
166
|
+
step.title = draftToString({
|
|
167
|
+
form: form,
|
|
168
|
+
dependencies: {},
|
|
169
|
+
}, step.title);
|
|
170
|
+
if ((_c = step.description) === null || _c === void 0 ? void 0 : _c.blocks)
|
|
171
|
+
step.description = draftToString({
|
|
172
|
+
form: form,
|
|
173
|
+
dependencies: {},
|
|
174
|
+
}, step.description);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
165
177
|
});
|
|
166
178
|
}
|
|
167
179
|
};
|
|
@@ -210,7 +222,14 @@ export var useSetupApp = function (isEmbedded, _a) {
|
|
|
210
222
|
handleConfirmed();
|
|
211
223
|
}
|
|
212
224
|
}, [form]);
|
|
213
|
-
return {
|
|
225
|
+
return {
|
|
226
|
+
form: form,
|
|
227
|
+
organization: organization,
|
|
228
|
+
branding: (organization === null || organization === void 0 ? void 0 : organization.customBrandings)
|
|
229
|
+
? (_b = form === null || form === void 0 ? void 0 : form.branding) !== null && _b !== void 0 ? _b : organization.branding
|
|
230
|
+
: organization === null || organization === void 0 ? void 0 : organization.branding,
|
|
231
|
+
reload: reload,
|
|
232
|
+
};
|
|
214
233
|
};
|
|
215
234
|
export var useLogRocket = function (organization, form, _a) {
|
|
216
235
|
var apiKey = _a.apiKey, internal = _a.internal, postview = _a.postview, preview = _a.preview;
|
|
@@ -66,7 +66,7 @@ function ConfirmationDialog(_a) {
|
|
|
66
66
|
if (global.confirmation.showLink) {
|
|
67
67
|
return (_jsxs(_Fragment, { children: [_jsx("div", __assign({ className: widthStats.isMobile
|
|
68
68
|
? styles.mobileLinkContainer
|
|
69
|
-
: styles.linkContainer }, { children: "Puedes consultar el estado
|
|
69
|
+
: styles.linkContainer }, { children: "Puedes consultar el estado aqu\u00ED:" })), _jsx("a", __assign({ className: styles.url, "data-testid": "ResUrl", target: "_blank", href: confirmation.url, style: {
|
|
70
70
|
color: '#293241',
|
|
71
71
|
fontSize: widthStats.isMobile ? '1rem' : '1.2rem',
|
|
72
72
|
} }, { children: confirmation.url }))] }));
|
|
@@ -228,7 +228,6 @@ function calcStepDependency(idStep, steps, values, customSteps) {
|
|
|
228
228
|
};
|
|
229
229
|
}
|
|
230
230
|
function calcStepDependencyValue(depStep, originalValue, customSteps) {
|
|
231
|
-
var _a;
|
|
232
231
|
var custom = customSteps[depStep === null || depStep === void 0 ? void 0 : depStep.type];
|
|
233
232
|
if (custom === null || custom === void 0 ? void 0 : custom.calcDependencyValue) {
|
|
234
233
|
return custom.calcDependencyValue(depStep, originalValue);
|
|
@@ -246,10 +245,10 @@ function calcStepDependencyValue(depStep, originalValue, customSteps) {
|
|
|
246
245
|
}
|
|
247
246
|
case FormStepTypes.MAPPER: {
|
|
248
247
|
//TODO: Esto aun no se usa
|
|
249
|
-
return
|
|
248
|
+
return {
|
|
250
249
|
elements: originalValue === null || originalValue === void 0 ? void 0 : originalValue.map(function (mapperValue) { var _a; return (_a = mapperValue.value) !== null && _a !== void 0 ? _a : mapperValue; }),
|
|
251
250
|
page: 0,
|
|
252
|
-
}
|
|
251
|
+
};
|
|
253
252
|
}
|
|
254
253
|
default:
|
|
255
254
|
return originalValue !== null && originalValue !== void 0 ? originalValue : null;
|
|
@@ -96,7 +96,7 @@ function EntityValuePickerStep(_a) {
|
|
|
96
96
|
: undefined;
|
|
97
97
|
});
|
|
98
98
|
}, []);
|
|
99
|
-
return (_jsxs(React.Fragment, { children: [dialogs !== undefined && ((_b = form.entities) === null || _b === void 0 ? void 0 : _b[step.idEntity]) && (_jsx(MaterialEntityValueDialog, { type: dialogs.current.type, entity: (_c = form.entities) === null || _c === void 0 ? void 0 : _c[step.idEntity], entityValue: dialogs.value, message: dialogs.current.message, handleClose: handleCloseDialog })), _jsx(StepFillerContainer, __assign({ step: step }, { children: _jsx(SmartSelect, { editable: editable, step: step, icon: step.icon ? _jsx(InputIcon, { icon: step.icon }) : undefined, getOptions: getEntityValueOptions, getOptionSelected: function (option, value) {
|
|
99
|
+
return (_jsxs(React.Fragment, { children: [dialogs !== undefined && ((_b = form.entities) === null || _b === void 0 ? void 0 : _b[step.idEntity]) && (_jsx(MaterialEntityValueDialog, { type: dialogs.current.type, entity: (_c = form.entities) === null || _c === void 0 ? void 0 : _c[step.idEntity], entityValue: dialogs.value, message: dialogs.current.message, handleClose: handleCloseDialog })), _jsx(StepFillerContainer, __assign({ step: step }, { children: _jsx(SmartSelect, { editable: editable, step: step, icon: step.icon ? _jsx(InputIcon, { icon: step.icon }) : undefined, getOptions: getEntityValueOptions, getOptionalDependencies: getOptionalDependencies, getOptionSelected: function (option, value) {
|
|
100
100
|
return option._id === value._id;
|
|
101
101
|
}, calcDepError: function (steps) {
|
|
102
102
|
for (var _i = 0, steps_1 = steps; _i < steps_1.length; _i++) {
|
|
@@ -235,3 +235,22 @@ var getEntityValueOptions = function (idOrganization, step, dependencyStore) { r
|
|
|
235
235
|
}
|
|
236
236
|
});
|
|
237
237
|
}); };
|
|
238
|
+
var getOptionalDependencies = function (step) {
|
|
239
|
+
var _a;
|
|
240
|
+
var optional = [];
|
|
241
|
+
for (var _i = 0, _b = step.filters; _i < _b.length; _i++) {
|
|
242
|
+
var filter = _b[_i];
|
|
243
|
+
switch (filter.type) {
|
|
244
|
+
case EntityValueDataTypes.STEP: {
|
|
245
|
+
if (filter.idStep &&
|
|
246
|
+
!filter.required &&
|
|
247
|
+
!((_a = step.dependencies) === null || _a === void 0 ? void 0 : _a.includes(filter.idStep)))
|
|
248
|
+
optional.push(filter.idStep);
|
|
249
|
+
break;
|
|
250
|
+
}
|
|
251
|
+
default:
|
|
252
|
+
break;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
return optional;
|
|
256
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { SmartSelectStepProps } from '../SmartSelectStep';
|
|
3
3
|
import { GSmartSelect } from '../../../@Types/GenericFormSteps';
|
|
4
|
-
declare function SmartSelectStep<StepType extends GSmartSelect>({ icon, step, editable, getOptions, calcDepError, defaultValue, filterOptions, valueOverwrite, getValueString, changeListener, getValueWarning, getOptionSelected, getOptionsConditionsIdSteps, renderNestedSteps, }: SmartSelectStepProps<StepType>): JSX.Element;
|
|
4
|
+
declare function SmartSelectStep<StepType extends GSmartSelect>({ icon, step, editable, getOptions, calcDepError, defaultValue, filterOptions, valueOverwrite, getValueString, changeListener, getValueWarning, getOptionSelected, getOptionalDependencies, getOptionsConditionsIdSteps, renderNestedSteps, }: SmartSelectStepProps<StepType>): JSX.Element;
|
|
5
5
|
export default SmartSelectStep;
|
|
@@ -45,6 +45,15 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
45
45
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
49
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
50
|
+
if (ar || !(i in from)) {
|
|
51
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
52
|
+
ar[i] = from[i];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
56
|
+
};
|
|
48
57
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
49
58
|
import { useFormContext } from 'react-hook-form';
|
|
50
59
|
import RoundedSmartSelect from '../../../Shared/RoundedSmartSelect/RoundedSmartSelect';
|
|
@@ -57,8 +66,8 @@ import { selectDependencies, selectStepDependencies, useFormStep, } from '../../
|
|
|
57
66
|
import MaterialInputContainer from '../../Utils/MaterialInputContainer/MaterialInputContainer';
|
|
58
67
|
function SmartSelectStep(_a) {
|
|
59
68
|
var _this = this;
|
|
60
|
-
var _b, _c, _d, _e, _f, _g
|
|
61
|
-
var icon = _a.icon, step = _a.step, editable = _a.editable, getOptions = _a.getOptions, calcDepError = _a.calcDepError, defaultValue = _a.defaultValue, filterOptions = _a.filterOptions, valueOverwrite = _a.valueOverwrite, getValueString = _a.getValueString, changeListener = _a.changeListener, getValueWarning = _a.getValueWarning, getOptionSelected = _a.getOptionSelected, _j = _a.getOptionsConditionsIdSteps, getOptionsConditionsIdSteps = _j === void 0 ? function () { return []; } : _j, renderNestedSteps = _a.renderNestedSteps;
|
|
69
|
+
var _b, _c, _d, _e, _f, _g;
|
|
70
|
+
var icon = _a.icon, step = _a.step, editable = _a.editable, getOptions = _a.getOptions, calcDepError = _a.calcDepError, defaultValue = _a.defaultValue, filterOptions = _a.filterOptions, valueOverwrite = _a.valueOverwrite, getValueString = _a.getValueString, changeListener = _a.changeListener, getValueWarning = _a.getValueWarning, getOptionSelected = _a.getOptionSelected, _h = _a.getOptionalDependencies, getOptionalDependencies = _h === void 0 ? function () { return []; } : _h, _j = _a.getOptionsConditionsIdSteps, getOptionsConditionsIdSteps = _j === void 0 ? function () { return []; } : _j, renderNestedSteps = _a.renderNestedSteps;
|
|
62
71
|
var _k = useFormStep(step, {
|
|
63
72
|
sizeChange: true,
|
|
64
73
|
defaultValue: defaultValue !== null && defaultValue !== void 0 ? defaultValue : null,
|
|
@@ -76,9 +85,10 @@ function SmartSelectStep(_a) {
|
|
|
76
85
|
var _p = useState(true), firstTime = _p[0], setFirstTime = _p[1];
|
|
77
86
|
var _q = useState(false), touched = _q[0], setTouched = _q[1];
|
|
78
87
|
var dispatch = useAppDispatch();
|
|
88
|
+
var allDeps = useMemo(function () { var _a; return __spreadArray(__spreadArray([], ((_a = step.dependencies) !== null && _a !== void 0 ? _a : []), true), getOptionalDependencies(step), true); }, []);
|
|
79
89
|
var idDependencies = useMemo(function () { return getOptionsConditionsIdSteps(step); }, []);
|
|
80
90
|
var dependencies = useAppSelector(function (state) {
|
|
81
|
-
return selectDependencies(state,
|
|
91
|
+
return selectDependencies(state, allDeps);
|
|
82
92
|
});
|
|
83
93
|
var deps = useAppSelector(function (state) {
|
|
84
94
|
return selectDependencies(state, idDependencies);
|
|
@@ -99,7 +109,7 @@ function SmartSelectStep(_a) {
|
|
|
99
109
|
else if (value && !step.searchable) {
|
|
100
110
|
setOptions([value]);
|
|
101
111
|
}
|
|
102
|
-
}, (
|
|
112
|
+
}, (_b = allDeps.map(function (dep) { var _a; return (_a = dependencies[dep]) === null || _a === void 0 ? void 0 : _a.value; })) !== null && _b !== void 0 ? _b : []);
|
|
103
113
|
var calcOptions = function (firstTime) { return __awaiter(_this, void 0, void 0, function () {
|
|
104
114
|
var resp, newValue, empty, error_1;
|
|
105
115
|
return __generator(this, function (_a) {
|
|
@@ -202,6 +212,6 @@ function SmartSelectStep(_a) {
|
|
|
202
212
|
}
|
|
203
213
|
return undefined;
|
|
204
214
|
}, [invalids, touched, value, filteredOptions]);
|
|
205
|
-
return (_jsxs(React.Fragment, { children: [_jsx(MaterialInputContainer, __assign({ step: step, onClick: onFocus, editable: editable }, { children: _jsx(RoundedSmartSelect, __assign({}, field, { inputRef: ref, value: value, handleUpdate: onChange, onFocus: onFocus, disabled: filteredOptions === null || disabled, hidden: disabled, loading: loading, options: filteredOptions !== null && filteredOptions !== void 0 ? filteredOptions : undefined, cantEdit: !editable || postview, fullWidth: true, backgroundColor: (
|
|
215
|
+
return (_jsxs(React.Fragment, { children: [_jsx(MaterialInputContainer, __assign({ step: step, onClick: onFocus, editable: editable }, { children: _jsx(RoundedSmartSelect, __assign({}, field, { inputRef: ref, value: value, handleUpdate: onChange, onFocus: onFocus, disabled: filteredOptions === null || disabled, hidden: disabled, loading: loading, options: filteredOptions !== null && filteredOptions !== void 0 ? filteredOptions : undefined, cantEdit: !editable || postview, fullWidth: true, backgroundColor: (_c = formStyle.stepBackgroundColor) !== null && _c !== void 0 ? _c : 'white', label: step.label, required: step.required, height: '31px', changeListener: changeListener, searchable: step.searchable, icon: step.showIcon ? icon : undefined, helperTextColor: formStyle.descriptionTextColor, focusColor: formStyle.primaryColor, outlineColor: formStyle.outlineColor, errorColor: formStyle.errorColor, color: formStyle.textColor, containerMargin: "0px", getOptionSelected: getOptionSelected, getValueString: getValueString, helperText: (_g = (_f = (_d = errorMsg !== null && errorMsg !== void 0 ? errorMsg : warning) !== null && _d !== void 0 ? _d : (_e = error === null || error === void 0 ? void 0 : error.message) === null || _e === void 0 ? void 0 : _e.toString()) !== null && _f !== void 0 ? _f : step.description) !== null && _g !== void 0 ? _g : undefined, error: !!errorMsg || !!warning || !!error })) })), renderNestedSteps === null || renderNestedSteps === void 0 ? void 0 : renderNestedSteps(value)] }));
|
|
206
216
|
}
|
|
207
217
|
export default SmartSelectStep;
|
|
@@ -18,6 +18,8 @@ export interface SmartSelectStepProps<StepType extends GSmartSelect = GSmartSele
|
|
|
18
18
|
getValueString: (value: any | undefined) => string;
|
|
19
19
|
/** Function to if currently selected option has warning */
|
|
20
20
|
getValueWarning?: (value: any | undefined) => string | null;
|
|
21
|
+
/** Function called to get the idSteps of the optional dependencies */
|
|
22
|
+
getOptionalDependencies?: (step: StepType) => string[];
|
|
21
23
|
/** Function called to get the idSteps of the step's conditions for better refreshing */
|
|
22
24
|
getOptionsConditionsIdSteps?: (step: StepType) => string[];
|
|
23
25
|
/** Function that returns the error message based on the steps of the missing Dependencies, undefined if no error msg */
|