@arquimedes.co/eureka-forms 2.0.19 → 2.0.21
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/@Types/FormStep.d.ts +1 -0
- package/dist/App/App.js +2 -2
- package/dist/App/AppFunctions.js +1 -1
- package/dist/Form/Section/MaterialSection/MaterialSection.js +1 -1
- package/dist/Form/Terms/Term/MaterialTerm/MaterialTerm.js +1 -1
- package/dist/FormSteps/@Construction/CBRElementStep/CBRElementStep.js +2 -2
- package/dist/FormSteps/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/Incident/Incident.d.ts +1 -1
- package/dist/FormSteps/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/Incident/Incident.js +2 -2
- package/dist/FormSteps/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/MaterialCBRIncidentsStep.d.ts +1 -1
- package/dist/FormSteps/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/MaterialCBRIncidentsStep.js +23 -23
- package/dist/FormSteps/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/MaterialCBRIncidentsStep.module.css +6 -0
- package/dist/FormSteps/ApiSelectorStep/MaterialApiSelectorStep/MaterialApiSelectorStep.d.ts +2 -2
- package/dist/FormSteps/ApiSelectorStep/MaterialApiSelectorStep/MaterialApiSelectorStep.js +20 -63
- package/dist/FormSteps/ApiSelectorStep/MaterialApiSelectorStep/MaterialApiSelectorStep.module.css +0 -16
- package/dist/FormSteps/CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxStep.d.ts +1 -1
- package/dist/FormSteps/CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxStep.js +21 -76
- package/dist/FormSteps/CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxStep.module.css +0 -28
- package/dist/FormSteps/ClassifierSelectorStep/MaterialClassifierSelectorStep/MaterialClassifierSelectorStep.d.ts +1 -1
- package/dist/FormSteps/ClassifierSelectorStep/MaterialClassifierSelectorStep/MaterialClassifierSelectorStep.js +39 -96
- package/dist/FormSteps/CollapsibleStep/MaterialTitleStep/MaterialCollapsibleStep.js +2 -2
- package/dist/FormSteps/DatePickerStep/MaterialDatePickerStep/MaterialDatePickerStep.js +7 -38
- package/dist/FormSteps/EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValuePickerStep.d.ts +1 -1
- package/dist/FormSteps/EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValuePickerStep.js +20 -74
- package/dist/FormSteps/FileUploadStep/MaterialFileUploadStep/MaterialFileUploadStep.d.ts +2 -2
- package/dist/FormSteps/FileUploadStep/MaterialFileUploadStep/MaterialFileUploadStep.js +18 -42
- package/dist/FormSteps/MapperStep/MaterialMapperStep/Element/MapperElementComponent.js +2 -2
- package/dist/FormSteps/MapperStep/MaterialMapperStep/MaterialMapperStep.js +9 -5
- package/dist/FormSteps/RatingStep/MaterialRatingStep/MaterialRatingStep.d.ts +1 -1
- package/dist/FormSteps/RatingStep/MaterialRatingStep/MaterialRatingStep.js +15 -43
- package/dist/FormSteps/SelectorStep/MaterialSelectorStep/MaterialSelectorStep.d.ts +2 -2
- package/dist/FormSteps/SelectorStep/MaterialSelectorStep/MaterialSelectorStep.js +22 -78
- package/dist/FormSteps/SelectorStep/MaterialSelectorStep/MaterialSelectorStep.module.css +0 -16
- package/dist/FormSteps/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.d.ts +1 -9
- package/dist/FormSteps/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.js +26 -57
- package/dist/FormSteps/Step.d.ts +0 -2
- package/dist/FormSteps/StepFunctions.d.ts +2 -1
- package/dist/FormSteps/StepFunctions.js +71 -63
- package/dist/FormSteps/StepHooks.d.ts +16 -0
- package/dist/FormSteps/StepHooks.js +58 -2
- package/dist/FormSteps/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaEditorStep.js +3 -3
- package/dist/FormSteps/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaStep.js +6 -37
- package/dist/FormSteps/TextInputStep/MaterialTextInputStep/MaterialTextInputStep.js +13 -39
- package/dist/FormSteps/TitleStep/MaterialTitleStep/MaterialTitleStep.d.ts +1 -1
- package/dist/FormSteps/TitleStep/MaterialTitleStep/MaterialTitleStep.js +4 -24
- package/dist/FormSteps/Utils/@StepFiller/StepFiller.d.ts +9 -0
- package/dist/FormSteps/Utils/@StepFiller/StepFiller.js +48 -0
- package/dist/FormSteps/{EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValuePickerStep.module.css → Utils/@StepFiller/StepFiller.module.css} +16 -16
- package/dist/FormSteps/Utils/MaterialInputContainer/MaterialInputContainer.d.ts +11 -0
- package/dist/FormSteps/Utils/MaterialInputContainer/MaterialInputContainer.js +32 -0
- package/dist/FormSteps/{DatePickerStep/MaterialDatePickerStep/MaterialDatePickerStep.module.css → Utils/MaterialInputContainer/MaterialInputContainer.module.css} +9 -9
- package/dist/Shared/RoundedCheckBox/RoundedCheckBox.d.ts +3 -3
- package/dist/Shared/RoundedSmartSelect/RoundedSmartSelect.d.ts +1 -4
- package/dist/Shared/RoundedSmartSelect/RoundedSmartSelect.js +1 -3
- package/dist/States/SiteSlice.d.ts +2 -1
- package/dist/States/SiteSlice.js +25 -6
- package/dist/hooks.d.ts +2 -0
- package/dist/hooks.js +5 -1
- package/package.json +2 -2
- package/dist/FormSteps/ClassifierSelectorStep/MaterialClassifierSelectorStep/MaterialClassifierSelectorStep.module.css +0 -25
- package/dist/FormSteps/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.module.css +0 -9
package/dist/App/App.js
CHANGED
|
@@ -29,14 +29,14 @@ import FormComponent from '../Form/Form';
|
|
|
29
29
|
import { Provider } from 'react-redux';
|
|
30
30
|
import { store } from '../Utils/store';
|
|
31
31
|
import { useLogRocket, useSetupApp } from './AppHooks';
|
|
32
|
-
import { useAppSelector } from '../hooks';
|
|
32
|
+
import { StoreContext, useAppSelector } from '../hooks';
|
|
33
33
|
import CustomContext from '../Contexts/CustomContext';
|
|
34
34
|
import { nanoid } from '@reduxjs/toolkit';
|
|
35
35
|
export var IdFormContext = createContext('');
|
|
36
36
|
function AppComponent(_a) {
|
|
37
37
|
var formData = _a.formData, valuesData = _a.valuesData, props = __rest(_a, ["formData", "valuesData"]);
|
|
38
38
|
var idForm = React.useState(nanoid(6))[0];
|
|
39
|
-
return (_jsx(IdFormContext.Provider, __assign({ value: idForm }, { children: _jsx(Provider, __assign({ store: store }, { children: _jsx(App, __assign({ formData: formData, valuesData: valuesData }, props)) })) })));
|
|
39
|
+
return (_jsx(IdFormContext.Provider, __assign({ value: idForm }, { children: _jsx(Provider, __assign({ store: store, context: StoreContext }, { children: _jsx(App, __assign({ formData: formData, valuesData: valuesData }, props)) })) })));
|
|
40
40
|
}
|
|
41
41
|
export default AppComponent;
|
|
42
42
|
function App(_a) {
|
package/dist/App/AppFunctions.js
CHANGED
|
@@ -166,7 +166,7 @@ export var mapOriginalValue = function (step, value, values, form) {
|
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
168
|
case StepTypes.SELECTOR: {
|
|
169
|
-
var option = step.options.find(function (option) { return option.value
|
|
169
|
+
var option = step.options.find(function (option) { return option.value === value; });
|
|
170
170
|
if (!(value === null || value === void 0 ? void 0 : value.value))
|
|
171
171
|
return option;
|
|
172
172
|
return value;
|
|
@@ -35,7 +35,7 @@ function MaterialSection(_a) {
|
|
|
35
35
|
: 'normal',
|
|
36
36
|
} }, { children: (_b = section.steps) === null || _b === void 0 ? void 0 : _b.map(function (idStep) {
|
|
37
37
|
var step = form.steps[idStep];
|
|
38
|
-
return (_jsx(StepComponent, { editable: editable, step: step
|
|
38
|
+
return (_jsx(StepComponent, { editable: editable, step: step }, idStep));
|
|
39
39
|
}) })));
|
|
40
40
|
}
|
|
41
41
|
export default MaterialSection;
|
|
@@ -47,7 +47,7 @@ function TermComponent(_a) {
|
|
|
47
47
|
rules: {
|
|
48
48
|
required: true,
|
|
49
49
|
},
|
|
50
|
-
defaultValue: originalValue,
|
|
50
|
+
defaultValue: originalValue !== null && originalValue !== void 0 ? originalValue : false,
|
|
51
51
|
shouldUnregister: true,
|
|
52
52
|
}), _e = _d.field, ref = _e.ref, field = __rest(_e, ["ref"]), error = _d.fieldState.error;
|
|
53
53
|
var _f = useState(false), showDialog = _f[0], setShowDialog = _f[1];
|
|
@@ -80,14 +80,14 @@ function ElementSubStepRenderer(_a) {
|
|
|
80
80
|
var _b;
|
|
81
81
|
var value = _a.value, stepProps = __rest(_a, ["value"]);
|
|
82
82
|
var form = useContext(FormContext);
|
|
83
|
-
if (!value || stepProps
|
|
83
|
+
if (!value || stepProps === undefined) {
|
|
84
84
|
return _jsx("div", {});
|
|
85
85
|
}
|
|
86
86
|
var subStep = form.steps[(_b = stepProps.step.subStep) !== null && _b !== void 0 ? _b : ''];
|
|
87
87
|
if ((subStep === null || subStep === void 0 ? void 0 : subStep.type) !== CBRFormStepTypes.CBR_LOCATIVAS) {
|
|
88
88
|
return _jsx("div", {});
|
|
89
89
|
}
|
|
90
|
-
return (_jsx(SmartSelectStep, __assign({}, stepProps, { step: subStep,
|
|
90
|
+
return (_jsx(SmartSelectStep, __assign({}, stepProps, { step: subStep, icon: _jsx(InputIcon, { icon: 'LEAK' }), getOptions: getElementOptions, calcDepError: calcDepError, getOptionSelected: function (option, value) {
|
|
91
91
|
return option.id === value.id;
|
|
92
92
|
}, getValueString: function (value) { return value === null || value === void 0 ? void 0 : value.id; }, renderNestedSteps: function (value) { return (_jsx(ElementSubStepRenderer, __assign({ value: value }, stepProps, { step: subStep }))); } })));
|
|
93
93
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { CBRIncidentsStepProps } from '../../CBRIncidentsStep';
|
|
3
3
|
import { Incident } from '../MaterialCBRIncidentsStep';
|
|
4
|
-
declare function IncidentComponent({ step,
|
|
4
|
+
declare function IncidentComponent({ step, incident, handleDelete, ...others }: CBRIncidentsStepProps & {
|
|
5
5
|
incident: Incident;
|
|
6
6
|
handleDelete: () => void;
|
|
7
7
|
}): JSX.Element;
|
package/dist/FormSteps/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/Incident/Incident.js
CHANGED
|
@@ -29,7 +29,7 @@ import FormContext from '../../../../../Contexts/FormContext';
|
|
|
29
29
|
import { useAppSelector } from '../../../../../hooks';
|
|
30
30
|
import { useContext } from 'react';
|
|
31
31
|
function IncidentComponent(_a) {
|
|
32
|
-
var step = _a.step,
|
|
32
|
+
var step = _a.step, incident = _a.incident, handleDelete = _a.handleDelete, others = __rest(_a, ["step", "incident", "handleDelete"]);
|
|
33
33
|
var _b = useAppSelector(function (state) { return state.global; }), formStyle = _b.formStyle, postview = _b.postview;
|
|
34
34
|
var form = useContext(FormContext);
|
|
35
35
|
var widthStats = useAppSelector(function (state) { return state.widthStats; });
|
|
@@ -50,6 +50,6 @@ function IncidentComponent(_a) {
|
|
|
50
50
|
if (others.editable && !postview) {
|
|
51
51
|
handleDelete();
|
|
52
52
|
}
|
|
53
|
-
} }, { children: _jsx(DeleteRoundedIcon, { fontSize: "inherit" }) })), _jsx(StepComponent, __assign({}, others, { step: spaceStep
|
|
53
|
+
} }, { children: _jsx(DeleteRoundedIcon, { fontSize: "inherit" }) })), _jsx(StepComponent, __assign({}, others, { step: spaceStep })), _jsx(StepComponent, __assign({}, others, { step: elementStep })), _jsx(TextAreaStep, __assign({}, others, { step: commentStep, maxLength: 200 }))] })) })));
|
|
54
54
|
}
|
|
55
55
|
export default IncidentComponent;
|
|
@@ -7,5 +7,5 @@ export interface Incident {
|
|
|
7
7
|
deleted?: boolean;
|
|
8
8
|
num: number;
|
|
9
9
|
}
|
|
10
|
-
declare function CBRIncidentsStep(
|
|
10
|
+
declare function CBRIncidentsStep({ step, editable, ...others }: CBRIncidentsStepProps): JSX.Element;
|
|
11
11
|
export default CBRIncidentsStep;
|
|
@@ -41,27 +41,37 @@ import FormContext from '../../../../Contexts/FormContext';
|
|
|
41
41
|
import { addStepsDependencies } from '../../../../States/SiteSlice';
|
|
42
42
|
import { useAppDispatch, useAppSelector } from '../../../../hooks';
|
|
43
43
|
import CustomContext from '../../../../Contexts/CustomContext';
|
|
44
|
-
import {
|
|
45
|
-
function
|
|
46
|
-
var step = _a.step,
|
|
44
|
+
import { useFormStep } from '../../../StepHooks';
|
|
45
|
+
function CBRIncidentsStep(_a) {
|
|
46
|
+
var step = _a.step, editable = _a.editable, others = __rest(_a, ["step", "editable"]);
|
|
47
|
+
console.log(step.required);
|
|
48
|
+
var _b = useFormStep(step, {
|
|
49
|
+
rules: {
|
|
50
|
+
validate: function (array) {
|
|
51
|
+
return !step.required ||
|
|
52
|
+
(step.required &&
|
|
53
|
+
array.filter(function (elem) { return !elem.deleted; }).length > 0);
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
}), ref = _b.ref, value = _b.value, onChange = _b.onChange, error = _b.error;
|
|
47
57
|
var customSteps = useContext(CustomContext).customSteps;
|
|
48
|
-
var
|
|
58
|
+
var _c = useAppSelector(function (state) { return state.global; }), formStyle = _c.formStyle, postview = _c.postview;
|
|
49
59
|
var dispatch = useAppDispatch();
|
|
50
60
|
var form = useContext(FormContext);
|
|
51
61
|
/** Form to pass down with aditional steps */
|
|
52
|
-
var
|
|
53
|
-
var
|
|
62
|
+
var _d = useState(__assign(__assign({}, form), { steps: __assign({}, form.steps) })), localForm = _d[0], setLocalForm = _d[1];
|
|
63
|
+
var _e = useState(false), firstRender = _e[0], setFirstRender = _e[1];
|
|
54
64
|
useEffect(function () {
|
|
55
65
|
setFirstRender(true);
|
|
56
66
|
}, []);
|
|
57
67
|
useEffect(function () {
|
|
58
|
-
if (firstRender &&
|
|
68
|
+
if (firstRender && value.length === 0 && !postview && editable) {
|
|
59
69
|
handleAddIncident();
|
|
60
70
|
}
|
|
61
71
|
}, [firstRender]);
|
|
62
72
|
var handleAddIncident = function () {
|
|
63
73
|
var _a, _b;
|
|
64
|
-
var current =
|
|
74
|
+
var current = value.filter(function (incident) { return !incident.deleted; });
|
|
65
75
|
var newIncident = {
|
|
66
76
|
idSpaceStep: CBRFormStepTypes.CBR_TIPO_ESPACIO + '-' + nanoid(),
|
|
67
77
|
idCommentStep: CBRFormStepTypes.CBR_COMENTARIO + '-' + nanoid(),
|
|
@@ -72,7 +82,7 @@ function Incidents(_a) {
|
|
|
72
82
|
newSteps[newIncident.idSpaceStep] = __assign(__assign({}, step.spaceStep), { id: newIncident.idSpaceStep, type: CBRFormStepTypes.CBR_TIPO_ESPACIO, dependencies: step.dependencies });
|
|
73
83
|
newSteps[newIncident.idCommentStep] = __assign(__assign({}, step.commentStep), { id: newIncident.idCommentStep, type: CBRFormStepTypes.CBR_COMENTARIO });
|
|
74
84
|
addRecursiveElementStep(newIncident.idElementStep, step.elementStep, null, newSteps, (_b = (_a = step.dependencies) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : '');
|
|
75
|
-
onChange(__spreadArray(__spreadArray([],
|
|
85
|
+
onChange(__spreadArray(__spreadArray([], value, true), [newIncident], false));
|
|
76
86
|
setLocalForm(__assign(__assign({}, localForm), { steps: newSteps }));
|
|
77
87
|
dispatch(addStepsDependencies({
|
|
78
88
|
steps: newSteps,
|
|
@@ -98,8 +108,8 @@ function Incidents(_a) {
|
|
|
98
108
|
margin: step.description
|
|
99
109
|
? '10px 0px'
|
|
100
110
|
: '0px 0px 5px 0px',
|
|
101
|
-
} }, { children: step.description }))), _jsx(FormContext.Provider, __assign({ value: localForm }, { children:
|
|
102
|
-
var tempIncidents = __spreadArray([],
|
|
111
|
+
} }, { children: step.description }))), _jsx(FormContext.Provider, __assign({ value: localForm }, { children: value.map(function (incident, index) { return (_jsx(IncidentComponent, __assign({ incident: incident, step: step, editable: editable, handleDelete: function () {
|
|
112
|
+
var tempIncidents = __spreadArray([], value, true);
|
|
103
113
|
tempIncidents[index].deleted = true;
|
|
104
114
|
var n = 1;
|
|
105
115
|
for (var _i = 0, tempIncidents_1 = tempIncidents; _i < tempIncidents_1.length; _i++) {
|
|
@@ -110,20 +120,10 @@ function Incidents(_a) {
|
|
|
110
120
|
}
|
|
111
121
|
}
|
|
112
122
|
onChange(tempIncidents);
|
|
113
|
-
} }, others), index)); }) })), _jsxs("div", __assign({ className: styles.btnContainer }, { children: [_jsx("input", { ref:
|
|
123
|
+
} }, others), index)); }) })), _jsxs("div", __assign({ className: styles.btnContainer }, { children: [_jsx("input", { ref: ref, className: 'hidden-input' }), _jsx(RoundedButton, { disabled: !editable || postview, text: step.addBtnLabel + (step.required ? ' *' : ''), color: formStyle.primaryContrastColor, backgroundColor: formStyle.primaryColor, fontSize: '1rem', padding: '5px 15px 5px 15px', onClick: function () {
|
|
114
124
|
if (editable && !postview) {
|
|
115
125
|
handleAddIncident();
|
|
116
126
|
}
|
|
117
|
-
} })] }))] })));
|
|
118
|
-
}
|
|
119
|
-
function CBRIncidentsStep(props) {
|
|
120
|
-
return (_jsx(Controller, { name: props.step.id, defaultValue: [], rules: {
|
|
121
|
-
required: props.step.required
|
|
122
|
-
? 'Este campo es obligatorio'
|
|
123
|
-
: undefined,
|
|
124
|
-
}, shouldUnregister: true, render: function (_a) {
|
|
125
|
-
var _b = _a.field, ref = _b.ref, value = _b.value, field = __rest(_b, ["ref", "value"]);
|
|
126
|
-
return (_jsx(Incidents, __assign({}, props, field, { incidents: value, onChange: field.onChange, btnRef: ref })));
|
|
127
|
-
} }));
|
|
127
|
+
} })] })), !!error && value.filter(function (elem) { return !elem.deleted; }).length === 0 && (_jsx("div", __assign({ className: styles.errorMsg, style: { color: formStyle.errorColor } }, { children: "Este campo es obligatorio" })))] })));
|
|
128
128
|
}
|
|
129
129
|
export default CBRIncidentsStep;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ApiSelectorStepProps } from '../ApiSelectorStep';
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
declare function ApiSelectorComponent({ step, editable, ...others }: ApiSelectorStepProps): JSX.Element;
|
|
4
|
+
export default ApiSelectorComponent;
|
|
@@ -56,28 +56,19 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
56
56
|
}
|
|
57
57
|
return t;
|
|
58
58
|
};
|
|
59
|
-
import { jsx as _jsx,
|
|
60
|
-
import React, {
|
|
59
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
60
|
+
import React, { useContext } from 'react';
|
|
61
61
|
import FormStepTypes, { ApiSelectorOptionTypes, ApiSelectorParamTypes, } from '../../../constants/FormStepTypes';
|
|
62
|
-
import styles from './MaterialApiSelectorStep.module.css';
|
|
63
62
|
import StepComponent from '../../Step';
|
|
64
|
-
import
|
|
65
|
-
import { calcFillerSize } from '../../StepFunctions';
|
|
66
|
-
import { SmartSelect } from '../../SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep';
|
|
63
|
+
import SmartSelect from '../../SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep';
|
|
67
64
|
import widgetInstance from '../../../Utils/AxiosWidget';
|
|
68
65
|
import axiosInstance from '../../../Utils/AxiosAPI';
|
|
69
66
|
import InputIcon from '../../../Shared/InputIcon/InputIcon';
|
|
70
67
|
import FormContext from '../../../Contexts/FormContext';
|
|
71
|
-
import
|
|
72
|
-
import { useStepDependency } from '../../StepHooks';
|
|
68
|
+
import StepFillerContainer from '../../Utils/@StepFiller/StepFiller';
|
|
73
69
|
function ApiSelectorComponent(_a) {
|
|
74
|
-
var step = _a.step,
|
|
70
|
+
var step = _a.step, editable = _a.editable, others = __rest(_a, ["step", "editable"]);
|
|
75
71
|
var form = useContext(FormContext);
|
|
76
|
-
var currentBreakPoint = useAppSelector(selectBreakPoint);
|
|
77
|
-
var getValues = useFormContext().getValues;
|
|
78
|
-
var _b = useState(level === 0
|
|
79
|
-
? calcFillerSize(step, form.steps, getValues(), form.size)
|
|
80
|
-
: 0), fillerSize = _b[0], setFillerSize = _b[1];
|
|
81
72
|
function calcOptionId(option) {
|
|
82
73
|
var _a;
|
|
83
74
|
return (_a = option === null || option === void 0 ? void 0 : option[step.idAttribute]) !== null && _a !== void 0 ? _a : '';
|
|
@@ -86,14 +77,7 @@ function ApiSelectorComponent(_a) {
|
|
|
86
77
|
var _a;
|
|
87
78
|
return (_a = option === null || option === void 0 ? void 0 : option[step.labelAttribute]) !== null && _a !== void 0 ? _a : '';
|
|
88
79
|
}
|
|
89
|
-
|
|
90
|
-
handleSizeChange === null || handleSizeChange === void 0 ? void 0 : handleSizeChange();
|
|
91
|
-
if (level === 0) {
|
|
92
|
-
setFillerSize(calcFillerSize(step, form.steps, getValues(), form.size));
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
var renderSelect = function () {
|
|
96
|
-
return (_jsx(SmartSelect, __assign({}, others, { level: level, value: value, inputRef: inputRef, editable: editable, step: step, icon: step.icon ? _jsx(InputIcon, { icon: step.icon }) : undefined, getOptions: getApiOptions, getOptionSelected: function (option, value) {
|
|
80
|
+
return (_jsx(StepFillerContainer, __assign({ step: step }, { children: _jsx(SmartSelect, __assign({}, others, { editable: editable, step: step, icon: step.icon ? _jsx(InputIcon, { icon: step.icon }) : undefined, getOptions: getApiOptions, getOptionSelected: function (option, value) {
|
|
97
81
|
return calcOptionId(option) === calcOptionId(value);
|
|
98
82
|
}, calcDepError: function (steps) {
|
|
99
83
|
for (var _i = 0, steps_1 = steps; _i < steps_1.length; _i++) {
|
|
@@ -103,48 +87,21 @@ function ApiSelectorComponent(_a) {
|
|
|
103
87
|
}
|
|
104
88
|
}
|
|
105
89
|
return undefined;
|
|
106
|
-
}, getValueString: function (value) { return calcOptionLabel(value); }
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
if (level === 0 && step.maxSize && step.maxSize < form.size.blockNum) {
|
|
120
|
-
return (_jsxs("div", __assign({ className: styles.firstLvlContainer, style: {
|
|
121
|
-
width: currentBreakPoint <= step.size ? '100%' : 'fit-content',
|
|
122
|
-
} }, { children: [renderSelect(), mapNestedOption(), level === 0 && step.maxSize < form.size.blockNum && (_jsx("div", { className: styles.smallSeparator, style: {
|
|
123
|
-
width: fillerSize,
|
|
124
|
-
} }, "SEPARATOR"))] })));
|
|
125
|
-
}
|
|
126
|
-
else {
|
|
127
|
-
return (_jsxs(React.Fragment, { children: [renderSelect(), mapNestedOption(), level === 0 && step.maxSize && (_jsx("div", { className: styles.separator }))] }));
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
export default ApiSelectorStep;
|
|
131
|
-
function ApiSelectorStep(props) {
|
|
132
|
-
var step = props.step, defaultValue = props.defaultValue;
|
|
133
|
-
var _a = useStepDependency(step, defaultValue), handleStepDep = _a.handleStepDep, originalValue = _a.originalValue;
|
|
134
|
-
var _b = useController({
|
|
135
|
-
name: step.id,
|
|
136
|
-
rules: {
|
|
137
|
-
required: step.required ? 'Este campo es obligatorio' : undefined,
|
|
138
|
-
},
|
|
139
|
-
shouldUnregister: true,
|
|
140
|
-
defaultValue: originalValue,
|
|
141
|
-
}), _c = _b.field, ref = _c.ref, field = __rest(_c, ["ref"]), error = _b.fieldState.error;
|
|
142
|
-
var onChange = useCallback(function (value) {
|
|
143
|
-
handleStepDep(value);
|
|
144
|
-
field.onChange(value);
|
|
145
|
-
}, [handleStepDep, field]);
|
|
146
|
-
return (_jsx(ApiSelectorComponent, __assign({}, props, field, { error: error, inputRef: ref, onChange: onChange })));
|
|
90
|
+
}, getValueString: function (value) { return calcOptionLabel(value); }, renderNestedSteps: function (value) {
|
|
91
|
+
if (!value)
|
|
92
|
+
return _jsx(_Fragment, {});
|
|
93
|
+
var currentOption = step.options[calcOptionId(value)];
|
|
94
|
+
if ((currentOption === null || currentOption === void 0 ? void 0 : currentOption.type) === ApiSelectorOptionTypes.NESTED) {
|
|
95
|
+
return (_jsx(React.Fragment, { children: currentOption.steps.map(function (idStep) {
|
|
96
|
+
var subStep = form.steps[idStep];
|
|
97
|
+
return (_jsx(StepComponent, { editable: editable, step: subStep }, idStep));
|
|
98
|
+
}) }));
|
|
99
|
+
}
|
|
100
|
+
else
|
|
101
|
+
return _jsx(_Fragment, {});
|
|
102
|
+
} })) })));
|
|
147
103
|
}
|
|
104
|
+
export default ApiSelectorComponent;
|
|
148
105
|
var getApiOptions = function (idOrganization, step, dependencyStore) { return __awaiter(void 0, void 0, void 0, function () {
|
|
149
106
|
function calcOptionId(option) {
|
|
150
107
|
var _a;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { CheckBoxStepProps } from '../CheckBoxStep';
|
|
3
|
-
declare function CheckBoxStep(
|
|
3
|
+
declare function CheckBoxStep({ step, editable }: CheckBoxStepProps): JSX.Element;
|
|
4
4
|
export default CheckBoxStep;
|
|
@@ -9,92 +9,37 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
-
|
|
13
|
-
var t = {};
|
|
14
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
-
t[p] = s[p];
|
|
16
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
-
t[p[i]] = s[p[i]];
|
|
20
|
-
}
|
|
21
|
-
return t;
|
|
22
|
-
};
|
|
23
|
-
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
13
|
import styles from './MaterialCheckBoxStep.module.css';
|
|
25
|
-
import { calcFillerSize, calcStepWidth } from '../../StepFunctions';
|
|
26
14
|
import RoundedCheckBox from '../../../Shared/RoundedCheckBox/RoundedCheckBox';
|
|
27
|
-
import {
|
|
28
|
-
import React, { useCallback, useContext, useState } from 'react';
|
|
15
|
+
import React, { useContext } from 'react';
|
|
29
16
|
import StepComponent from '../../Step';
|
|
30
17
|
import FormContext from '../../../Contexts/FormContext';
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
18
|
+
import { useAppSelector } from '../../../hooks';
|
|
19
|
+
import { useFormStep } from '../../StepHooks';
|
|
20
|
+
import StepFillerContainer from '../../Utils/@StepFiller/StepFiller';
|
|
21
|
+
import MaterialInputContainer from '../../Utils/MaterialInputContainer/MaterialInputContainer';
|
|
22
|
+
function CheckBoxStep(_a) {
|
|
23
|
+
var step = _a.step, editable = _a.editable;
|
|
24
|
+
var _b = useFormStep(step, {
|
|
25
|
+
rules: {
|
|
26
|
+
required: step.required ? 'Este campo es obligatorio' : undefined,
|
|
27
|
+
},
|
|
28
|
+
sizeChange: true,
|
|
29
|
+
}), ref = _b.ref, value = _b.value, onChange = _b.onChange, error = _b.error, field = _b.field;
|
|
30
|
+
var _c = useAppSelector(function (state) { return state.global; }), formStyle = _c.formStyle, postview = _c.postview;
|
|
36
31
|
var form = useContext(FormContext);
|
|
37
|
-
var currentBreakPoint = useAppSelector(selectBreakPoint);
|
|
38
|
-
var _c = useFormContext(), getValues = _c.getValues, errors = _c.formState.errors;
|
|
39
|
-
var _d = useState(level === 0
|
|
40
|
-
? calcFillerSize(step, form.steps, getValues(), form.size)
|
|
41
|
-
: 0), fillerSize = _d[0], setFillerSize = _d[1];
|
|
42
|
-
var sizeChange = function () {
|
|
43
|
-
handleSizeChange === null || handleSizeChange === void 0 ? void 0 : handleSizeChange();
|
|
44
|
-
if (level === 0) {
|
|
45
|
-
setFillerSize(calcFillerSize(step, form.steps, getValues(), form.size));
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
var renderCheckbox = function () {
|
|
49
|
-
return (_jsxs("div", __assign({ className: styles.container, style: {
|
|
50
|
-
width: currentBreakPoint <= step.size
|
|
51
|
-
? '100%'
|
|
52
|
-
: calcStepWidth(step.size, form.size),
|
|
53
|
-
minHeight: step.description ||
|
|
54
|
-
(!postview && editable && step.required)
|
|
55
|
-
? '55px'
|
|
56
|
-
: '43px',
|
|
57
|
-
} }, { children: [_jsxs("div", __assign({ className: styles.labelCheckBoxContainer }, { children: [step.label && (_jsxs("div", __assign({ className: styles.checkboxLbl }, { children: [step.label, step.required ? ' *' : '', ":"] }))), _jsx(RoundedCheckBox, { onChange: onChange, onBlur: onBlur, "data-testid": step.id, inputRef: inputRef, padding: "0px", size: "1.6rem", error: !!errors[step.id], cantEdit: !editable || postview, checkedColor: formStyle.primaryColor, uncheckedColor: formStyle.outlineColor, checked: value })] })), (step.description || !!errors[step.id]) && (_jsx("div", __assign({ className: styles.descriptionPar, style: {
|
|
58
|
-
color: errors[step.id]
|
|
59
|
-
? formStyle.errorColor
|
|
60
|
-
: formStyle.descriptionTextColor,
|
|
61
|
-
} }, { children: errors[step.id]
|
|
62
|
-
? 'Este campo es obligatorio'
|
|
63
|
-
: step.description })))] }), step.id));
|
|
64
|
-
};
|
|
65
32
|
var renderNested = function () {
|
|
66
33
|
var steps = value ? step.steps : step.uncheckedSteps;
|
|
67
34
|
return (_jsx(React.Fragment, { children: steps === null || steps === void 0 ? void 0 : steps.map(function (idStep) {
|
|
68
35
|
var subStep = form.steps[idStep];
|
|
69
|
-
return (_jsx(StepComponent, { editable: editable, step: subStep
|
|
36
|
+
return (_jsx(StepComponent, { editable: editable, step: subStep }, idStep));
|
|
70
37
|
}) }));
|
|
71
38
|
};
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
} }, "SEPARATOR"))] })));
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
return (_jsxs(React.Fragment, { children: [renderCheckbox(), renderNested(), level === 0 && step.maxSize && (_jsx("div", { className: styles.separator }))] }));
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
function CheckBoxStep(props) {
|
|
84
|
-
var step = props.step;
|
|
85
|
-
var _a = useStepDependency(step), handleStepDep = _a.handleStepDep, originalValue = _a.originalValue;
|
|
86
|
-
var _b = useController({
|
|
87
|
-
name: step.id,
|
|
88
|
-
rules: {
|
|
89
|
-
required: step.required ? 'Este campo es obligatorio' : undefined,
|
|
90
|
-
},
|
|
91
|
-
shouldUnregister: true,
|
|
92
|
-
defaultValue: originalValue,
|
|
93
|
-
}).field, ref = _b.ref, field = __rest(_b, ["ref"]);
|
|
94
|
-
var onChange = useCallback(function (value) {
|
|
95
|
-
handleStepDep(value);
|
|
96
|
-
field.onChange(value);
|
|
97
|
-
}, [handleStepDep, field]);
|
|
98
|
-
return (_jsx(CheckBox, __assign({}, props, field, { inputRef: ref, onChange: onChange })));
|
|
39
|
+
return (_jsxs(StepFillerContainer, __assign({ step: step }, { children: [_jsxs(MaterialInputContainer, __assign({ step: step, editable: editable }, { 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: {
|
|
40
|
+
color: error
|
|
41
|
+
? formStyle.errorColor
|
|
42
|
+
: formStyle.descriptionTextColor,
|
|
43
|
+
} }, { children: error ? 'Este campo es obligatorio' : step.description })))] })), renderNested()] })));
|
|
99
44
|
}
|
|
100
45
|
export default CheckBoxStep;
|
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
.container {
|
|
2
|
-
width: fit-content;
|
|
3
|
-
max-width: calc(100% - 20px);
|
|
4
|
-
display: flex;
|
|
5
|
-
padding: 10px;
|
|
6
|
-
padding-bottom: 0px;
|
|
7
|
-
padding-top: 5px;
|
|
8
|
-
margin-bottom: 0px;
|
|
9
|
-
flex-direction: column;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
1
|
.checkboxLbl {
|
|
13
2
|
font-size: 18px;
|
|
14
3
|
margin-right: 10px;
|
|
@@ -35,20 +24,3 @@
|
|
|
35
24
|
overflow: hidden;
|
|
36
25
|
text-overflow: ellipsis;
|
|
37
26
|
}
|
|
38
|
-
|
|
39
|
-
.separator {
|
|
40
|
-
flex-basis: 100%;
|
|
41
|
-
height: 0;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.firstLvlContainer {
|
|
45
|
-
max-width: 100%;
|
|
46
|
-
display: flex;
|
|
47
|
-
flex-flow: row wrap;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
.smallSeparator {
|
|
51
|
-
height: 0;
|
|
52
|
-
max-width: 100%;
|
|
53
|
-
flex-basis: 0;
|
|
54
|
-
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ClassifierSelectorStepProps } from '../ClassifierSelectorStep';
|
|
3
|
+
declare function ClassifierSelectorStep({ step, editable, }: ClassifierSelectorStepProps): JSX.Element;
|
|
3
4
|
export default ClassifierSelectorStep;
|
|
4
|
-
declare function ClassifierSelectorStep(props: ClassifierSelectorStepProps): JSX.Element;
|