@arquimedes.co/eureka-forms 1.9.134 → 2.0.1-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/@Types/Form.d.ts +1 -1
- package/dist/@Types/FormStep.d.ts +2 -2
- package/dist/@Types/GenericFormSteps.d.ts +1 -0
- package/dist/App/App.css +6 -0
- package/dist/{App.d.ts → App/App.d.ts} +13 -21
- package/dist/App/App.js +76 -0
- package/dist/App/AppFunctions.d.ts +17 -0
- package/dist/App/AppFunctions.js +210 -0
- package/dist/App/AppHooks.d.ts +10 -0
- package/dist/App/AppHooks.js +235 -0
- package/dist/Contexts/CustomContext.d.ts +11 -0
- package/dist/Contexts/CustomContext.js +6 -0
- package/dist/Contexts/FormContext.d.ts +4 -0
- package/dist/Contexts/FormContext.js +19 -0
- package/dist/Contexts/SectionContext.d.ts +3 -0
- package/dist/Contexts/SectionContext.js +3 -0
- package/dist/Form/ConfirmationDialog/ConfirmationDialog.d.ts +2 -4
- package/dist/Form/ConfirmationDialog/ConfirmationDialog.js +3 -1
- package/dist/Form/Form.d.ts +17 -34
- package/dist/Form/Form.js +73 -124
- package/dist/Form/FormFunctions.d.ts +5 -4
- package/dist/Form/FormFunctions.js +24 -25
- package/dist/Form/FormTypes/ColumnForm/ColumnForm.d.ts +1 -1
- package/dist/Form/FormTypes/ColumnForm/ColumnForm.js +34 -58
- package/dist/Form/FormTypes/ColumnForm/ColumnForm.module.css +0 -4
- package/dist/Form/FormTypes/StepperForm/StepperForm.d.ts +1 -1
- package/dist/Form/FormTypes/StepperForm/StepperForm.js +122 -3
- package/dist/Form/FormTypes/StepperForm/StepperForm.module.css +53 -0
- package/dist/Form/Hooks.d.ts +9 -0
- package/dist/Form/Hooks.js +7 -0
- package/dist/Form/Section/MaterialSection/MaterialSection.d.ts +1 -1
- package/dist/Form/Section/MaterialSection/MaterialSection.js +15 -16
- package/dist/Form/Section/Section.d.ts +2 -34
- package/dist/Form/Section/Section.js +11 -5
- package/dist/Form/Terms/Term/MaterialTerm/MaterialTerm.d.ts +1 -1
- package/dist/Form/Terms/Term/MaterialTerm/MaterialTerm.js +19 -14
- package/dist/Form/Terms/Term/Term.d.ts +1 -8
- package/dist/Form/Terms/Term/Term.js +3 -1
- package/dist/Form/Terms/Terms.d.ts +1 -2
- package/dist/Form/Terms/Terms.js +17 -8
- package/dist/Form/Terms/Terms.module.css +3 -0
- package/dist/FormSteps/@Construction/CBRElementStep/CBRElementStep.d.ts +3 -3
- package/dist/FormSteps/@Construction/CBRElementStep/CBRElementStep.js +49 -38
- package/dist/FormSteps/@Construction/CBRIncidentsStep/CBRIncidentsStep.js +3 -1
- package/dist/FormSteps/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/Incident/Incident.d.ts +2 -2
- package/dist/FormSteps/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/Incident/Incident.js +11 -5
- package/dist/FormSteps/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/MaterialCBRIncidentsStep.js +29 -27
- package/dist/FormSteps/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/MaterialCBRIncidentsStep.module.css +0 -6
- package/dist/FormSteps/@Construction/CBRPropertyStep/CBRPropertyStep.js +39 -31
- package/dist/FormSteps/AYFStepMapper.js +42 -43
- package/dist/FormSteps/ApiSelectorStep/ApiSelectorStep.d.ts +1 -1
- package/dist/FormSteps/ApiSelectorStep/ApiSelectorStep.js +4 -14
- package/dist/FormSteps/ApiSelectorStep/MaterialApiSelectorStep/MaterialApiSelectorStep.js +84 -97
- package/dist/FormSteps/ApiSelectorStep/MaterialApiSelectorStep/MaterialApiSelectorStep.module.css +0 -9
- package/dist/FormSteps/CBRStepMapper.js +78 -74
- package/dist/FormSteps/CheckBoxStep/CheckBoxStep.d.ts +1 -1
- package/dist/FormSteps/CheckBoxStep/CheckBoxStep.js +4 -14
- package/dist/FormSteps/CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxStep.js +33 -26
- package/dist/FormSteps/CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxStep.module.css +17 -0
- package/dist/FormSteps/ClassifierSelectorStep/ClassifierSelectorStep.d.ts +1 -1
- package/dist/FormSteps/ClassifierSelectorStep/ClassifierSelectorStep.js +4 -14
- package/dist/FormSteps/ClassifierSelectorStep/MaterialClassifierSelectorStep/MaterialClassifierSelectorStep.js +34 -27
- package/dist/FormSteps/CollapsibleStep/CollapsibleStep.d.ts +1 -1
- package/dist/FormSteps/CollapsibleStep/CollapsibleStep.js +4 -2
- package/dist/FormSteps/CollapsibleStep/MaterialTitleStep/MaterialCollapsibleStep.js +16 -11
- package/dist/FormSteps/CustomStep.d.ts +22 -0
- package/dist/FormSteps/CustomStep.js +37 -0
- package/dist/FormSteps/DatePickerStep/DatePickerStep.js +3 -1
- package/dist/FormSteps/DatePickerStep/MaterialDatePickerStep/MaterialDatePickerStep.d.ts +1 -1
- package/dist/FormSteps/DatePickerStep/MaterialDatePickerStep/MaterialDatePickerStep.js +26 -14
- package/dist/FormSteps/EntityValueStep/EntityValuePickerStep.d.ts +1 -1
- package/dist/FormSteps/EntityValueStep/EntityValuePickerStep.js +4 -14
- package/dist/FormSteps/EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValuePickerStep.js +93 -112
- package/dist/FormSteps/EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValuePickerStep.module.css +0 -9
- package/dist/FormSteps/FileUploadStep/FileUploadStep.js +3 -1
- package/dist/FormSteps/FileUploadStep/MaterialFileUploadStep/FileComponent/FileComponent.d.ts +1 -1
- package/dist/FormSteps/FileUploadStep/MaterialFileUploadStep/FileComponent/FileComponent.js +1 -1
- package/dist/FormSteps/FileUploadStep/MaterialFileUploadStep/FileComponent/FileComponent.module.css +0 -7
- package/dist/FormSteps/FileUploadStep/MaterialFileUploadStep/MaterialFileUploadStep.js +32 -18
- package/dist/FormSteps/FileUploadStep/MaterialFileUploadStep/MaterialFileUploadStep.module.css +0 -7
- package/dist/FormSteps/MapperStep/MapperStep.d.ts +2 -2
- package/dist/FormSteps/MapperStep/MapperStep.js +4 -14
- package/dist/FormSteps/MapperStep/MaterialMapperStep/Element/ListMapperElement/ListMapperElement.d.ts +1 -9
- package/dist/FormSteps/MapperStep/MaterialMapperStep/Element/ListMapperElement/ListMapperElement.js +7 -2
- package/dist/FormSteps/MapperStep/MaterialMapperStep/Element/MapperElement.d.ts +3 -2
- package/dist/FormSteps/MapperStep/MaterialMapperStep/Element/MapperElement.js +18 -10
- package/dist/FormSteps/MapperStep/MaterialMapperStep/Element/PillMapperElement/PillMapperElement.d.ts +1 -9
- package/dist/FormSteps/MapperStep/MaterialMapperStep/Element/PillMapperElement/PillMapperElement.js +7 -2
- package/dist/FormSteps/MapperStep/MaterialMapperStep/MaterialMapperStep.d.ts +1 -1
- package/dist/FormSteps/MapperStep/MaterialMapperStep/MaterialMapperStep.js +44 -228
- package/dist/FormSteps/MapperStep/MaterialMapperStep/MaterialMapperStep.module.css +0 -7
- package/dist/FormSteps/RatingStep/MaterialRatingStep/MaterialRatingStep.js +30 -14
- package/dist/FormSteps/RatingStep/RatingStep.js +3 -1
- package/dist/FormSteps/SelectorStep/MaterialSelectorStep/MaterialSelectorStep.js +36 -26
- package/dist/FormSteps/SelectorStep/SelectorStep.d.ts +1 -1
- package/dist/FormSteps/SelectorStep/SelectorStep.js +4 -14
- package/dist/FormSteps/SeparatorStep/MaterialSeparatorStep/MaterialSeparatorStep.d.ts +1 -1
- package/dist/FormSteps/SeparatorStep/MaterialSeparatorStep/MaterialSeparatorStep.js +3 -1
- package/dist/FormSteps/SeparatorStep/SeparatorStep.d.ts +1 -1
- package/dist/FormSteps/SeparatorStep/SeparatorStep.js +4 -14
- package/dist/FormSteps/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.d.ts +5 -2
- package/dist/FormSteps/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.js +119 -199
- package/dist/FormSteps/SmartSelectStep/SmartSelectStep.d.ts +9 -10
- package/dist/FormSteps/SmartSelectStep/SmartSelectStep.js +3 -1
- package/dist/FormSteps/Step.d.ts +3 -4
- package/dist/FormSteps/Step.js +12 -8
- package/dist/FormSteps/StepFunctions.d.ts +10 -0
- package/dist/FormSteps/StepFunctions.js +156 -1
- package/dist/FormSteps/StepHooks.d.ts +23 -0
- package/dist/FormSteps/StepHooks.js +87 -0
- package/dist/FormSteps/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaEditorStep.d.ts +10 -0
- package/dist/FormSteps/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaEditorStep.js +148 -0
- package/dist/FormSteps/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaStep.d.ts +1 -6
- package/dist/FormSteps/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaStep.js +40 -186
- package/dist/FormSteps/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaStep.module.css +0 -9
- package/dist/FormSteps/TextAreaStep/TextAreaStep.js +8 -2
- package/dist/FormSteps/TextInputStep/MaterialTextInputStep/MaterialTextInputStep.d.ts +1 -1
- package/dist/FormSteps/TextInputStep/MaterialTextInputStep/MaterialTextInputStep.js +43 -42
- package/dist/FormSteps/TextInputStep/TextInputStep.js +3 -1
- package/dist/FormSteps/TitleStep/MaterialTitleStep/MaterialTitleStep.js +11 -6
- package/dist/FormSteps/TitleStep/TitleStep.d.ts +1 -1
- package/dist/FormSteps/TitleStep/TitleStep.js +4 -14
- package/dist/Icons/Construction/LeakIcon.d.ts +2 -2
- package/dist/Icons/Construction/LeakIcon.js +2 -1
- package/dist/Icons/Construction/ProjectIcon.d.ts +2 -2
- package/dist/Icons/Construction/ProjectIcon.js +2 -1
- package/dist/Icons/Construction/PropertyIcon.d.ts +2 -2
- package/dist/Icons/Construction/PropertyIcon.js +2 -1
- package/dist/Icons/Construction/SpaceIcon.d.ts +2 -2
- package/dist/Icons/Construction/SpaceIcon.js +2 -1
- package/dist/Icons/DocumentIcon.d.ts +2 -2
- package/dist/Icons/DocumentIcon.js +2 -1
- package/dist/Icons/Entities/CheckListIcon.d.ts +2 -2
- package/dist/Icons/Entities/CheckListIcon.js +2 -1
- package/dist/Icons/Entities/GenericEntityIcon.d.ts +2 -1
- package/dist/Icons/Entities/GenericEntityIcon.js +1 -1
- package/dist/Icons/Entities/HandshakeIcon.d.ts +2 -1
- package/dist/Icons/Entities/HandshakeIcon.js +1 -1
- package/dist/Icons/Entities/SupplierIcon.d.ts +2 -1
- package/dist/Icons/Entities/SupplierIcon.js +4 -1
- package/dist/{controllers → Services}/FileService.d.ts +1 -1
- package/dist/{controllers → Services}/FileService.js +5 -5
- package/dist/Services/FormService.d.ts +5 -0
- package/dist/Services/FormService.js +59 -0
- package/dist/Services/OrganizationService.d.ts +2 -0
- package/dist/Services/OrganizationService.js +65 -0
- package/dist/Shared/Navbar/Navbar.module.css +8 -0
- package/dist/{shared → Shared}/Rating/Rating.d.ts +1 -1
- package/dist/Shared/Rating/Rating.module.css +18 -0
- package/dist/{shared → Shared}/Rating/Ratings/LikeRating.js +5 -5
- package/dist/{shared → Shared}/Rating/Ratings/SatisfactionRating.js +9 -9
- package/dist/{shared → Shared}/Rating/Ratings/ScaleRating.js +1 -2
- package/dist/{shared → Shared}/RoundedCheckBox/RoundedCheckBox.d.ts +1 -1
- package/dist/{shared → Shared}/RoundedSmartSelect/RoundedSmartSelect.js +4 -4
- package/dist/{shared → Shared}/RoundedTextField/RoundedTextField.d.ts +1 -1
- package/dist/{shared → Shared}/RoundedTextField/RoundedTextField.js +3 -2
- package/dist/Shared/RoundedTextField/RoundedTextField.stories.d.ts +24 -0
- package/dist/Shared/RoundedTextField/RoundedTextField.stories.js +25 -0
- package/dist/States/GlobalStateReducer.d.ts +35 -0
- package/dist/States/GlobalStateReducer.js +34 -0
- package/dist/States/SiteStateReducer.d.ts +63 -0
- package/dist/States/SiteStateReducer.js +110 -0
- package/dist/States/WidthStatsStateReducer.d.ts +11 -0
- package/dist/States/WidthStatsStateReducer.js +64 -0
- package/dist/Utils/DraftFunctions.d.ts +3 -0
- package/dist/Utils/DraftFunctions.js +42 -0
- package/dist/Utils/MaterialProviders.d.ts +6 -0
- package/dist/Utils/MaterialProviders.js +31 -0
- package/dist/Utils/store.d.ts +25 -0
- package/dist/Utils/store.js +52 -0
- package/dist/Widget.js +3 -3
- package/dist/constants/CBRFormStepTypes.d.ts +2 -2
- package/dist/constants/CBRFormStepTypes.js +22 -22
- package/dist/hooks.d.ts +5 -0
- package/dist/hooks.js +7 -0
- package/dist/index.js +1 -1
- package/dist/index.lib.d.ts +1 -1
- package/dist/index.lib.js +1 -1
- package/package.json +63 -44
- package/dist/App.js +0 -472
- package/dist/shared/Navbar/Navbar.module.css +0 -18
- package/dist/shared/Rating/Rating.module.css +0 -32
- package/dist/{App.module.css → App/App.module.css} +0 -0
- package/dist/{shared → Shared}/InputIcon/InputIcon.d.ts +0 -0
- package/dist/{shared → Shared}/InputIcon/InputIcon.js +0 -0
- package/dist/{shared → Shared}/Loader/Loader.d.ts +0 -0
- package/dist/{shared → Shared}/Loader/Loader.js +0 -0
- package/dist/{shared → Shared}/Loader/Loader.module.css +0 -0
- package/dist/{shared → Shared}/Navbar/Navbar.d.ts +0 -0
- package/dist/{shared → Shared}/Navbar/Navbar.js +0 -0
- package/dist/{shared → Shared}/Rating/Rating.js +2 -2
- /package/dist/{shared → Shared}/Rating/Ratings/LikeRating.d.ts +0 -0
- /package/dist/{shared → Shared}/Rating/Ratings/SatisfactionRating.d.ts +0 -0
- /package/dist/{shared → Shared}/Rating/Ratings/ScaleRating.d.ts +0 -0
- /package/dist/{shared → Shared}/RoundedButton/RoundedButton.d.ts +0 -0
- /package/dist/{shared → Shared}/RoundedButton/RoundedButton.js +0 -0
- /package/dist/{shared → Shared}/RoundedCheckBox/RoundedCheckBox.js +0 -0
- /package/dist/{shared → Shared}/RoundedDatePicker/RoundedDatePicker.d.ts +0 -0
- /package/dist/{shared → Shared}/RoundedDatePicker/RoundedDatePicker.js +0 -0
- /package/dist/{shared → Shared}/RoundedSelect/RoundedSelect.d.ts +0 -0
- /package/dist/{shared → Shared}/RoundedSelect/RoundedSelect.js +0 -0
- /package/dist/{shared → Shared}/RoundedSmartSelect/RoundedSmartSelect.d.ts +0 -0
- /package/dist/{AxiosAPI.d.ts → Utils/AxiosAPI.d.ts} +0 -0
- /package/dist/{AxiosAPI.js → Utils/AxiosAPI.js} +0 -0
- /package/dist/{AxiosWidget.d.ts → Utils/AxiosWidget.d.ts} +0 -0
- /package/dist/{AxiosWidget.js → Utils/AxiosWidget.js} +0 -0
- /package/dist/{utils/CbrFunctions.d.ts → Utils/CBRFunctions.d.ts} +0 -0
- /package/dist/{utils/CbrFunctions.js → Utils/CBRFunctions.js} +0 -0
|
@@ -45,82 +45,58 @@ 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
|
-
|
|
49
|
-
|
|
50
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
51
|
-
t[p] = s[p];
|
|
52
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
53
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
54
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
55
|
-
t[p[i]] = s[p[i]];
|
|
56
|
-
}
|
|
57
|
-
return t;
|
|
58
|
-
};
|
|
59
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
60
|
-
import { cloneElement, useState } from 'react';
|
|
61
|
-
import SectionComponent from '../../Section/Section';
|
|
48
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
49
|
+
import { useCallback, useContext, useState } from 'react';
|
|
62
50
|
import styles from './ColumnForm.module.css';
|
|
63
|
-
import Loader from '../../../
|
|
51
|
+
import Loader from '../../../Shared/Loader/Loader';
|
|
64
52
|
import React from 'react';
|
|
65
53
|
import Terms from '../../Terms/Terms';
|
|
54
|
+
import { useFormContext } from 'react-hook-form';
|
|
55
|
+
import { useAppSelector } from '../../../hooks';
|
|
56
|
+
import Section from '../../Section/Section';
|
|
57
|
+
import CustomContext from '../../../Contexts/CustomContext';
|
|
66
58
|
function ColumnForm(_a) {
|
|
67
59
|
var _this = this;
|
|
68
|
-
var
|
|
69
|
-
var
|
|
70
|
-
var
|
|
71
|
-
var
|
|
72
|
-
var
|
|
73
|
-
var
|
|
60
|
+
var onSubmit = _a.onSubmit, customSubmitBtns = _a.customSubmitBtns;
|
|
61
|
+
var _b = useState(false), loading = _b[0], setLoading = _b[1];
|
|
62
|
+
var _c = useAppSelector(function (state) { return state.global; }), postview = _c.postview, editable = _c.editable, formStyle = _c.formStyle;
|
|
63
|
+
var _d = useFormContext(), trigger = _d.trigger, getValues = _d.getValues, handleSubmit = _d.handleSubmit;
|
|
64
|
+
var sendLabel = useContext(CustomContext).sendLabel;
|
|
65
|
+
var previous = useAppSelector(function (state) { return state.site.previousSections; });
|
|
66
|
+
var next = useAppSelector(function (state) { return state.site.nextSections; });
|
|
67
|
+
/** Esto se usa para no tener que escuchar todo el tiempo los errores del formulario */
|
|
68
|
+
var handleErrors = handleSubmit(function () { }, function (errors) {
|
|
69
|
+
console.error('Errors:', errors);
|
|
70
|
+
});
|
|
71
|
+
var submit = useCallback(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
72
|
+
var valid, values;
|
|
74
73
|
return __generator(this, function (_a) {
|
|
75
74
|
switch (_a.label) {
|
|
76
75
|
case 0:
|
|
77
76
|
setLoading(true);
|
|
78
|
-
return [4 /*yield*/,
|
|
77
|
+
return [4 /*yield*/, trigger(undefined, { shouldFocus: true })];
|
|
79
78
|
case 1:
|
|
80
|
-
_a.sent();
|
|
79
|
+
valid = _a.sent();
|
|
80
|
+
/** Imprimir errores si no es valido */
|
|
81
|
+
if (!valid) {
|
|
82
|
+
handleErrors();
|
|
83
|
+
return [2 /*return*/, setLoading(false)];
|
|
84
|
+
}
|
|
85
|
+
return [4 /*yield*/, onSubmit(getValues())];
|
|
86
|
+
case 2:
|
|
87
|
+
values = _a.sent();
|
|
81
88
|
setLoading(false);
|
|
82
|
-
return [2 /*return
|
|
89
|
+
return [2 /*return*/, values];
|
|
83
90
|
}
|
|
84
91
|
});
|
|
85
|
-
}); });
|
|
86
|
-
return (_jsxs("div", __assign({ className: styles.container, style: { color: formStyle.textColor } }, { children: [loading && _jsx("div", { className: styles.curtain }),
|
|
92
|
+
}); }, []);
|
|
93
|
+
return (_jsxs("div", __assign({ className: styles.container, style: { color: formStyle.textColor } }, { children: [loading && _jsx("div", { className: styles.curtain }), previous.map(function (idSection) { return (_jsx(Section, { idSection: idSection }, idSection)); }), next.map(function (idSection) { return (_jsx(Section, { idSection: idSection }, idSection)); }), _jsx(Terms, {}), !postview && editable && (_jsxs(React.Fragment, { children: [!customSubmitBtns && (_jsx("div", __assign({ className: styles.submitBtnContainer }, { children: _jsxs("button", __assign({ "data-testid": "form__submit", className: styles.submitBtn, onClick: submit, style: {
|
|
87
94
|
background: formStyle.primaryColor,
|
|
88
95
|
color: formStyle.primaryContrastColor,
|
|
89
96
|
}, disabled: loading }, { children: [_jsx("div", __assign({ style: {
|
|
90
97
|
visibility: loading
|
|
91
98
|
? 'hidden'
|
|
92
99
|
: 'visible',
|
|
93
|
-
} }, { children:
|
|
94
|
-
cloneElement(customSubmit, {
|
|
95
|
-
onSubmit: function () { return __awaiter(_this, void 0, void 0, function () {
|
|
96
|
-
var valid, values, response;
|
|
97
|
-
return __generator(this, function (_a) {
|
|
98
|
-
switch (_a.label) {
|
|
99
|
-
case 0:
|
|
100
|
-
setLoading(true);
|
|
101
|
-
return [4 /*yield*/, trigger()];
|
|
102
|
-
case 1:
|
|
103
|
-
valid = _a.sent();
|
|
104
|
-
if (!valid) return [3 /*break*/, 3];
|
|
105
|
-
values = getValues();
|
|
106
|
-
return [4 /*yield*/, onSubmit(values)];
|
|
107
|
-
case 2:
|
|
108
|
-
response = _a.sent();
|
|
109
|
-
setLoading(false);
|
|
110
|
-
return [2 /*return*/, response];
|
|
111
|
-
case 3:
|
|
112
|
-
setLoading(false);
|
|
113
|
-
return [2 /*return*/];
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
}); },
|
|
117
|
-
loading: loading,
|
|
118
|
-
})] }))] })));
|
|
100
|
+
} }, { children: sendLabel !== null && sendLabel !== void 0 ? sendLabel : 'Enviar' })), loading && (_jsx("div", __assign({ className: styles.loaderContainer }, { children: _jsx(Loader, { color: formStyle.primaryContrastColor, position: "unset" }) })))] })) }))), customSubmitBtns === null || customSubmitBtns === void 0 ? void 0 : customSubmitBtns(submit, loading)] }))] })));
|
|
119
101
|
}
|
|
120
102
|
export default ColumnForm;
|
|
121
|
-
function ColumnSection(props) {
|
|
122
|
-
var section = props.section;
|
|
123
|
-
if (!props.section)
|
|
124
|
-
return _jsx(_Fragment, {});
|
|
125
|
-
return (_jsxs(React.Fragment, { children: [_jsx(SectionComponent, __assign({}, props)), section.nextSection && (_jsx(ColumnSection, __assign({}, props, { section: props.form.sections[section.nextSection] })))] }));
|
|
126
|
-
}
|
|
@@ -1,6 +1,125 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
49
|
+
import { useCallback, useContext, useState } from 'react';
|
|
50
|
+
import styles from './StepperForm.module.css';
|
|
51
|
+
import Loader from '../../../Shared/Loader/Loader';
|
|
52
|
+
import Terms from '../../Terms/Terms';
|
|
53
|
+
import { useFormContext } from 'react-hook-form';
|
|
54
|
+
import { useAppDispatch, useAppSelector } from '../../../hooks';
|
|
55
|
+
import Section from '../../Section/Section';
|
|
56
|
+
import CustomContext from '../../../Contexts/CustomContext';
|
|
57
|
+
import * as SiteReducer from '../../../States/SiteStateReducer';
|
|
58
|
+
import { getAppState } from '../../../Utils/store';
|
|
3
59
|
function StepperForm(_a) {
|
|
4
|
-
|
|
60
|
+
var _this = this;
|
|
61
|
+
var onSubmit = _a.onSubmit;
|
|
62
|
+
var _b = useState(undefined), loading = _b[0], setLoading = _b[1];
|
|
63
|
+
var _c = useAppSelector(function (state) { return state.global; }), postview = _c.postview, editable = _c.editable, formStyle = _c.formStyle;
|
|
64
|
+
var _d = useFormContext(), trigger = _d.trigger, getValues = _d.getValues, handleSubmit = _d.handleSubmit;
|
|
65
|
+
var sendLabel = useContext(CustomContext).sendLabel;
|
|
66
|
+
var dispatch = useAppDispatch();
|
|
67
|
+
var previous = useAppSelector(function (state) { return state.site.previousSections; });
|
|
68
|
+
var idCurrent = useAppSelector(function (state) { return state.site.idCurrentSection; });
|
|
69
|
+
var next = useAppSelector(function (state) { return state.site.nextSections; });
|
|
70
|
+
/** Esto se usa para no tener que escuchar todo el tiempo los errores del formulario */
|
|
71
|
+
var handleErrors = handleSubmit(function () { }, function (errors) {
|
|
72
|
+
console.error('Errors:', errors);
|
|
73
|
+
});
|
|
74
|
+
var handlePrevious = useCallback(function () {
|
|
75
|
+
dispatch(SiteReducer.handlePrevious(getValues()));
|
|
76
|
+
}, []);
|
|
77
|
+
var handleNext = useCallback(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
78
|
+
var valid, state, values, response;
|
|
79
|
+
return __generator(this, function (_a) {
|
|
80
|
+
switch (_a.label) {
|
|
81
|
+
case 0:
|
|
82
|
+
setLoading('NEXT');
|
|
83
|
+
return [4 /*yield*/, trigger(undefined, { shouldFocus: true })];
|
|
84
|
+
case 1:
|
|
85
|
+
valid = _a.sent();
|
|
86
|
+
/** Imprimir errores si no es valido */
|
|
87
|
+
if (!valid) {
|
|
88
|
+
handleErrors();
|
|
89
|
+
return [2 /*return*/, setLoading(undefined)];
|
|
90
|
+
}
|
|
91
|
+
if (next.length > 0) {
|
|
92
|
+
dispatch(SiteReducer.handleNext(getValues()));
|
|
93
|
+
return [2 /*return*/, setLoading(undefined)];
|
|
94
|
+
}
|
|
95
|
+
return [4 /*yield*/, dispatch(getAppState()).unwrap()];
|
|
96
|
+
case 2:
|
|
97
|
+
state = _a.sent();
|
|
98
|
+
values = state.site.previousSections.reduce(function (v, idSection) { return (__assign(__assign({}, v), state.site.values.sections[idSection])); }, {});
|
|
99
|
+
/** Add the current section's values */
|
|
100
|
+
values = __assign(__assign({}, values), getValues());
|
|
101
|
+
return [4 /*yield*/, onSubmit(values)];
|
|
102
|
+
case 3:
|
|
103
|
+
response = _a.sent();
|
|
104
|
+
setLoading(undefined);
|
|
105
|
+
return [2 /*return*/, response];
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
}); }, [next]);
|
|
109
|
+
if (!idCurrent)
|
|
110
|
+
return _jsx(_Fragment, {});
|
|
111
|
+
return (_jsxs("div", __assign({ className: styles.container, style: { color: formStyle.textColor } }, { children: [loading && _jsx("div", { className: styles.curtain }), _jsx(Section, { idSection: idCurrent }, idCurrent), next.length === 0 && _jsx(Terms, {}), _jsxs("div", __assign({ className: styles.btnsContainer }, { children: [previous.length > 0 && (_jsxs("button", __assign({ "data-testid": "form__back", className: styles.formBtn, onClick: handlePrevious, style: {
|
|
112
|
+
background: formStyle.primaryColor,
|
|
113
|
+
color: formStyle.primaryContrastColor,
|
|
114
|
+
}, disabled: !!loading }, { children: [_jsx("div", __assign({ style: {
|
|
115
|
+
visibility: loading === 'BACK' ? 'hidden' : 'visible',
|
|
116
|
+
} }, { children: "Volver" })), loading === 'BACK' && (_jsx("div", __assign({ className: styles.loaderContainer }, { children: _jsx(Loader, { color: formStyle.primaryContrastColor, position: "unset" }) })))] }))), (next.length > 0 || (!postview && editable)) && (_jsxs("button", __assign({ "data-testid": "form__submit", className: styles.formBtn, onClick: handleNext, style: {
|
|
117
|
+
background: formStyle.primaryColor,
|
|
118
|
+
color: formStyle.primaryContrastColor,
|
|
119
|
+
}, disabled: !!loading }, { children: [_jsx("div", __assign({ style: {
|
|
120
|
+
visibility: loading === 'NEXT' ? 'hidden' : 'visible',
|
|
121
|
+
} }, { children: next.length > 0
|
|
122
|
+
? 'Siguiente'
|
|
123
|
+
: sendLabel !== null && sendLabel !== void 0 ? sendLabel : 'Enviar' })), loading === 'NEXT' && (_jsx("div", __assign({ className: styles.loaderContainer }, { children: _jsx(Loader, { color: formStyle.primaryContrastColor, position: "unset" }) })))] })))] }))] })));
|
|
5
124
|
}
|
|
6
125
|
export default StepperForm;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
.container {
|
|
2
|
+
width: fit-content;
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
align-items: center;
|
|
6
|
+
max-width: 100%;
|
|
7
|
+
position: relative;
|
|
8
|
+
}
|
|
9
|
+
.curtain {
|
|
10
|
+
position: absolute;
|
|
11
|
+
width: 100%;
|
|
12
|
+
height: 100%;
|
|
13
|
+
z-index: 2;
|
|
14
|
+
}
|
|
15
|
+
.btnsContainer {
|
|
16
|
+
margin-top: 10px;
|
|
17
|
+
max-width: calc(100% - 40px);
|
|
18
|
+
display: -webkit-box; /* OLD - iOS 6-, Safari 3.1-6 */
|
|
19
|
+
display: -moz-box; /* OLD - Firefox 19- (buggy but mostly works) */
|
|
20
|
+
display: -ms-flexbox; /* TWEENER - IE 10 */
|
|
21
|
+
display: -webkit-flex; /* NEW - Chrome */
|
|
22
|
+
display: flex;
|
|
23
|
+
flex-wrap: wrap;
|
|
24
|
+
justify-content: center;
|
|
25
|
+
gap: 10px 20px;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.formBtn {
|
|
29
|
+
max-width: 100%;
|
|
30
|
+
border-radius: 20px;
|
|
31
|
+
padding: 15px 20px;
|
|
32
|
+
font-size: 1.4rem;
|
|
33
|
+
cursor: pointer;
|
|
34
|
+
-moz-user-select: none;
|
|
35
|
+
-khtml-user-select: none;
|
|
36
|
+
-webkit-user-select: none;
|
|
37
|
+
-ms-user-select: none;
|
|
38
|
+
user-select: none;
|
|
39
|
+
border: none;
|
|
40
|
+
position: relative;
|
|
41
|
+
}
|
|
42
|
+
.formBtn[disabled] {
|
|
43
|
+
pointer-events: none;
|
|
44
|
+
opacity: 0.5;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.loaderContainer {
|
|
48
|
+
top: 0px;
|
|
49
|
+
bottom: 0px;
|
|
50
|
+
right: 0px;
|
|
51
|
+
left: 0px;
|
|
52
|
+
position: absolute;
|
|
53
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const selectCurrentValues: ((state: {
|
|
2
|
+
global: import("../States/GlobalStateReducer").GlobalState;
|
|
3
|
+
site: import("../States/SiteStateReducer").SiteState;
|
|
4
|
+
widthStats: import("./Form").WidthStats;
|
|
5
|
+
}) => Record<string, any>) & import("reselect").OutputSelectorFields<(args_0: string | null, args_1: Record<string, Record<string, any>>) => Record<string, any>, {
|
|
6
|
+
clearCache: () => void;
|
|
7
|
+
}> & {
|
|
8
|
+
clearCache: () => void;
|
|
9
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createSelector } from 'reselect';
|
|
2
|
+
export var selectCurrentValues = createSelector([
|
|
3
|
+
function (state) { return state.site.idCurrentSection; },
|
|
4
|
+
function (state) {
|
|
5
|
+
return state.site.values.sections;
|
|
6
|
+
},
|
|
7
|
+
], function (idCurrent, values) { var _a; return (_a = values[idCurrent !== null && idCurrent !== void 0 ? idCurrent : '']) !== null && _a !== void 0 ? _a : {}; });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { SectionComponentProps } from '../Section';
|
|
3
|
-
declare function MaterialSection({
|
|
3
|
+
declare function MaterialSection({ idSection }: SectionComponentProps): JSX.Element;
|
|
4
4
|
export default MaterialSection;
|
|
@@ -9,34 +9,33 @@ 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 { jsx as _jsx } from "react/jsx-runtime";
|
|
24
|
-
import { createElement as _createElement } from "react";
|
|
12
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
25
13
|
import StepComponent from '../../../FormSteps/Step';
|
|
26
14
|
import styles from './MaterialSection.module.css';
|
|
15
|
+
import { selectBreakPoint, useAppSelector } from '../../../hooks';
|
|
16
|
+
import { useContext } from 'react';
|
|
17
|
+
import CustomContext from '../../../Contexts/CustomContext';
|
|
18
|
+
import FormContext from '../../../Contexts/FormContext';
|
|
27
19
|
function MaterialSection(_a) {
|
|
28
20
|
var _b;
|
|
29
|
-
var
|
|
21
|
+
var idSection = _a.idSection;
|
|
22
|
+
var currentBreakPoint = useAppSelector(selectBreakPoint);
|
|
23
|
+
var editable = useAppSelector(function (state) { return state.global; }).editable;
|
|
24
|
+
var form = useContext(FormContext);
|
|
25
|
+
var sendLabel = useContext(CustomContext).sendLabel;
|
|
26
|
+
var section = form.sections[idSection];
|
|
27
|
+
if (!section)
|
|
28
|
+
return _jsx(_Fragment, {});
|
|
30
29
|
return (_jsx("div", __assign({ className: styles.container, style: {
|
|
31
30
|
width: (form.size.blockSize + form.size.spacingSize) *
|
|
32
31
|
form.size.blockNum,
|
|
33
32
|
justifyContent: sendLabel !== undefined &&
|
|
34
|
-
|
|
33
|
+
currentBreakPoint < form.size.blockNum
|
|
35
34
|
? 'center'
|
|
36
35
|
: 'normal',
|
|
37
36
|
} }, { children: (_b = section.steps) === null || _b === void 0 ? void 0 : _b.map(function (idStep) {
|
|
38
37
|
var step = form.steps[idStep];
|
|
39
|
-
return (
|
|
38
|
+
return (_jsx(StepComponent, { editable: editable, step: step, level: 0 }, idStep));
|
|
40
39
|
}) })));
|
|
41
40
|
}
|
|
42
41
|
export default MaterialSection;
|
|
@@ -1,38 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { Form, FormStyle, Section } from '../../@Types/Form';
|
|
5
|
-
import { CustomStep } from '../../App';
|
|
6
|
-
import { DependencyStore, WidthStats } from '../Form';
|
|
7
|
-
export interface RecursiveData {
|
|
8
|
-
form: Form;
|
|
9
|
-
organization: Organization;
|
|
10
|
-
control: Control<FieldValues, object>;
|
|
11
|
-
formStyle: FormStyle;
|
|
12
|
-
/** If the formsteps can be edited (For internal) */
|
|
13
|
-
editable: boolean;
|
|
14
|
-
preview: boolean;
|
|
15
|
-
postview: boolean;
|
|
16
|
-
partial: boolean;
|
|
17
|
-
domain?: string;
|
|
18
|
-
errors: Record<string, any>;
|
|
19
|
-
widthStats: WidthStats;
|
|
20
|
-
clearErrors: Function;
|
|
21
|
-
getValues: UseFormGetValues<FieldValues>;
|
|
22
|
-
originalValues: Record<string, any>;
|
|
23
|
-
customSteps: Record<string, CustomStep>;
|
|
24
|
-
customStepProps: Record<string, any>;
|
|
25
|
-
/** Function to call on postview to fetch the download url of a file */
|
|
26
|
-
fetchDownloadUrl?: (S3Key: string, fileName: string) => Promise<string>;
|
|
27
|
-
dependencyStore: DependencyStore;
|
|
28
|
-
setDependencyStore: React.Dispatch<React.SetStateAction<DependencyStore>>;
|
|
29
|
-
setFocus: (id: string) => void;
|
|
30
|
-
setValue: (id: string, value: any) => void;
|
|
31
|
-
}
|
|
32
|
-
export interface SectionComponentProps extends RecursiveData {
|
|
33
|
-
/** The custom send label to display */
|
|
34
|
-
sendLabel?: string;
|
|
35
|
-
section: Section;
|
|
2
|
+
export interface SectionComponentProps {
|
|
3
|
+
idSection: string;
|
|
36
4
|
}
|
|
37
5
|
declare function SectionComponent(props: SectionComponentProps): JSX.Element;
|
|
38
6
|
export default SectionComponent;
|
|
@@ -12,12 +12,18 @@ var __assign = (this && this.__assign) || function () {
|
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
import { FormStyleTypes } from '../../constants/FormStepTypes';
|
|
14
14
|
import MaterialSection from './MaterialSection/MaterialSection';
|
|
15
|
+
import SectionContext from '../../Contexts/SectionContext';
|
|
16
|
+
import { useAppSelector } from '../../hooks';
|
|
15
17
|
function SectionComponent(props) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
var formStyle = useAppSelector(function (state) { return state.global.formStyle; });
|
|
19
|
+
var renderSectionType = function () {
|
|
20
|
+
switch (formStyle.type) {
|
|
21
|
+
case FormStyleTypes.MATERIAL:
|
|
22
|
+
default: {
|
|
23
|
+
return _jsx(MaterialSection, __assign({}, props));
|
|
24
|
+
}
|
|
20
25
|
}
|
|
21
|
-
}
|
|
26
|
+
};
|
|
27
|
+
return (_jsx(SectionContext.Provider, __assign({ value: props.idSection }, { children: renderSectionType() })));
|
|
22
28
|
}
|
|
23
29
|
export default SectionComponent;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { TermComponentProps } from '../Term';
|
|
3
|
-
declare function TermComponent({ term,
|
|
3
|
+
declare function TermComponent({ term, tempError }: TermComponentProps): JSX.Element;
|
|
4
4
|
export default TermComponent;
|
|
@@ -24,15 +24,25 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
24
24
|
import { Dialog } from '@material-ui/core';
|
|
25
25
|
import React from 'react';
|
|
26
26
|
import { useState } from 'react';
|
|
27
|
-
import {
|
|
28
|
-
import RoundedButton from '../../../../
|
|
29
|
-
import RoundedCheckBox from '../../../../
|
|
27
|
+
import { useController } from 'react-hook-form';
|
|
28
|
+
import RoundedButton from '../../../../Shared/RoundedButton/RoundedButton';
|
|
29
|
+
import RoundedCheckBox from '../../../../Shared/RoundedCheckBox/RoundedCheckBox';
|
|
30
30
|
import CloseRoundedIcon from '@material-ui/icons/CloseRounded';
|
|
31
31
|
import styles from './MaterialTerm.module.css';
|
|
32
|
+
import { useAppSelector } from '../../../../hooks';
|
|
32
33
|
function TermComponent(_a) {
|
|
33
34
|
var _b;
|
|
34
|
-
var term = _a.term,
|
|
35
|
-
var _c =
|
|
35
|
+
var term = _a.term, tempError = _a.tempError;
|
|
36
|
+
var _c = useAppSelector(function (state) { return state.global; }), formStyle = _c.formStyle, postview = _c.postview;
|
|
37
|
+
var _d = useController({
|
|
38
|
+
name: term.id,
|
|
39
|
+
rules: {
|
|
40
|
+
required: true,
|
|
41
|
+
},
|
|
42
|
+
defaultValue: false,
|
|
43
|
+
shouldUnregister: true,
|
|
44
|
+
}), _e = _d.field, ref = _e.ref, field = __rest(_e, ["ref"]), error = _d.fieldState.error;
|
|
45
|
+
var _f = useState(false), showDialog = _f[0], setShowDialog = _f[1];
|
|
36
46
|
/**
|
|
37
47
|
* Function that renders the highlighted text
|
|
38
48
|
* @returns a string with span highlighted
|
|
@@ -42,7 +52,7 @@ function TermComponent(_a) {
|
|
|
42
52
|
var parts = text.split(/{{(.*?)}}/gi);
|
|
43
53
|
for (var i = 1; i < parts.length; i += 2) {
|
|
44
54
|
parts[i] = (_jsx("span", __assign({ className: styles.highlight, style: {
|
|
45
|
-
color: !!
|
|
55
|
+
color: !!error && tempError
|
|
46
56
|
? formStyle.errorColor
|
|
47
57
|
: formStyle.primaryColor,
|
|
48
58
|
}, onClick: function () {
|
|
@@ -72,15 +82,10 @@ function TermComponent(_a) {
|
|
|
72
82
|
} }, { children: term.clickEffect.title })), _jsx("div", __assign({ className: styles.dialogContentContainer }, { children: term.clickEffect.text })), _jsx(RoundedButton, { text: 'Aceptar', padding: "20px 15px", backgroundColor: formStyle.primaryColor, color: formStyle.primaryContrastColor, fontSize: 20, onClick: function () {
|
|
73
83
|
setShowDialog(false);
|
|
74
84
|
if (!postview) {
|
|
75
|
-
|
|
85
|
+
field.onChange(true);
|
|
76
86
|
}
|
|
77
|
-
} })] }))) })), _jsxs("div", __assign({ className: styles.container + ' noselect' }, { children: [_jsx("div", __assign({ className: styles.checkboxContainer }, { children: _jsx(
|
|
78
|
-
|
|
79
|
-
}, defaultValue: false, shouldUnregister: true, render: function (_a) {
|
|
80
|
-
var _b = _a.field, ref = _b.ref, field = __rest(_b, ["ref"]);
|
|
81
|
-
return (_jsx(RoundedCheckBox, __assign({ inputRef: ref }, field, { checked: field.value, cantEdit: postview, padding: "5px", checkedColor: formStyle.primaryColor, errorColor: formStyle.errorColor, size: "1.5rem", error: !!errors[term.id] })));
|
|
82
|
-
} }) })), _jsx("div", __assign({ className: styles.messageContainer, style: {
|
|
83
|
-
color: !!errors[term.id] && tempError
|
|
87
|
+
} })] }))) })), _jsxs("div", __assign({ className: styles.container + ' noselect' }, { children: [_jsx("div", __assign({ className: styles.checkboxContainer }, { children: _jsx(RoundedCheckBox, __assign({ inputRef: ref }, field, { checked: field.value, cantEdit: postview, padding: "5px", checkedColor: formStyle.primaryColor, errorColor: formStyle.errorColor, size: "1.5rem", error: !!error })) })), _jsx("div", __assign({ className: styles.messageContainer, style: {
|
|
88
|
+
color: !!error && tempError
|
|
84
89
|
? formStyle.errorColor
|
|
85
90
|
: 'inherit',
|
|
86
91
|
} }, { children: renderText(term.message) }))] }))] }));
|
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
3
|
-
import { Form, FormStyle, Term } from '../../../@Types/Form';
|
|
2
|
+
import { Term } from '../../../@Types/Form';
|
|
4
3
|
export interface TermComponentProps {
|
|
5
4
|
term: Term;
|
|
6
|
-
form: Form;
|
|
7
|
-
control: Control<FieldValues, object>;
|
|
8
|
-
errors: Record<string, any>;
|
|
9
|
-
formStyle: FormStyle;
|
|
10
|
-
postview: boolean;
|
|
11
5
|
tempError: boolean;
|
|
12
|
-
setValue: Function;
|
|
13
6
|
}
|
|
14
7
|
declare function TermComponent(props: TermComponentProps): JSX.Element;
|
|
15
8
|
export default TermComponent;
|
|
@@ -11,9 +11,11 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
import { FormStyleTypes } from '../../../constants/FormStepTypes';
|
|
14
|
+
import { useAppSelector } from '../../../hooks';
|
|
14
15
|
import MaterialTerm from './MaterialTerm/MaterialTerm';
|
|
15
16
|
function TermComponent(props) {
|
|
16
|
-
|
|
17
|
+
var formStyle = useAppSelector(function (state) { return state.global; }).formStyle;
|
|
18
|
+
switch (formStyle.type) {
|
|
17
19
|
case FormStyleTypes.MATERIAL:
|
|
18
20
|
default: {
|
|
19
21
|
return _jsx(MaterialTerm, __assign({}, props));
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
|
|
3
|
-
declare function Terms({ form, internal, postview, formStyle, originalValues, formController, }: FormComponentProps): JSX.Element;
|
|
2
|
+
declare function Terms(): JSX.Element;
|
|
4
3
|
export default Terms;
|
package/dist/Form/Terms/Terms.js
CHANGED
|
@@ -10,26 +10,35 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
|
-
import { useEffect, useState } from 'react';
|
|
14
|
-
import styles from '
|
|
13
|
+
import { useContext, useEffect, useState } from 'react';
|
|
14
|
+
import styles from './Terms.module.css';
|
|
15
15
|
import TermComponent from './Term/Term';
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
import { useFormContext } from 'react-hook-form';
|
|
17
|
+
import FormContext from '../../Contexts/FormContext';
|
|
18
|
+
import { useAppSelector } from '../../hooks';
|
|
19
|
+
function Terms() {
|
|
20
|
+
var _a = useAppSelector(function (state) { return state.global; }), postview = _a.postview, internal = _a.internal;
|
|
21
|
+
var isInteralAgent = useAppSelector(function (state) {
|
|
22
|
+
return state.site.values.global['INTERNAL_CREATING_AGENT'] !== undefined;
|
|
23
|
+
});
|
|
24
|
+
var form = useContext(FormContext);
|
|
25
|
+
var isSubmitting = useFormContext().formState.isSubmitting;
|
|
19
26
|
var _b = useState(false), tempError = _b[0], setTempError = _b[1];
|
|
20
27
|
useEffect(function () {
|
|
28
|
+
if (!isSubmitting)
|
|
29
|
+
return;
|
|
21
30
|
setTempError(true);
|
|
22
31
|
setTimeout(function () {
|
|
23
32
|
setTempError(false);
|
|
24
33
|
}, 500);
|
|
25
|
-
}, [
|
|
34
|
+
}, [isSubmitting]);
|
|
26
35
|
if (form.terms &&
|
|
27
36
|
(!internal || (internal && postview)) &&
|
|
28
|
-
|
|
37
|
+
!isInteralAgent) {
|
|
29
38
|
return (_jsx("div", __assign({ className: styles.termsContainer, style: {
|
|
30
39
|
width: (form.size.blockSize + form.size.spacingSize) *
|
|
31
40
|
form.size.blockNum,
|
|
32
|
-
} }, { children: form.terms.map(function (term) { return (_jsx(TermComponent, {
|
|
41
|
+
} }, { children: form.terms.map(function (term) { return (_jsx(TermComponent, { term: term, tempError: tempError }, term.id)); }) })));
|
|
33
42
|
}
|
|
34
43
|
return _jsx(_Fragment, {});
|
|
35
44
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { StepProps } from '../../Step';
|
|
3
3
|
import { CBRElementStep } from '../../../@Types/CBRFormStep';
|
|
4
|
-
|
|
5
|
-
export default CBRElementStepComponent;
|
|
6
|
-
export interface ElementSubStepRendererProps extends Omit<StepProps, 'step'> {
|
|
4
|
+
export interface ElementStepProps extends Omit<StepProps, 'step'> {
|
|
7
5
|
step: CBRElementStep;
|
|
8
6
|
}
|
|
7
|
+
declare function CBRElementStepComponent(props: ElementStepProps): JSX.Element;
|
|
8
|
+
export default CBRElementStepComponent;
|