@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
|
@@ -56,89 +56,27 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
56
56
|
}
|
|
57
57
|
return t;
|
|
58
58
|
};
|
|
59
|
-
import { createElement as _createElement } from "react";
|
|
60
59
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
61
|
-
import React, {
|
|
60
|
+
import React, { useCallback, useContext, useState } from 'react';
|
|
62
61
|
import FormStepTypes, { EntityValueDataTypes, EntityValueOptionTypes, } from '../../../constants/FormStepTypes';
|
|
63
62
|
import styles from './MaterialEntityValuePickerStep.module.css';
|
|
64
63
|
import StepComponent from '../../Step';
|
|
65
|
-
import {
|
|
64
|
+
import { useController, useFormContext } from 'react-hook-form';
|
|
66
65
|
import { calcFillerSize } from '../../StepFunctions';
|
|
67
66
|
import { SmartSelect } from '../../SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep';
|
|
68
|
-
import widgetInstance from '../../../AxiosWidget';
|
|
69
|
-
import
|
|
70
|
-
import
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
67
|
+
import widgetInstance from '../../../Utils/AxiosWidget';
|
|
68
|
+
import InputIcon from '../../../Shared/InputIcon/InputIcon';
|
|
69
|
+
import FormContext from '../../../Contexts/FormContext';
|
|
70
|
+
import { selectBreakPoint, useAppSelector } from '../../../hooks';
|
|
71
|
+
import { useStepDependency } from '../../StepHooks';
|
|
72
|
+
function EntityValuePickerComponent(_a) {
|
|
73
|
+
var step = _a.step, error = _a.error, level = _a.level, value = _a.value, editable = _a.editable, inputRef = _a.inputRef, onBlur = _a.onBlur, onChange = _a.onChange, handleSizeChange = _a.handleSizeChange;
|
|
74
|
+
var form = useContext(FormContext);
|
|
75
|
+
var getValues = useFormContext().getValues;
|
|
76
|
+
var currentBreakPoint = useAppSelector(selectBreakPoint);
|
|
74
77
|
var _b = useState(level === 0
|
|
75
78
|
? calcFillerSize(step, form.steps, getValues(), form.size)
|
|
76
79
|
: 0), fillerSize = _b[0], setFillerSize = _b[1];
|
|
77
|
-
var getEntityValueOptions = function (_a, _step, dependencyStore, domain) {
|
|
78
|
-
var idOrganization = _a.idOrganization;
|
|
79
|
-
return __awaiter(_this, void 0, void 0, function () {
|
|
80
|
-
var urlPath, _i, _b, path, idEntityValue, currentValue, params, _c, _d, filter, currentValue, url, response;
|
|
81
|
-
var _e, _f, _g, _h, _j;
|
|
82
|
-
return __generator(this, function (_k) {
|
|
83
|
-
switch (_k.label) {
|
|
84
|
-
case 0:
|
|
85
|
-
urlPath = '';
|
|
86
|
-
for (_i = 0, _b = step.path; _i < _b.length; _i++) {
|
|
87
|
-
path = _b[_i];
|
|
88
|
-
idEntityValue = 'null';
|
|
89
|
-
switch (path.type) {
|
|
90
|
-
case EntityValueDataTypes.STEP:
|
|
91
|
-
currentValue = (_e = dependencyStore[path.idStep]) === null || _e === void 0 ? void 0 : _e.value;
|
|
92
|
-
if (!currentValue)
|
|
93
|
-
return [2 /*return*/, null];
|
|
94
|
-
if (typeof currentValue === 'string')
|
|
95
|
-
idEntityValue = currentValue;
|
|
96
|
-
else
|
|
97
|
-
idEntityValue = (_f = currentValue._id) !== null && _f !== void 0 ? _f : currentValue.id;
|
|
98
|
-
break;
|
|
99
|
-
case EntityValueDataTypes.VALUE:
|
|
100
|
-
default:
|
|
101
|
-
idEntityValue = (_g = path.idEntityValue) !== null && _g !== void 0 ? _g : 'null';
|
|
102
|
-
break;
|
|
103
|
-
}
|
|
104
|
-
urlPath +=
|
|
105
|
-
'/' +
|
|
106
|
-
path.idEntity +
|
|
107
|
-
(idEntityValue ? '/' + idEntityValue : '');
|
|
108
|
-
}
|
|
109
|
-
params = new URLSearchParams({});
|
|
110
|
-
for (_c = 0, _d = step.filters; _c < _d.length; _c++) {
|
|
111
|
-
filter = _d[_c];
|
|
112
|
-
switch (filter.type) {
|
|
113
|
-
case EntityValueDataTypes.STEP:
|
|
114
|
-
currentValue = (_h = dependencyStore[filter.idStep]) === null || _h === void 0 ? void 0 : _h.value;
|
|
115
|
-
if (currentValue) {
|
|
116
|
-
if (typeof currentValue === 'string')
|
|
117
|
-
params.set(filter.idProperty, currentValue);
|
|
118
|
-
else
|
|
119
|
-
params.set(filter.idProperty, (_j = currentValue._id) !== null && _j !== void 0 ? _j : currentValue.id);
|
|
120
|
-
}
|
|
121
|
-
else if (filter.required) {
|
|
122
|
-
return [2 /*return*/, null];
|
|
123
|
-
}
|
|
124
|
-
break;
|
|
125
|
-
case EntityValueDataTypes.VALUE:
|
|
126
|
-
default:
|
|
127
|
-
params.set(filter.idProperty, filter.value);
|
|
128
|
-
break;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
url = "".concat(domain !== null && domain !== void 0 ? domain : idOrganization, "/entities/").concat(step.idEntity).concat(urlPath, "?").concat(params.toString());
|
|
132
|
-
return [4 /*yield*/, (domain
|
|
133
|
-
? widgetInstance.get(url)
|
|
134
|
-
: axiosInstance.get(url))];
|
|
135
|
-
case 1:
|
|
136
|
-
response = _k.sent();
|
|
137
|
-
return [2 /*return*/, response.data.filter(function (option) { var _a; return ((_a = step.options[option._id]) === null || _a === void 0 ? void 0 : _a.type) !== EntityValueOptionTypes.HIDE; })];
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
};
|
|
142
80
|
var sizeChange = function () {
|
|
143
81
|
handleSizeChange === null || handleSizeChange === void 0 ? void 0 : handleSizeChange();
|
|
144
82
|
if (level === 0) {
|
|
@@ -146,7 +84,7 @@ function EntityValuePicker(_a) {
|
|
|
146
84
|
}
|
|
147
85
|
};
|
|
148
86
|
var renderSelect = function () {
|
|
149
|
-
return (_jsx(SmartSelect,
|
|
87
|
+
return (_jsx(SmartSelect, { onBlur: onBlur, error: error, onChange: onChange, level: level, value: value, inputRef: inputRef, editable: editable, step: step, icon: step.icon ? _jsx(InputIcon, { icon: step.icon }) : undefined, getOptions: getEntityValueOptions, getOptionSelected: function (option, value) {
|
|
150
88
|
return option._id === value._id;
|
|
151
89
|
}, calcDepError: function (steps) {
|
|
152
90
|
for (var _i = 0, steps_1 = steps; _i < steps_1.length; _i++) {
|
|
@@ -156,7 +94,7 @@ function EntityValuePicker(_a) {
|
|
|
156
94
|
}
|
|
157
95
|
}
|
|
158
96
|
return undefined;
|
|
159
|
-
}, getValueString: function (value) { return value === null || value === void 0 ? void 0 : value._id; } }))
|
|
97
|
+
}, getValueString: function (value) { return value === null || value === void 0 ? void 0 : value._id; } }));
|
|
160
98
|
};
|
|
161
99
|
var mapNestedOption = function () {
|
|
162
100
|
if (value) {
|
|
@@ -164,18 +102,14 @@ function EntityValuePicker(_a) {
|
|
|
164
102
|
if ((currentOption === null || currentOption === void 0 ? void 0 : currentOption.type) === EntityValueOptionTypes.NESTED) {
|
|
165
103
|
return (_jsx(React.Fragment, { children: currentOption.steps.map(function (idStep) {
|
|
166
104
|
var subStep = form.steps[idStep];
|
|
167
|
-
return (
|
|
168
|
-
sizeChange();
|
|
169
|
-
} })));
|
|
105
|
+
return (_jsx(StepComponent, { editable: editable, step: subStep, level: level + 1, handleSizeChange: sizeChange }, idStep));
|
|
170
106
|
}) }));
|
|
171
107
|
}
|
|
172
108
|
}
|
|
173
109
|
};
|
|
174
110
|
if (level === 0 && step.maxSize && step.maxSize < form.size.blockNum) {
|
|
175
111
|
return (_jsxs("div", __assign({ className: styles.firstLvlContainer, style: {
|
|
176
|
-
width:
|
|
177
|
-
? '100%'
|
|
178
|
-
: 'fit-content',
|
|
112
|
+
width: currentBreakPoint <= step.size ? '100%' : 'fit-content',
|
|
179
113
|
} }, { children: [renderSelect(), mapNestedOption(), level === 0 && step.maxSize < form.size.blockNum && (_jsx("div", { className: styles.smallSeparator, style: {
|
|
180
114
|
width: fillerSize,
|
|
181
115
|
} }, "SEPARATOR"))] })));
|
|
@@ -186,34 +120,81 @@ function EntityValuePicker(_a) {
|
|
|
186
120
|
}
|
|
187
121
|
export default EntityValuePickerStep;
|
|
188
122
|
function EntityValuePickerStep(props) {
|
|
189
|
-
var
|
|
190
|
-
var
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
}, shouldUnregister: true, render: function (_a) {
|
|
205
|
-
var _b = _a.field, ref = _b.ref, field = __rest(_b, ["ref"]);
|
|
206
|
-
return (_jsx(EntityValuePicker, __assign({}, props, field, { inputRef: ref, onChange: function (value) {
|
|
207
|
-
if (dependencyStore[step.id] !== undefined) {
|
|
208
|
-
props.setDependencyStore(function (dependencies) {
|
|
209
|
-
var _a;
|
|
210
|
-
return (__assign(__assign({}, dependencies), (_a = {}, _a[step.id] = {
|
|
211
|
-
type: step.type,
|
|
212
|
-
value: value !== null && value !== void 0 ? value : null,
|
|
213
|
-
}, _a)));
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
field.onChange(value);
|
|
217
|
-
} })));
|
|
218
|
-
} }));
|
|
123
|
+
var step = props.step, defaultValue = props.defaultValue;
|
|
124
|
+
var _a = useStepDependency(step, defaultValue), handleStepDep = _a.handleStepDep, originalValue = _a.originalValue;
|
|
125
|
+
var _b = useController({
|
|
126
|
+
name: step.id,
|
|
127
|
+
rules: {
|
|
128
|
+
required: step.required ? 'Este campo es obligatorio' : undefined,
|
|
129
|
+
},
|
|
130
|
+
shouldUnregister: true,
|
|
131
|
+
defaultValue: originalValue,
|
|
132
|
+
}), _c = _b.field, ref = _c.ref, field = __rest(_c, ["ref"]), error = _b.fieldState.error;
|
|
133
|
+
var onChange = useCallback(function (value) {
|
|
134
|
+
handleStepDep(value);
|
|
135
|
+
field.onChange(value);
|
|
136
|
+
}, [handleStepDep, field]);
|
|
137
|
+
return (_jsx(EntityValuePickerComponent, __assign({}, props, field, { error: error, inputRef: ref, onChange: onChange })));
|
|
219
138
|
}
|
|
139
|
+
var getEntityValueOptions = function (idOrganization, step, dependencyStore) { return __awaiter(void 0, void 0, void 0, function () {
|
|
140
|
+
var urlPath, _i, _a, path, idEntityValue, currentValue, params, _b, _c, filter, currentValue, url, response;
|
|
141
|
+
var _d, _e, _f, _g, _h;
|
|
142
|
+
return __generator(this, function (_j) {
|
|
143
|
+
switch (_j.label) {
|
|
144
|
+
case 0:
|
|
145
|
+
if (!idOrganization)
|
|
146
|
+
return [2 /*return*/, null];
|
|
147
|
+
urlPath = '';
|
|
148
|
+
for (_i = 0, _a = step.path; _i < _a.length; _i++) {
|
|
149
|
+
path = _a[_i];
|
|
150
|
+
idEntityValue = 'null';
|
|
151
|
+
switch (path.type) {
|
|
152
|
+
case EntityValueDataTypes.STEP: {
|
|
153
|
+
currentValue = (_d = dependencyStore[path.idStep]) === null || _d === void 0 ? void 0 : _d.value;
|
|
154
|
+
if (!currentValue)
|
|
155
|
+
return [2 /*return*/, null];
|
|
156
|
+
if (typeof currentValue === 'string')
|
|
157
|
+
idEntityValue = currentValue;
|
|
158
|
+
else
|
|
159
|
+
idEntityValue = (_e = currentValue._id) !== null && _e !== void 0 ? _e : currentValue.id;
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
case EntityValueDataTypes.VALUE:
|
|
163
|
+
default:
|
|
164
|
+
idEntityValue = (_f = path.idEntityValue) !== null && _f !== void 0 ? _f : 'null';
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
urlPath +=
|
|
168
|
+
'/' + path.idEntity + (idEntityValue ? '/' + idEntityValue : '');
|
|
169
|
+
}
|
|
170
|
+
params = new URLSearchParams({});
|
|
171
|
+
for (_b = 0, _c = step.filters; _b < _c.length; _b++) {
|
|
172
|
+
filter = _c[_b];
|
|
173
|
+
switch (filter.type) {
|
|
174
|
+
case EntityValueDataTypes.STEP: {
|
|
175
|
+
currentValue = (_g = dependencyStore[filter.idStep]) === null || _g === void 0 ? void 0 : _g.value;
|
|
176
|
+
if (currentValue) {
|
|
177
|
+
if (typeof currentValue === 'string')
|
|
178
|
+
params.set(filter.idProperty, currentValue);
|
|
179
|
+
else
|
|
180
|
+
params.set(filter.idProperty, (_h = currentValue._id) !== null && _h !== void 0 ? _h : currentValue.id);
|
|
181
|
+
}
|
|
182
|
+
else if (filter.required) {
|
|
183
|
+
return [2 /*return*/, null];
|
|
184
|
+
}
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
case EntityValueDataTypes.VALUE:
|
|
188
|
+
default:
|
|
189
|
+
params.set(filter.idProperty, filter.value);
|
|
190
|
+
break;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
url = "".concat(idOrganization, "/entities/").concat(step.idEntity).concat(urlPath, "?").concat(params.toString());
|
|
194
|
+
return [4 /*yield*/, widgetInstance.get(url)];
|
|
195
|
+
case 1:
|
|
196
|
+
response = _j.sent();
|
|
197
|
+
return [2 /*return*/, response.data.filter(function (option) { var _a; return ((_a = step.options[option._id]) === null || _a === void 0 ? void 0 : _a.type) !== EntityValueOptionTypes.HIDE; })];
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
}); };
|
|
@@ -10,10 +10,12 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { useAppSelector } from '../../hooks';
|
|
13
14
|
import { FormStyleTypes } from '../../constants/FormStepTypes';
|
|
14
15
|
import MaterialFileUploadStep from './MaterialFileUploadStep/MaterialFileUploadStep';
|
|
15
16
|
function FileUploadStep(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(MaterialFileUploadStep, __assign({}, props));
|
package/dist/FormSteps/FileUploadStep/MaterialFileUploadStep/FileComponent/FileComponent.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ interface FileComponentProps {
|
|
|
5
5
|
file: FileObject | UploadedFileObject;
|
|
6
6
|
formStyle: FormStyle;
|
|
7
7
|
error: boolean;
|
|
8
|
-
handleRemove:
|
|
8
|
+
handleRemove: () => void;
|
|
9
9
|
/** Function to call on postview to fetch the download url of a file */
|
|
10
10
|
fetchDownloadUrl?: (S3Key: string, fileName: string) => Promise<string>;
|
|
11
11
|
}
|
|
@@ -51,7 +51,7 @@ import styles from './FileComponent.module.css';
|
|
|
51
51
|
import ClearRoundedIcon from '@material-ui/icons/ClearRounded';
|
|
52
52
|
import DescriptionRoundedIcon from '@material-ui/icons/DescriptionRounded';
|
|
53
53
|
import ErrorRoundedIcon from '@material-ui/icons/ErrorRounded';
|
|
54
|
-
import Loader from '../../../../
|
|
54
|
+
import Loader from '../../../../Shared/Loader/Loader';
|
|
55
55
|
import { useState } from 'react';
|
|
56
56
|
function FileUploadComponent(_a) {
|
|
57
57
|
var _this = this;
|
|
@@ -67,20 +67,26 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
67
67
|
};
|
|
68
68
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
69
69
|
import styles from './MaterialFileUploadStep.module.css';
|
|
70
|
-
import {
|
|
71
|
-
import RoundedButton from '../../../
|
|
72
|
-
import { useEffect, useRef, useState } from 'react';
|
|
70
|
+
import { useController, useFormContext } from 'react-hook-form';
|
|
71
|
+
import RoundedButton from '../../../Shared/RoundedButton/RoundedButton';
|
|
72
|
+
import { useCallback, useContext, useEffect, useRef, useState } from 'react';
|
|
73
73
|
import { getAcceptedExtensions } from '../../../constants/Files/FileExtensions';
|
|
74
|
-
import { getUploadUrls, postFile } from '../../../
|
|
74
|
+
import { getUploadUrls, postFile } from '../../../Services/FileService';
|
|
75
75
|
import FileComponent from './FileComponent/FileComponent';
|
|
76
76
|
import maxSize from '../../../constants/Files/FileMaxSize';
|
|
77
|
+
import { useAppSelector } from '../../../hooks';
|
|
78
|
+
import CustomContext from '../../../Contexts/CustomContext';
|
|
79
|
+
import { useStepDependency } from '../../StepHooks';
|
|
77
80
|
export function isUploadedFileObject(file) {
|
|
78
81
|
return file.state === undefined && file.S3Key !== undefined;
|
|
79
82
|
}
|
|
80
83
|
function FileUploadStep(_a) {
|
|
81
|
-
var step = _a.step,
|
|
82
|
-
var
|
|
83
|
-
var
|
|
84
|
+
var step = _a.step, value = _a.value, btnRef = _a.btnRef, onChange = _a.onChange, editable = _a.editable, fieldError = _a.fieldError;
|
|
85
|
+
var fetchDownloadUrl = useContext(CustomContext).fetchDownloadUrl;
|
|
86
|
+
var _b = useAppSelector(function (state) { return state.global; }), formStyle = _b.formStyle, idOrganization = _b.idOrganization, postview = _b.postview;
|
|
87
|
+
var clearErrors = useFormContext().clearErrors;
|
|
88
|
+
var _c = useState(undefined), error = _c[0], setError = _c[1];
|
|
89
|
+
var _d = useState([]), fileChange = _d[0], setFileChange = _d[1];
|
|
84
90
|
var inputRef = useRef();
|
|
85
91
|
useEffect(function () {
|
|
86
92
|
var filesToFetchLink = [];
|
|
@@ -133,7 +139,7 @@ function FileUploadStep(_a) {
|
|
|
133
139
|
switch (_a.label) {
|
|
134
140
|
case 0:
|
|
135
141
|
_a.trys.push([0, 2, , 3]);
|
|
136
|
-
return [4 /*yield*/, getUploadUrls(pFiles.map(function (file) { return file.file; }),
|
|
142
|
+
return [4 /*yield*/, getUploadUrls(pFiles.map(function (file) { return file.file; }), idOrganization)];
|
|
137
143
|
case 1:
|
|
138
144
|
fileLinks_1 = _a.sent();
|
|
139
145
|
errorsExt_1 = [];
|
|
@@ -190,7 +196,7 @@ function FileUploadStep(_a) {
|
|
|
190
196
|
});
|
|
191
197
|
}
|
|
192
198
|
var calcErrorMsg = function () {
|
|
193
|
-
if (
|
|
199
|
+
if (fieldError) {
|
|
194
200
|
var errNum = value.filter(function (val) { return val.state === 'ERROR'; }).length;
|
|
195
201
|
if (errNum === 1) {
|
|
196
202
|
return 'Este archivo no es válido';
|
|
@@ -204,8 +210,7 @@ function FileUploadStep(_a) {
|
|
|
204
210
|
}
|
|
205
211
|
return '';
|
|
206
212
|
};
|
|
207
|
-
return (_jsxs("div", __assign({ className: styles.container +
|
|
208
|
-
(error || !!errors[step.id] ? ' EF-error' : ''), style: editable == false || postview
|
|
213
|
+
return (_jsxs("div", __assign({ className: styles.container + (error || !!fieldError ? ' EF-error' : ''), style: editable == false || postview
|
|
209
214
|
? {}
|
|
210
215
|
: {
|
|
211
216
|
minHeight: '100px',
|
|
@@ -235,7 +240,7 @@ function FileUploadStep(_a) {
|
|
|
235
240
|
}
|
|
236
241
|
inputRef.current.value = '';
|
|
237
242
|
}
|
|
238
|
-
}, multiple: true, accept: getAcceptedExtensions() }), _jsxs("div", __assign({ className: styles.btnContainer }, { children: [_jsx("input", { ref: btnRef, className:
|
|
243
|
+
}, multiple: true, accept: getAcceptedExtensions() }), _jsxs("div", __assign({ className: styles.btnContainer }, { children: [_jsx("input", { ref: btnRef, className: 'hidden-input' }), _jsx(RoundedButton, { disabled: !editable || postview, text: 'Examinar' + (step.required ? ' *' : ''), color: formStyle.primaryContrastColor, backgroundColor: formStyle.primaryColor, fontSize: '1rem', padding: '5px 15px 5px 15px', onClick: function () {
|
|
239
244
|
if (editable && !postview) {
|
|
240
245
|
var input = inputRef.current;
|
|
241
246
|
if (input !== null) {
|
|
@@ -244,7 +249,7 @@ function FileUploadStep(_a) {
|
|
|
244
249
|
input.click();
|
|
245
250
|
}
|
|
246
251
|
}
|
|
247
|
-
} })] })), _jsx("div", __assign({ className: styles.filesContainer }, { children: value.map(function (file, index) { return (_jsx(FileComponent, { formStyle: formStyle, file: file, error: (!!
|
|
252
|
+
} })] })), _jsx("div", __assign({ className: styles.filesContainer }, { children: value.map(function (file, index) { return (_jsx(FileComponent, { formStyle: formStyle, file: file, error: (!!fieldError &&
|
|
248
253
|
file.state !== 'DONE') ||
|
|
249
254
|
file.state === 'ERROR', handleRemove: function () {
|
|
250
255
|
if (value.filter(function (val) {
|
|
@@ -261,15 +266,24 @@ function FileUploadStep(_a) {
|
|
|
261
266
|
}, fetchDownloadUrl: fetchDownloadUrl }, index)); }) })), _jsx("div", __assign({ className: styles.errorMsg, style: { color: formStyle.errorColor } }, { children: error !== null && error !== void 0 ? error : calcErrorMsg() }))] })));
|
|
262
267
|
}
|
|
263
268
|
function UploadStepComponent(props) {
|
|
264
|
-
|
|
269
|
+
var step = props.step;
|
|
270
|
+
var _a = useStepDependency(step), handleStepDep = _a.handleStepDep, originalValue = _a.originalValue;
|
|
271
|
+
var _b = useController({
|
|
272
|
+
name: step.id,
|
|
273
|
+
rules: {
|
|
265
274
|
validate: function (array) {
|
|
266
275
|
return ((props.step.required && array.length > 0) ||
|
|
267
276
|
!props.step.required) &&
|
|
268
277
|
array.find(function (file) { return !file.S3Key; }) === undefined;
|
|
269
278
|
},
|
|
270
|
-
},
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
279
|
+
},
|
|
280
|
+
shouldUnregister: true,
|
|
281
|
+
defaultValue: originalValue,
|
|
282
|
+
}), _c = _b.field, ref = _c.ref, field = __rest(_c, ["ref"]), error = _b.fieldState.error;
|
|
283
|
+
var onChange = useCallback(function (value) {
|
|
284
|
+
handleStepDep(value);
|
|
285
|
+
field.onChange(value);
|
|
286
|
+
}, [handleStepDep, field]);
|
|
287
|
+
return (_jsx(FileUploadStep, __assign({}, props, field, { btnRef: ref, fieldError: error, onChange: onChange })));
|
|
274
288
|
}
|
|
275
289
|
export default UploadStepComponent;
|
|
@@ -8,10 +8,10 @@ interface CustomMapperElementModifiers<Type> {
|
|
|
8
8
|
export interface MapperStepProps<Type> extends StepProps {
|
|
9
9
|
/** The MapperStep to display */
|
|
10
10
|
step: Mapper;
|
|
11
|
-
customAdd?: JSX.Element;
|
|
11
|
+
customAdd?: (ref: React.RefObject<HTMLDivElement>, disabled: boolean, handleAddElement: (value?: any) => void) => JSX.Element;
|
|
12
12
|
customElementRender?: (element: MapperElement<Type>, index: number, renderElement: (renderElementButtons?: (element: MapperElement<any>) => JSX.Element) => JSX.Element) => JSX.Element;
|
|
13
13
|
customElementModifiers?: CustomMapperElementModifiers<Type>;
|
|
14
14
|
calcCustomStepProps?: (element: MapperElement<Type>, customStepProps: Record<string, any>) => Record<string, any>;
|
|
15
15
|
}
|
|
16
|
-
declare function MapperStep<Type>(
|
|
16
|
+
declare function MapperStep<Type>(props: MapperStepProps<Type>): JSX.Element;
|
|
17
17
|
export default MapperStep;
|
|
@@ -9,26 +9,16 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
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
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
13
|
import { FormStyleTypes } from '../../constants/FormStepTypes';
|
|
25
14
|
import MaterialMapperStep from './MaterialMapperStep/MaterialMapperStep';
|
|
26
|
-
|
|
27
|
-
|
|
15
|
+
import { useAppSelector } from '../../hooks';
|
|
16
|
+
function MapperStep(props) {
|
|
17
|
+
var formStyle = useAppSelector(function (state) { return state.global; }).formStyle;
|
|
28
18
|
switch (formStyle.type) {
|
|
29
19
|
case FormStyleTypes.MATERIAL:
|
|
30
20
|
default: {
|
|
31
|
-
return
|
|
21
|
+
return _jsx(MaterialMapperStep, __assign({}, props));
|
|
32
22
|
}
|
|
33
23
|
}
|
|
34
24
|
}
|
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { MapperStepProps } from '../../../MapperStep';
|
|
3
3
|
import { MapperElementComponentProps } from '../MapperElement';
|
|
4
|
-
declare function ListMapperElement<Type = any>({ step,
|
|
5
|
-
num: number;
|
|
6
|
-
formStyle: {
|
|
7
|
-
textColor: string;
|
|
8
|
-
};
|
|
9
|
-
handleDelete?: Function;
|
|
10
|
-
/** children to render */
|
|
11
|
-
children?: any;
|
|
12
|
-
}): JSX.Element;
|
|
4
|
+
declare function ListMapperElement<Type = any>({ step, num, loading, element, children, editable, handleDelete, customElementModifiers, }: MapperStepProps<Type> & MapperElementComponentProps<Type>): JSX.Element;
|
|
13
5
|
export default ListMapperElement;
|
package/dist/FormSteps/MapperStep/MaterialMapperStep/Element/ListMapperElement/ListMapperElement.js
CHANGED
|
@@ -10,12 +10,17 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { useContext } from 'react';
|
|
13
14
|
import styles from './ListMapperElement.module.css';
|
|
14
15
|
import DeleteRoundedIcon from '@material-ui/icons/DeleteRounded';
|
|
16
|
+
import FormContext from '../../../../../Contexts/FormContext';
|
|
17
|
+
import { useAppSelector } from '../../../../../hooks';
|
|
15
18
|
function ListMapperElement(_a) {
|
|
16
19
|
var _b, _c;
|
|
17
|
-
var step = _a.step,
|
|
18
|
-
var size =
|
|
20
|
+
var step = _a.step, num = _a.num, loading = _a.loading, element = _a.element, children = _a.children, editable = _a.editable, handleDelete = _a.handleDelete, customElementModifiers = _a.customElementModifiers;
|
|
21
|
+
var size = useContext(FormContext).size;
|
|
22
|
+
var _d = useAppSelector(function (state) { return state.global; }), formStyle = _d.formStyle, postview = _d.postview;
|
|
23
|
+
var widthStats = useAppSelector(function (state) { return state.widthStats; });
|
|
19
24
|
var calcName = (customElementModifiers !== null && customElementModifiers !== void 0 ? customElementModifiers : {}).calcName;
|
|
20
25
|
var name = calcName
|
|
21
26
|
? calcName(element)
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { MapperStepProps } from '../../MapperStep';
|
|
3
2
|
import { MapperElement } from '../MaterialMapperStep';
|
|
3
|
+
import React from 'react';
|
|
4
4
|
export interface MapperElementComponentProps<Type> {
|
|
5
5
|
num: number;
|
|
6
6
|
loading: boolean;
|
|
7
7
|
element: MapperElement<Type>;
|
|
8
|
-
handleDelete:
|
|
8
|
+
handleDelete: () => void;
|
|
9
|
+
children?: React.ReactNode;
|
|
9
10
|
}
|
|
10
11
|
declare function MapperElementComponent<Type = any>(props: MapperStepProps<Type> & MapperElementComponentProps<Type>): JSX.Element;
|
|
11
12
|
export default MapperElementComponent;
|
|
@@ -15,22 +15,30 @@ import StepComponent from '../../../Step';
|
|
|
15
15
|
import { MapperStyleTypes } from '../../../../constants/FormStepTypes';
|
|
16
16
|
import ListMapperElement from './ListMapperElement/ListMapperElement';
|
|
17
17
|
import PillMapperElement from './PillMapperElement/PillMapperElement';
|
|
18
|
-
import React from 'react';
|
|
18
|
+
import React, { useContext, useMemo } from 'react';
|
|
19
|
+
import FormContext from '../../../../Contexts/FormContext';
|
|
20
|
+
import CustomContext from '../../../../Contexts/CustomContext';
|
|
19
21
|
function MapperElementComponent(props) {
|
|
20
|
-
var _a
|
|
21
|
-
var level = props.level,
|
|
22
|
+
var _a;
|
|
23
|
+
var level = props.level, step = props.step, element = props.element, editable = props.editable;
|
|
24
|
+
var customContext = useContext(CustomContext);
|
|
25
|
+
var form = useContext(FormContext);
|
|
22
26
|
if (element.deleted) {
|
|
23
27
|
return _jsx("div", {});
|
|
24
28
|
}
|
|
25
|
-
var
|
|
29
|
+
var nestedCustomContext = useMemo(function () {
|
|
30
|
+
if (!props.calcCustomStepProps)
|
|
31
|
+
return customContext;
|
|
32
|
+
return __assign(__assign({}, customContext), { customStepProps: props.calcCustomStepProps(element, customContext.customStepProps) });
|
|
33
|
+
}, [element, customContext]);
|
|
26
34
|
var mapSubSteps = function () {
|
|
27
|
-
return step.rootSteps.map(function (idSubStep) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
35
|
+
return (_jsx(CustomContext.Provider, __assign({ value: nestedCustomContext }, { children: step.rootSteps.map(function (idSubStep) {
|
|
36
|
+
var _a;
|
|
37
|
+
var subStep = form.steps[element.ids[idSubStep]];
|
|
38
|
+
return (_createElement(StepComponent, __assign({}, props, { editable: editable ? (_a = step.editable) !== null && _a !== void 0 ? _a : true : false, step: subStep, key: element.ids[idSubStep], level: level + 1 })));
|
|
39
|
+
}) })));
|
|
32
40
|
};
|
|
33
|
-
switch ((
|
|
41
|
+
switch ((_a = step.style) === null || _a === void 0 ? void 0 : _a.type) {
|
|
34
42
|
case MapperStyleTypes.INLINE:
|
|
35
43
|
return _jsx(React.Fragment, { children: mapSubSteps() });
|
|
36
44
|
case MapperStyleTypes.LIST:
|
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { MapperStepProps } from '../../../MapperStep';
|
|
3
3
|
import { MapperElementComponentProps } from '../MapperElement';
|
|
4
|
-
declare function PillMapperElement<Type = any>({ step,
|
|
5
|
-
num: number;
|
|
6
|
-
formStyle: {
|
|
7
|
-
textColor: string;
|
|
8
|
-
};
|
|
9
|
-
handleDelete?: Function;
|
|
10
|
-
/** children to render */
|
|
11
|
-
children?: any;
|
|
12
|
-
}): JSX.Element;
|
|
4
|
+
declare function PillMapperElement<Type = any>({ step, num, loading, element, children, editable, handleDelete, customElementModifiers, customElementRender, }: MapperStepProps<Type> & MapperElementComponentProps<Type>): JSX.Element;
|
|
13
5
|
export default PillMapperElement;
|
package/dist/FormSteps/MapperStep/MaterialMapperStep/Element/PillMapperElement/PillMapperElement.js
CHANGED
|
@@ -10,13 +10,18 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { useContext } from 'react';
|
|
13
14
|
import styles from './PillMapperElement.module.css';
|
|
14
15
|
import DeleteRoundedIcon from '@material-ui/icons/DeleteRounded';
|
|
16
|
+
import FormContext from '../../../../../Contexts/FormContext';
|
|
17
|
+
import { useAppSelector } from '../../../../../hooks';
|
|
15
18
|
function PillMapperElement(_a) {
|
|
16
19
|
var _b;
|
|
17
|
-
var step = _a.step,
|
|
20
|
+
var step = _a.step, num = _a.num, loading = _a.loading, element = _a.element, children = _a.children, editable = _a.editable, handleDelete = _a.handleDelete, customElementModifiers = _a.customElementModifiers, customElementRender = _a.customElementRender;
|
|
18
21
|
var deletable = (_b = step.deletable) !== null && _b !== void 0 ? _b : true;
|
|
19
|
-
var size =
|
|
22
|
+
var size = useContext(FormContext).size;
|
|
23
|
+
var _c = useAppSelector(function (state) { return state.global; }), formStyle = _c.formStyle, postview = _c.postview;
|
|
24
|
+
var widthStats = useAppSelector(function (state) { return state.widthStats; });
|
|
20
25
|
var calcName = (customElementModifiers !== null && customElementModifiers !== void 0 ? customElementModifiers : {}).calcName;
|
|
21
26
|
var name = calcName
|
|
22
27
|
? calcName(element)
|
|
@@ -8,7 +8,7 @@ export interface MapperElement<Type> {
|
|
|
8
8
|
originalValues: Record<string, any>;
|
|
9
9
|
isOriginal: boolean;
|
|
10
10
|
}
|
|
11
|
-
export declare function ElementsComponent<Type = any>({ step,
|
|
11
|
+
export declare function ElementsComponent<Type = any>({ step, inputRef, editable, elements, customAdd, loading, ...others }: MapperStepProps<Type> & {
|
|
12
12
|
loading?: boolean;
|
|
13
13
|
onChange: (elements: MapperElement<Type>[]) => void;
|
|
14
14
|
elements: MapperElement<Type>[];
|