@arquimedes.co/eureka-forms 2.0.54 → 2.0.55
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/Condition.d.ts +54 -2
- package/dist/@Types/Draft/Draft.d.ts +12 -0
- package/dist/@Types/Draft/Draft.js +1 -0
- package/dist/@Types/Draft/DraftEntityData.d.ts +50 -0
- package/dist/@Types/Draft/DraftEntityData.js +1 -0
- package/dist/@Types/Entity.d.ts +33 -0
- package/dist/@Types/Entity.js +1 -0
- package/dist/@Types/Form.d.ts +7 -0
- package/dist/@Types/FormStep.d.ts +7 -0
- package/dist/App/App.css +14 -0
- package/dist/App/AppFunctions.d.ts +2 -2
- package/dist/App/AppFunctions.js +167 -156
- package/dist/App/AppHooks.js +12 -8
- package/dist/Contexts/FormContext.d.ts +2 -0
- package/dist/Contexts/FormContext.js +49 -0
- package/dist/Form/ConfirmationDialog/ConfirmationDialog.js +30 -5
- package/dist/Form/ConfirmationDialog/ConfirmationDialog.module.css +2 -0
- package/dist/Form/Form.js +1 -1
- package/dist/Form/FormFunctions.js +15 -12
- package/dist/Form/FormTypes/StepperForm/StepperForm.js +10 -7
- package/dist/FormSteps/EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValueDialog/MaterialEntityValueDialog.d.ts +12 -0
- package/dist/FormSteps/EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValueDialog/MaterialEntityValueDialog.js +49 -0
- package/dist/FormSteps/EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValueDialog/MaterialEntityValueDialog.module.css +60 -0
- package/dist/FormSteps/EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValuePickerStep.js +103 -49
- package/dist/FormSteps/MapperStep/MaterialMapperStep/Element/MapperElementComponent.d.ts +3 -0
- package/dist/FormSteps/MapperStep/MaterialMapperStep/Element/MapperElementComponent.js +3 -0
- package/dist/FormSteps/MapperStep/MaterialMapperStep/Element/PagedMapperElement/PagedMapperElement.d.ts +5 -0
- package/dist/FormSteps/MapperStep/MaterialMapperStep/Element/PagedMapperElement/PagedMapperElement.js +204 -0
- package/dist/FormSteps/MapperStep/MaterialMapperStep/Element/PagedMapperElement/PagedMapperElement.module.css +75 -0
- package/dist/FormSteps/MapperStep/MaterialMapperStep/MaterialMapperStep.d.ts +6 -2
- package/dist/FormSteps/MapperStep/MaterialMapperStep/MaterialMapperStep.js +44 -14
- package/dist/FormSteps/StepFunctions.d.ts +11 -1
- package/dist/FormSteps/StepFunctions.js +146 -1
- package/dist/FormSteps/StepHooks.js +12 -4
- package/dist/Shared/CustomBtn/CustomBtn.d.ts +7 -2
- package/dist/Shared/CustomBtn/CustomBtn.js +14 -5
- package/dist/Shared/CustomBtn/CustomBtn.module.css +0 -2
- package/dist/States/GlobalSlice.d.ts +9 -0
- package/dist/States/GlobalSlice.js +5 -0
- package/dist/States/SiteSlice.d.ts +32 -3
- package/dist/States/SiteSlice.js +50 -5
- package/dist/Utils/DraftFunctions.d.ts +21 -0
- package/dist/Utils/DraftFunctions.js +239 -0
- package/dist/constants/ConditionTypes.d.ts +6 -1
- package/dist/constants/ConditionTypes.js +5 -0
- package/dist/constants/Draft/DraftEntityDataTypes.d.ts +10 -0
- package/dist/constants/Draft/DraftEntityDataTypes.js +12 -0
- package/dist/constants/Draft/DraftEntityTypes.d.ts +3 -0
- package/dist/constants/Draft/DraftEntityTypes.js +4 -0
- package/dist/constants/Draft/DraftStyleTypes.d.ts +7 -0
- package/dist/constants/Draft/DraftStyleTypes.js +8 -0
- package/dist/constants/EntityPropertyTypes.d.ts +9 -0
- package/dist/constants/EntityPropertyTypes.js +10 -0
- package/dist/constants/FormStepTypes.d.ts +1 -0
- package/dist/constants/FormStepTypes.js +1 -0
- package/dist/constants/TicketPropertyTypes.d.ts +3 -0
- package/dist/constants/TicketPropertyTypes.js +4 -0
- package/package.json +2 -2
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { MapperStepProps } from '../../MapperStep';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { MapperElement } from '../../../../@Types/MapperElement';
|
|
4
|
+
import { MapperValue } from '../MaterialMapperStep';
|
|
4
5
|
export interface MapperElementComponentProps<Type> {
|
|
5
6
|
num: number;
|
|
6
7
|
loading?: boolean;
|
|
7
8
|
element: MapperElement<Type>;
|
|
9
|
+
onChange: (value: MapperValue<Type>) => void;
|
|
10
|
+
value: MapperValue<Type>;
|
|
8
11
|
handleDelete: () => void;
|
|
9
12
|
children?: React.ReactNode;
|
|
10
13
|
}
|
|
@@ -18,6 +18,7 @@ import PillMapperElement from './PillMapperElement/PillMapperElement';
|
|
|
18
18
|
import React, { useContext, useMemo } from 'react';
|
|
19
19
|
import FormContext from '../../../../Contexts/FormContext';
|
|
20
20
|
import CustomContext from '../../../../Contexts/CustomContext';
|
|
21
|
+
import PagedMapperElement from './PagedMapperElement/PagedMapperElement';
|
|
21
22
|
function MapperElementComponent(props) {
|
|
22
23
|
var _a;
|
|
23
24
|
var step = props.step, element = props.element, editable = props.editable;
|
|
@@ -43,6 +44,8 @@ function MapperElementComponent(props) {
|
|
|
43
44
|
return _jsx(React.Fragment, { children: mapSubSteps() });
|
|
44
45
|
case MapperStyleTypes.LIST:
|
|
45
46
|
return (_jsx(ListMapperElement, __assign({}, props, { step: step }, { children: mapSubSteps() })));
|
|
47
|
+
case MapperStyleTypes.PAGED:
|
|
48
|
+
return (_jsx(PagedMapperElement, __assign({}, props, { step: step }, { children: mapSubSteps() })));
|
|
46
49
|
case MapperStyleTypes.PILL:
|
|
47
50
|
default:
|
|
48
51
|
return (_jsx(PillMapperElement, __assign({}, props, { step: step }, { children: mapSubSteps() })));
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { MapperStepProps } from '../../../MapperStep';
|
|
3
|
+
import { MapperElementComponentProps } from '../MapperElementComponent';
|
|
4
|
+
declare function PagedMapperElement<Type = any>({ step, num, loading, element, children, editable, onChange, value, handleDelete, customElementModifiers, customElementRender, }: MapperStepProps<Type> & MapperElementComponentProps<Type>): JSX.Element;
|
|
5
|
+
export default PagedMapperElement;
|
|
@@ -0,0 +1,204 @@
|
|
|
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 { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
49
|
+
import React, { useCallback, useContext, useMemo } from 'react';
|
|
50
|
+
import styles from './PagedMapperElement.module.css';
|
|
51
|
+
import DeleteRoundedIcon from '@material-ui/icons/DeleteRounded';
|
|
52
|
+
import FormContext from '../../../../../Contexts/FormContext';
|
|
53
|
+
import { useAppDispatch, useAppSelector } from '../../../../../hooks';
|
|
54
|
+
import { MobileStepper, makeStyles } from '@material-ui/core';
|
|
55
|
+
import { KeyboardArrowLeft, KeyboardArrowRight } from '@material-ui/icons';
|
|
56
|
+
import CustomBtn from '../../../../../Shared/CustomBtn/CustomBtn';
|
|
57
|
+
import { useFormContext } from 'react-hook-form';
|
|
58
|
+
import { updateNestedValues } from '../../../../../States/SiteSlice';
|
|
59
|
+
function PagedMapperElement(_a) {
|
|
60
|
+
var _this = this;
|
|
61
|
+
var _b;
|
|
62
|
+
var step = _a.step, num = _a.num, loading = _a.loading, element = _a.element, children = _a.children, editable = _a.editable, onChange = _a.onChange, value = _a.value, handleDelete = _a.handleDelete, customElementModifiers = _a.customElementModifiers, customElementRender = _a.customElementRender;
|
|
63
|
+
var deletable = (_b = step.deletable) !== null && _b !== void 0 ? _b : true;
|
|
64
|
+
var size = useContext(FormContext).size;
|
|
65
|
+
var elements = value.elements, page = value.page;
|
|
66
|
+
var dispatch = useAppDispatch();
|
|
67
|
+
var _c = useAppSelector(function (state) { return state.global; }), formStyle = _c.formStyle, postview = _c.postview;
|
|
68
|
+
var totalElements = elements.filter(function (elem) { return !elem.deleted; });
|
|
69
|
+
var position = totalElements.findIndex(function (e) { return e.id == element.id; });
|
|
70
|
+
var pagingRef = React.useRef(null);
|
|
71
|
+
var _d = useFormContext(), getValues = _d.getValues, trigger = _d.trigger, handleSubmit = _d.handleSubmit;
|
|
72
|
+
var nextIndex = useMemo(function () {
|
|
73
|
+
for (var i = page + 1; i < elements.length; i++) {
|
|
74
|
+
var element_1 = elements[i];
|
|
75
|
+
if (!element_1.deleted) {
|
|
76
|
+
return i;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return null;
|
|
80
|
+
}, [value]);
|
|
81
|
+
var prevIndex = useMemo(function () {
|
|
82
|
+
for (var i = page - 1; i >= 0; i--) {
|
|
83
|
+
var element_2 = elements[i];
|
|
84
|
+
if (!element_2.deleted) {
|
|
85
|
+
return i;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return null;
|
|
89
|
+
}, [value]);
|
|
90
|
+
/** Esto se usa para no tener que escuchar todo el tiempo los errores del formulario */
|
|
91
|
+
var handleErrors = handleSubmit(function () { }, function (errors) {
|
|
92
|
+
console.error('Errors:', errors);
|
|
93
|
+
});
|
|
94
|
+
var handleChangePage = useCallback(function (index) { return __awaiter(_this, void 0, void 0, function () {
|
|
95
|
+
var valid, values, nestedValues, _i, _a, _b, key, value_1;
|
|
96
|
+
return __generator(this, function (_c) {
|
|
97
|
+
switch (_c.label) {
|
|
98
|
+
case 0: return [4 /*yield*/, trigger(undefined, { shouldFocus: true })];
|
|
99
|
+
case 1:
|
|
100
|
+
valid = _c.sent();
|
|
101
|
+
/** Imprimir errores si no es valido */
|
|
102
|
+
if (!valid) {
|
|
103
|
+
handleErrors();
|
|
104
|
+
return [2 /*return*/];
|
|
105
|
+
}
|
|
106
|
+
values = getValues();
|
|
107
|
+
nestedValues = {};
|
|
108
|
+
for (_i = 0, _a = Object.entries(values); _i < _a.length; _i++) {
|
|
109
|
+
_b = _a[_i], key = _b[0], value_1 = _b[1];
|
|
110
|
+
if (key.startsWith(step.id + '-' + element.id)) {
|
|
111
|
+
nestedValues[key] = value_1;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
dispatch(updateNestedValues({
|
|
115
|
+
key: step.id + '-' + element.id,
|
|
116
|
+
values: nestedValues,
|
|
117
|
+
}));
|
|
118
|
+
location.href = '#' + step.id;
|
|
119
|
+
//Updated the nestedValues in the values store.
|
|
120
|
+
onChange({
|
|
121
|
+
elements: elements,
|
|
122
|
+
page: index,
|
|
123
|
+
});
|
|
124
|
+
return [2 /*return*/];
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
}); }, [elements]);
|
|
128
|
+
var widthStats = useAppSelector(function (state) { return state.widthStats; });
|
|
129
|
+
var calcName = (customElementModifiers !== null && customElementModifiers !== void 0 ? customElementModifiers : {}).calcName;
|
|
130
|
+
var name = calcName
|
|
131
|
+
? calcName(element)
|
|
132
|
+
: step.unitLabel
|
|
133
|
+
? step.unitLabel + ' ' + (num + 1)
|
|
134
|
+
: '';
|
|
135
|
+
var renderElement = function (renderElementButtons) {
|
|
136
|
+
var _a, _b, _c;
|
|
137
|
+
return (_jsx("div", __assign({ className: widthStats.isMobile
|
|
138
|
+
? styles.mobileContainer
|
|
139
|
+
: styles.container }, { children: _jsxs("div", __assign({ className: styles.contentContainer, style: {
|
|
140
|
+
width: (size.blockSize + size.spacingSize) *
|
|
141
|
+
((_b = (_a = step.style) === null || _a === void 0 ? void 0 : _a.size) !== null && _b !== void 0 ? _b : size.blockNum - 1),
|
|
142
|
+
} }, { children: [name && (_jsx("div", __assign({ className: styles.titleLbl, style: { color: formStyle.textColor } }, { children: loading ? 'Cargando...' : name + ':' }))), _jsxs("div", __assign({ className: styles.btnsContainer }, { children: [renderElementButtons === null || renderElementButtons === void 0 ? void 0 : renderElementButtons(element), (deletable || !element.isOriginal) && (_jsx("div", __assign({ className: !editable || postview
|
|
143
|
+
? styles.disabledDeleteBtn
|
|
144
|
+
: styles.deleteBtn, style: { color: formStyle.textColor }, onClick: function () {
|
|
145
|
+
if (editable && !postview) {
|
|
146
|
+
handleDelete === null || handleDelete === void 0 ? void 0 : handleDelete();
|
|
147
|
+
}
|
|
148
|
+
} }, { children: _jsx(DeleteRoundedIcon, { fontSize: "inherit" }) })))] })), children, totalElements.length > 0 && (_jsx("div", __assign({ className: styles.pagingContainer, ref: pagingRef }, { children: _jsx(CustomStepper, { totalElements: totalElements.length, position: position, handleNext: nextIndex !== null
|
|
149
|
+
? function () {
|
|
150
|
+
return handleChangePage(nextIndex);
|
|
151
|
+
}
|
|
152
|
+
: undefined, handlePrev: prevIndex !== null
|
|
153
|
+
? function () {
|
|
154
|
+
return handleChangePage(prevIndex);
|
|
155
|
+
}
|
|
156
|
+
: undefined, width: (_c = pagingRef.current) === null || _c === void 0 ? void 0 : _c.clientWidth }) })))] })) })));
|
|
157
|
+
};
|
|
158
|
+
return (_jsx("div", __assign({ className: styles.containerContainer }, { children: customElementRender
|
|
159
|
+
? customElementRender(element, num, renderElement)
|
|
160
|
+
: renderElement() })));
|
|
161
|
+
}
|
|
162
|
+
export default PagedMapperElement;
|
|
163
|
+
var useStepperStyles = function (props) {
|
|
164
|
+
return makeStyles(function () { return ({
|
|
165
|
+
root: {
|
|
166
|
+
backgroundColor: 'transparent',
|
|
167
|
+
padding: '10px',
|
|
168
|
+
'& .EF-MuiMobileStepper-dot': {
|
|
169
|
+
width: 11,
|
|
170
|
+
height: 11,
|
|
171
|
+
backgroundColor: props.outlineColor,
|
|
172
|
+
},
|
|
173
|
+
'& .EF-MuiMobileStepper-dotActive': {
|
|
174
|
+
backgroundColor: props.primaryColor,
|
|
175
|
+
},
|
|
176
|
+
'& .EF-MuiLinearProgress-root': {
|
|
177
|
+
height: 8,
|
|
178
|
+
backgroundColor: props.outlineColor,
|
|
179
|
+
borderRadius: 4,
|
|
180
|
+
margin: '0px 8px',
|
|
181
|
+
},
|
|
182
|
+
'& .EF-MuiLinearProgress-barColorPrimary': {
|
|
183
|
+
backgroundColor: props.primaryColor,
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
}); });
|
|
187
|
+
};
|
|
188
|
+
function CustomStepper(_a) {
|
|
189
|
+
var position = _a.position, handleNext = _a.handleNext, totalElements = _a.totalElements, width = _a.width, handlePrev = _a.handlePrev;
|
|
190
|
+
var formStyle = useAppSelector(function (state) { return state.global.formStyle; });
|
|
191
|
+
var classes = useStepperStyles(formStyle)();
|
|
192
|
+
var fits = useMemo(function () {
|
|
193
|
+
return (width !== null && width !== void 0 ? width : 0) > 16 + totalElements * 15 + 128;
|
|
194
|
+
}, [width]);
|
|
195
|
+
if (!width)
|
|
196
|
+
return _jsx(_Fragment, {});
|
|
197
|
+
return (_jsx(MobileStepper, { className: classes.root, steps: totalElements, position: "static", variant: fits ? 'dots' : 'progress', activeStep: position, nextButton: _jsx(CustomBtn, __assign({ onClick: handleNext, disabled: !handleNext, backgroundColor: formStyle.primaryColor, color: formStyle.primaryContrastColor, padding: "0px", height: "30px", width: "54px", borderRadius: "10px" }, { children: _jsx(KeyboardArrowRight, { style: {
|
|
198
|
+
width: 30,
|
|
199
|
+
height: 30,
|
|
200
|
+
} }) })), backButton: _jsx(CustomBtn, __assign({ onClick: handlePrev, disabled: !handlePrev, backgroundColor: formStyle.primaryColor, color: formStyle.primaryContrastColor, padding: "0px", height: "30px", width: "54px", borderRadius: "10px" }, { children: _jsx(KeyboardArrowLeft, { style: {
|
|
201
|
+
width: 30,
|
|
202
|
+
height: 30,
|
|
203
|
+
} }) })) }));
|
|
204
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
.containerContainer {
|
|
2
|
+
margin-top: 10px;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.container,
|
|
6
|
+
.mobileContainer {
|
|
7
|
+
background-color: #f0f0f0;
|
|
8
|
+
border: 1px solid #d6d6d6;
|
|
9
|
+
width: fit-content;
|
|
10
|
+
border-radius: 20px;
|
|
11
|
+
margin-bottom: 10px;
|
|
12
|
+
margin-left: auto;
|
|
13
|
+
margin-right: auto;
|
|
14
|
+
position: relative;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.container {
|
|
18
|
+
max-width: calc(100% - 112px);
|
|
19
|
+
padding-right: 55px;
|
|
20
|
+
padding-left: 55px;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.mobileContainer {
|
|
24
|
+
max-width: calc(100% - 42px);
|
|
25
|
+
padding-right: 20px;
|
|
26
|
+
padding-left: 20px;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.titleLbl {
|
|
30
|
+
width: 100%;
|
|
31
|
+
font-size: 20px;
|
|
32
|
+
font-weight: 600;
|
|
33
|
+
white-space: nowrap;
|
|
34
|
+
overflow: hidden;
|
|
35
|
+
text-overflow: ellipsis;
|
|
36
|
+
cursor: default;
|
|
37
|
+
margin-left: 10px;
|
|
38
|
+
margin-bottom: 10px;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.contentContainer {
|
|
42
|
+
margin-left: auto;
|
|
43
|
+
margin-right: auto;
|
|
44
|
+
display: flex;
|
|
45
|
+
flex-flow: row wrap;
|
|
46
|
+
height: fit-content;
|
|
47
|
+
max-width: 100%;
|
|
48
|
+
overflow-x: hidden;
|
|
49
|
+
overflow-y: hidden;
|
|
50
|
+
padding-top: 20px;
|
|
51
|
+
padding-bottom: 20px;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.btnsContainer {
|
|
55
|
+
position: absolute;
|
|
56
|
+
right: 15px;
|
|
57
|
+
top: 15px;
|
|
58
|
+
display: flex;
|
|
59
|
+
flex-direction: row;
|
|
60
|
+
gap: 5px;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.deleteBtn,
|
|
64
|
+
.disabledDeleteBtn {
|
|
65
|
+
font-size: 24px;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.deleteBtn {
|
|
69
|
+
cursor: pointer;
|
|
70
|
+
height: 24px;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.pagingContainer {
|
|
74
|
+
width: 100%;
|
|
75
|
+
}
|
|
@@ -3,13 +3,17 @@ import { MapperStepProps } from '../MapperStep';
|
|
|
3
3
|
import { FieldError } from 'react-hook-form';
|
|
4
4
|
import { MapperElement } from '../../../@Types/MapperElement';
|
|
5
5
|
import { Form } from '../../../@Types';
|
|
6
|
+
export interface MapperValue<Type> {
|
|
7
|
+
elements: MapperElement<Type>[];
|
|
8
|
+
page: number;
|
|
9
|
+
}
|
|
6
10
|
export interface MapperComponentProps<Type> extends MapperStepProps<Type> {
|
|
7
11
|
form: Form;
|
|
8
12
|
loading?: boolean;
|
|
9
13
|
error: FieldError | undefined;
|
|
10
|
-
onChange: (
|
|
14
|
+
onChange: (value: MapperValue<Type>) => void;
|
|
11
15
|
handleAddElement: (elementValue?: Type) => void;
|
|
12
|
-
|
|
16
|
+
value: MapperValue<Type>;
|
|
13
17
|
inputRef: any;
|
|
14
18
|
}
|
|
15
19
|
declare function MapperStep<Type>(props: MapperStepProps<Type>): JSX.Element;
|
|
@@ -29,8 +29,8 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
29
29
|
}
|
|
30
30
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
31
31
|
};
|
|
32
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
33
32
|
import { createElement as _createElement } from "react";
|
|
33
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
34
34
|
import React, { useState, useEffect, useContext, useMemo, useCallback, } from 'react';
|
|
35
35
|
import styles from './MaterialMapperStep.module.css';
|
|
36
36
|
import { useFormContext } from 'react-hook-form';
|
|
@@ -45,11 +45,23 @@ import { useFormStep } from '../../StepHooks';
|
|
|
45
45
|
import { addMapperStep } from '../../../App/AppFunctions';
|
|
46
46
|
import { calcMapperSubSteps } from '../../../Form/FormFunctions';
|
|
47
47
|
function MapperComponent(_a) {
|
|
48
|
-
var form = _a.form, step = _a.step, error = _a.error, loading = _a.loading, inputRef = _a.inputRef, editable = _a.editable, customAdd = _a.customAdd,
|
|
48
|
+
var form = _a.form, step = _a.step, error = _a.error, value = _a.value, loading = _a.loading, inputRef = _a.inputRef, editable = _a.editable, customAdd = _a.customAdd, onChange = _a.onChange, handleAddElement = _a.handleAddElement, others = __rest(_a, ["form", "step", "error", "value", "loading", "inputRef", "editable", "customAdd", "onChange", "handleAddElement"]);
|
|
49
|
+
var page = value.page, elements = value.elements;
|
|
49
50
|
var handleDeleteElement = useCallback(function (index) { return function () {
|
|
50
51
|
var tempElements = __spreadArray([], elements, true);
|
|
51
52
|
tempElements[index] = __assign(__assign({}, tempElements[index]), { deleted: true });
|
|
52
|
-
|
|
53
|
+
var newPage = 0;
|
|
54
|
+
for (var i = page; i >= 0; i--) {
|
|
55
|
+
var element = elements[i];
|
|
56
|
+
if (!element.deleted) {
|
|
57
|
+
newPage = i;
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
onChange({
|
|
62
|
+
elements: tempElements,
|
|
63
|
+
page: page === index ? newPage : page,
|
|
64
|
+
});
|
|
53
65
|
}; }, [elements, onChange]);
|
|
54
66
|
var inputValue = useMemo(function () { return JSON.stringify(elements); }, [elements]);
|
|
55
67
|
var _b = useAppSelector(function (state) { return state.global; }), formStyle = _b.formStyle, postview = _b.postview;
|
|
@@ -64,11 +76,17 @@ function MapperComponent(_a) {
|
|
|
64
76
|
}
|
|
65
77
|
}, [step]).container;
|
|
66
78
|
var mapElements = function () {
|
|
67
|
-
|
|
79
|
+
if (step.style.type === MapperStyleTypes.PAGED) {
|
|
80
|
+
var element = elements[page];
|
|
81
|
+
if (!element)
|
|
82
|
+
return _jsx(_Fragment, {});
|
|
83
|
+
return (_jsx(FormContext.Provider, __assign({ value: form }, { children: _createElement(MapperElementComponent, __assign({}, others, { key: element.id, num: page, element: element, step: step, editable: editable, loading: loading, onChange: onChange, value: value, handleDelete: handleDeleteElement(page) })) })));
|
|
84
|
+
}
|
|
85
|
+
return (_jsx(FormContext.Provider, __assign({ value: form }, { children: elements.map(function (element, index) { return (_createElement(MapperElementComponent, __assign({}, others, { num: index, key: element.id, element: element, step: step, editable: editable, loading: loading, onChange: onChange, value: value, handleDelete: handleDeleteElement(index) }))); }) })));
|
|
68
86
|
};
|
|
69
87
|
if (step.style.type === MapperStyleTypes.INLINE)
|
|
70
88
|
return _jsx(React.Fragment, { children: mapElements() });
|
|
71
|
-
return (_jsxs("div", __assign({ className: container, style: { color: formStyle.textColor }, "data-testid": step.id }, { children: [step.label && _jsx("div", __assign({ className: styles.titleLbl }, { children: step.label })), step.description && (_jsx("p", __assign({ className: styles.descriptionPar, style: {
|
|
89
|
+
return (_jsxs("div", __assign({ className: container, style: { color: formStyle.textColor }, "data-testid": step.id, id: step.id }, { children: [step.label && _jsx("div", __assign({ className: styles.titleLbl }, { children: step.label })), step.description && (_jsx("p", __assign({ className: styles.descriptionPar, style: {
|
|
72
90
|
margin: step.description
|
|
73
91
|
? '10px 0px'
|
|
74
92
|
: '0px 0px 5px 0px',
|
|
@@ -90,7 +108,7 @@ function MapperStep(props) {
|
|
|
90
108
|
var dispatch = useAppDispatch();
|
|
91
109
|
var setValue = useFormContext().setValue;
|
|
92
110
|
var _a = useFormStep(step, {
|
|
93
|
-
defaultValue: [],
|
|
111
|
+
defaultValue: { elements: [], page: 0 },
|
|
94
112
|
rules: {
|
|
95
113
|
validate: function (array) {
|
|
96
114
|
return !step.required ||
|
|
@@ -99,10 +117,11 @@ function MapperStep(props) {
|
|
|
99
117
|
},
|
|
100
118
|
},
|
|
101
119
|
}), ref = _a.ref, value = _a.value, onChange = _a.onChange, error = _a.error;
|
|
102
|
-
var
|
|
120
|
+
var elements = value.elements;
|
|
121
|
+
var _b = useState(calcMapperSubSteps(step, elements, customSteps)), localSteps = _b[0], setLocalSteps = _b[1];
|
|
103
122
|
//Por alguna razón si se saca esto del componente no se ejecuta el agregar inicial
|
|
104
123
|
useEffect(function () {
|
|
105
|
-
if (
|
|
124
|
+
if (elements.length === 0 && !postview && editable && step.creatable) {
|
|
106
125
|
if (!customAdd)
|
|
107
126
|
handleAddElement();
|
|
108
127
|
}
|
|
@@ -115,8 +134,13 @@ function MapperStep(props) {
|
|
|
115
134
|
var _c = _b[_i], key = _c[0], elems = _c[1];
|
|
116
135
|
setValue(key, elems);
|
|
117
136
|
}
|
|
118
|
-
var newElements = __spreadArray(__spreadArray([],
|
|
119
|
-
onChange(
|
|
137
|
+
var newElements = __spreadArray(__spreadArray([], elements, true), [element], false);
|
|
138
|
+
onChange({
|
|
139
|
+
elements: newElements,
|
|
140
|
+
page: step.style.type === MapperStyleTypes.PAGED
|
|
141
|
+
? elements.length - 1
|
|
142
|
+
: 0,
|
|
143
|
+
});
|
|
120
144
|
setLocalSteps(function (oldLocalSteps) { return (__assign(__assign({}, oldLocalSteps), steps)); });
|
|
121
145
|
dispatch(addStepsDependencies({
|
|
122
146
|
steps: steps,
|
|
@@ -125,10 +149,11 @@ function MapperStep(props) {
|
|
|
125
149
|
}));
|
|
126
150
|
}, [step, form, customSteps, value, onChange]);
|
|
127
151
|
var subForm = useMemo(function () { return (__assign(__assign({}, form), { steps: __assign(__assign({}, form.steps), localSteps) })); }, [localSteps]);
|
|
128
|
-
return (_jsx(MapperComponent, __assign({}, props, { error: error, inputRef: ref, onChange: onChange, handleAddElement: handleAddElement, form: subForm
|
|
152
|
+
return (_jsx(MapperComponent, __assign({}, props, { error: error, inputRef: ref, onChange: onChange, value: value, handleAddElement: handleAddElement, form: subForm })));
|
|
129
153
|
}
|
|
130
154
|
export function CustomMapperStep(props) {
|
|
131
|
-
var step = props.step,
|
|
155
|
+
var step = props.step, value = props.value, onChange = props.onChange;
|
|
156
|
+
var elements = value.elements;
|
|
132
157
|
var form = useContext(FormContext);
|
|
133
158
|
var customSteps = useContext(CustomContext).customSteps;
|
|
134
159
|
var dispatch = useAppDispatch();
|
|
@@ -143,7 +168,12 @@ export function CustomMapperStep(props) {
|
|
|
143
168
|
setValue(key, elems);
|
|
144
169
|
}
|
|
145
170
|
var newElements = __spreadArray(__spreadArray([], elements, true), [element], false);
|
|
146
|
-
onChange(
|
|
171
|
+
onChange({
|
|
172
|
+
elements: newElements,
|
|
173
|
+
page: step.style.type === MapperStyleTypes.PAGED
|
|
174
|
+
? elements.length - 1
|
|
175
|
+
: 0,
|
|
176
|
+
});
|
|
147
177
|
setLocalSteps(function (oldLocalSteps) { return (__assign(__assign({}, oldLocalSteps), steps)); });
|
|
148
178
|
dispatch(addStepsDependencies({
|
|
149
179
|
steps: steps,
|
|
@@ -152,6 +182,6 @@ export function CustomMapperStep(props) {
|
|
|
152
182
|
}));
|
|
153
183
|
}, [step, form, customSteps, elements, onChange]);
|
|
154
184
|
var subForm = useMemo(function () { return (__assign(__assign({}, form), { steps: __assign(__assign({}, form.steps), localSteps) })); }, [localSteps]);
|
|
155
|
-
return (_jsx(MapperComponent, __assign({}, props, { form: subForm,
|
|
185
|
+
return (_jsx(MapperComponent, __assign({}, props, { form: subForm, onChange: onChange, handleAddElement: handleAddElement })));
|
|
156
186
|
}
|
|
157
187
|
export default MapperStep;
|
|
@@ -4,6 +4,7 @@ import { AYFFormStep } from '../@Types/AYFFormStep';
|
|
|
4
4
|
import { CBRFormStep } from '../@Types/CBRFormStep';
|
|
5
5
|
import { Condition } from '../@Types/Condition';
|
|
6
6
|
import { DependencyStore } from '../Form/Form';
|
|
7
|
+
import { Entity } from '../@Types/Entity';
|
|
7
8
|
export type FillerSteps = FormSelector | ClassifierSelector | EntityValuePicker | ApiSelector | CheckBox;
|
|
8
9
|
export declare function calcFillerSize(step: FillerSteps, steps: Record<string, FormStep>, values: Record<string, unknown>, size: FormSize): number;
|
|
9
10
|
export declare const calcStepWidth: (stepSize: 1 | 2 | 3 | 4, size: FormSize) => number;
|
|
@@ -16,4 +17,13 @@ export declare const iterateNestedSteps: (idStep: string, steps: Record<string,
|
|
|
16
17
|
* @returns list of the ids of the substeps of the step, if modifier returns modified steps
|
|
17
18
|
*/
|
|
18
19
|
export declare const calcSubSteps: (idStep: string, allSteps: Record<string, FormStep | CBRFormStep | AYFFormStep>, idModifier?: ((idSubStep: string) => string) | undefined) => string[];
|
|
19
|
-
export declare const evaluateCondition: (condition: Condition, dependencies: DependencyStore
|
|
20
|
+
export declare const evaluateCondition: (condition: Condition, dependencies: DependencyStore, entityValue?: {
|
|
21
|
+
entity?: Entity | undefined;
|
|
22
|
+
entityValue: {
|
|
23
|
+
_id: string;
|
|
24
|
+
value: string;
|
|
25
|
+
} & {
|
|
26
|
+
[key: string]: any;
|
|
27
|
+
};
|
|
28
|
+
} | undefined) => boolean;
|
|
29
|
+
export declare function getRelativeDate(nDays?: number, nHours?: number, nMinutes?: number, subtract?: boolean, date?: Date): Date;
|