@arquimedes.co/eureka-forms 1.9.16-test → 1.9.19-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/App.js +98 -205
- package/dist/AxiosAPI.js +3 -3
- package/dist/AxiosWidget.js +4 -4
- package/dist/FormComponents/Form/ColumnForm/ColumnForm.js +104 -207
- package/dist/FormComponents/Form/ConfirmationDialog/ConfirmationDialog.js +5 -17
- package/dist/FormComponents/Form/Form.js +29 -56
- package/dist/FormComponents/Form/StepperForm/StepperForm.js +1 -1
- package/dist/FormComponents/Section/MaterialSection/MaterialSection.js +7 -30
- package/dist/FormComponents/Section/Section.js +2 -13
- package/dist/FormComponents/Step/@Construction/CBRIncidentsStep/CBRIncidentsStep.js +2 -13
- package/dist/FormComponents/Step/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/Incident/Incident.js +9 -32
- package/dist/FormComponents/Step/@Construction/CBRIncidentsStep/MaterialCBRIncidentsStep/MaterialCBRIncidentsStep.js +47 -64
- package/dist/FormComponents/Step/@Construction/CBRLocativasStep/CBRLocativasStep.js +41 -102
- package/dist/FormComponents/Step/@Construction/CBRPropertyStep/CBRPropertyStep.js +37 -92
- package/dist/FormComponents/Step/AYFStepMapper.js +23 -75
- package/dist/FormComponents/Step/CBRStepMapper.js +56 -144
- package/dist/FormComponents/Step/CheckBoxStep/CheckBoxStep.js +3 -26
- package/dist/FormComponents/Step/CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxStep.js +6 -21
- package/dist/FormComponents/Step/ClassifierSelectorStep/ClassifierSelectorStep.js +3 -26
- package/dist/FormComponents/Step/ClassifierSelectorStep/MaterialClassifierSelectorStep/MaterialClassifierSelectorStep.js +32 -65
- package/dist/FormComponents/Step/DatePickerStep/DatePickerStep.js +2 -13
- package/dist/FormComponents/Step/DatePickerStep/MaterialDatePickerStep/MaterialDatePickerStep.js +6 -21
- package/dist/FormComponents/Step/FileUploadStep/FileUploadStep.js +2 -13
- package/dist/FormComponents/Step/FileUploadStep/MaterialFileUploadStep/FileComponent/FileComponent.js +27 -88
- package/dist/FormComponents/Step/FileUploadStep/MaterialFileUploadStep/MaterialFileUploadStep.js +81 -171
- package/dist/FormComponents/Step/RatingStep/MaterialRatingStep/MaterialRatingStep.js +15 -41
- package/dist/FormComponents/Step/RatingStep/RatingStep.js +2 -13
- package/dist/FormComponents/Step/SelectorStep/MaterialSelectorStep/MaterialSelectorStep.js +25 -52
- package/dist/FormComponents/Step/SelectorStep/SelectorStep.js +3 -26
- package/dist/FormComponents/Step/SeparatorStep/MaterialSeparatorStep/MaterialSeparatorStep.js +1 -2
- package/dist/FormComponents/Step/SeparatorStep/SeparatorStep.js +3 -26
- package/dist/FormComponents/Step/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.js +83 -145
- package/dist/FormComponents/Step/SmartSelectStep/SmartSelectStep.js +2 -13
- package/dist/FormComponents/Step/Step.js +19 -39
- package/dist/FormComponents/Step/StepFunctions.js +14 -16
- package/dist/FormComponents/Step/TextAreaStep/MaterialTextAreaStep/MaterialTextAreaStep.js +43 -62
- package/dist/FormComponents/Step/TextAreaStep/TextAreaStep.js +2 -13
- package/dist/FormComponents/Step/TextInputStep/MaterialTextInputStep/MaterialTextInputStep.js +6 -21
- package/dist/FormComponents/Step/TextInputStep/TextInputStep.js +2 -13
- package/dist/FormComponents/Step/TitleStep/MaterialTitleStep/MaterialTitleStep.js +3 -15
- package/dist/FormComponents/Step/TitleStep/TitleStep.js +3 -26
- package/dist/FormComponents/Term/MaterialTerm/MaterialTerm.js +19 -35
- package/dist/FormComponents/Term/Term.js +2 -13
- package/dist/Widget.js +13 -25
- package/dist/constants/Files/FileExtensions.js +3 -3
- package/dist/constants/Files/FileMaxSize.js +1 -1
- package/dist/constants/InternalFormStyle.js +1 -1
- package/dist/constants/MaterialClassNameSeed.js +1 -1
- package/dist/controllers/FileService.js +29 -86
- package/dist/index.js +4 -15
- package/dist/shared/Loader/Loader.js +5 -17
- package/dist/shared/Navbar/Navbar.js +2 -14
- package/dist/shared/Rating/Rating.js +4 -27
- package/dist/shared/Rating/Ratings/LikeRating.js +9 -21
- package/dist/shared/Rating/Ratings/SatisfactionRating.js +15 -27
- package/dist/shared/Rating/Ratings/ScaleRating.js +22 -49
- package/dist/shared/RoundedButton/RoundedButton.js +12 -24
- package/dist/shared/RoundedCheckBox/RoundedCheckBox.js +39 -84
- package/dist/shared/RoundedDatePicker/RoundedDatePicker.js +235 -286
- package/dist/shared/RoundedSelect/RoundedSelect.js +103 -152
- package/dist/shared/RoundedSmartSelect/RoundedSmartSelect.js +125 -160
- package/dist/shared/RoundedTextField/RoundedTextField.js +92 -137
- package/dist/utils/CbrFunctions.js +30 -30
- package/package.json +6 -4
|
@@ -1,25 +1,3 @@
|
|
|
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 __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
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
2
|
import React, { useEffect, useState } from 'react';
|
|
25
3
|
import { FormStyleTypes, FormTypes } from '../../constants/FormStepTypes';
|
|
@@ -34,31 +12,27 @@ import { SEED } from '../../constants/MaterialClassNameSeed';
|
|
|
34
12
|
import InternalFormStyle from '../../constants/InternalFormStyle';
|
|
35
13
|
import enLocale from 'date-fns/locale/en-US';
|
|
36
14
|
import esLocale from 'date-fns/locale/es';
|
|
37
|
-
|
|
15
|
+
const localeMap = {
|
|
38
16
|
en: enLocale,
|
|
39
17
|
'en-US': enLocale,
|
|
40
18
|
es: esLocale,
|
|
41
19
|
};
|
|
42
|
-
export
|
|
43
|
-
|
|
44
|
-
return ((_a = localeMap[navigator.languages && navigator.languages.length
|
|
20
|
+
export const getLocale = () => {
|
|
21
|
+
return (localeMap[navigator.languages && navigator.languages.length
|
|
45
22
|
? navigator.languages[0]
|
|
46
23
|
: navigator.userLanguage ||
|
|
47
24
|
navigator.language ||
|
|
48
|
-
navigator.browserLanguage]
|
|
25
|
+
navigator.browserLanguage] ?? localeMap.es);
|
|
49
26
|
};
|
|
50
|
-
function FormComponent(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
var _d = useState(false), loaded = _d[0], setLoaded = _d[1];
|
|
54
|
-
var _e = useState(undefined), widthStats = _e[0], setWidthStats = _e[1];
|
|
27
|
+
function FormComponent({ form, isWidget, internal, postview, organization, containerRef, ...others }) {
|
|
28
|
+
const [loaded, setLoaded] = useState(false);
|
|
29
|
+
const [widthStats, setWidthStats] = useState(undefined);
|
|
55
30
|
/** Calcs the currentBreakPoint and if is mobile */
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
var currentWidth = (_a = containerRef === null || containerRef === void 0 ? void 0 : containerRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth;
|
|
31
|
+
const handleResize = () => {
|
|
32
|
+
const currentWidth = containerRef?.current?.offsetWidth;
|
|
59
33
|
if (currentWidth !== undefined) {
|
|
60
|
-
|
|
61
|
-
|
|
34
|
+
let currentBreakPoint = form.size.blockNum;
|
|
35
|
+
const padding = postview || internal || !form.isStandAlone ? 0 : 40;
|
|
62
36
|
while (currentWidth <
|
|
63
37
|
(form.size.blockSize + form.size.spacingSize) *
|
|
64
38
|
currentBreakPoint +
|
|
@@ -72,72 +46,71 @@ function FormComponent(_a) {
|
|
|
72
46
|
padding,
|
|
73
47
|
isMobile: currentWidth <
|
|
74
48
|
(form.size.blockSize + form.size.spacingSize) * 2 + padding,
|
|
75
|
-
currentBreakPoint
|
|
49
|
+
currentBreakPoint,
|
|
76
50
|
});
|
|
77
51
|
}
|
|
78
52
|
};
|
|
79
|
-
useEffect(
|
|
53
|
+
useEffect(() => {
|
|
80
54
|
/** On load add a resize listener to calc the currentBreakpoint */
|
|
81
55
|
window.addEventListener('resize', handleResize);
|
|
82
56
|
handleResize();
|
|
83
|
-
return
|
|
57
|
+
return () => {
|
|
84
58
|
window.removeEventListener('resize', handleResize);
|
|
85
59
|
};
|
|
86
|
-
}, [containerRef.current,
|
|
60
|
+
}, [containerRef.current, containerRef.current?.offsetWidth]);
|
|
87
61
|
//If currently displaying internal or form is standalone
|
|
88
62
|
if ((postview || internal || !form.isStandAlone) &&
|
|
89
63
|
widthStats !== undefined) {
|
|
90
|
-
return (_jsx("div",
|
|
64
|
+
return (_jsx("div", { style: {
|
|
91
65
|
backgroundColor: internal
|
|
92
66
|
? InternalFormStyle.backgroundColor
|
|
93
67
|
: form.style.backgroundColor,
|
|
94
68
|
minHeight: form.isStandAlone && !isWidget ? '100vh' : '100%',
|
|
95
|
-
}
|
|
69
|
+
}, children: _jsx("div", { className: styles.widgetFormContainer, ref: containerRef, children: _jsx(FormTypeComponent, { ...others, handleLoaded: () => {
|
|
96
70
|
setLoaded(true);
|
|
97
|
-
}, widthStats: widthStats, form: form, internal: internal, postview: postview, organization: organization, formStyle: internal ? InternalFormStyle : form.style })
|
|
71
|
+
}, widthStats: widthStats, form: form, internal: internal, postview: postview, organization: organization, formStyle: internal ? InternalFormStyle : form.style }) }) }));
|
|
98
72
|
}
|
|
99
73
|
else if (organization && widthStats !== undefined) {
|
|
100
74
|
//Standalone cant have widget
|
|
101
|
-
return (_jsxs(React.Fragment, { children: [_jsx(Navbar, { logo: organization.logoUrl, color:
|
|
75
|
+
return (_jsxs(React.Fragment, { children: [_jsx(Navbar, { logo: organization.logoUrl, color: organization.styles?.primaryColor }), _jsx("div", { className: styles.standAloneFormContainer, ref: containerRef, children: _jsx("div", { className: widthStats.isResponsive
|
|
102
76
|
? styles.fullScreenStandAloneForm
|
|
103
77
|
: styles.standAloneFormCard, style: {
|
|
104
78
|
backgroundColor: form.style.backgroundColor,
|
|
105
79
|
visibility: loaded ? 'visible' : 'hidden',
|
|
106
|
-
}
|
|
80
|
+
}, children: _jsx(FormTypeComponent, { ...others, internal: internal, postview: postview, widthStats: widthStats, form: form, formStyle: form.style, organization: organization, handleLoaded: () => {
|
|
107
81
|
setLoaded(true);
|
|
108
|
-
} })
|
|
82
|
+
} }) }) })] }));
|
|
109
83
|
}
|
|
110
84
|
else {
|
|
111
85
|
return _jsx("div", {});
|
|
112
86
|
}
|
|
113
87
|
}
|
|
114
|
-
|
|
88
|
+
const muiTheme = createTheme({
|
|
115
89
|
typography: {
|
|
116
90
|
fontFamily: 'inherit',
|
|
117
91
|
},
|
|
118
92
|
});
|
|
119
|
-
|
|
93
|
+
const generateClassName = createGenerateClassName({
|
|
120
94
|
seed: SEED,
|
|
121
95
|
productionPrefix: 'efjss',
|
|
122
96
|
});
|
|
123
|
-
function FormTypeComponent(
|
|
124
|
-
|
|
125
|
-
var renderTypes = function () {
|
|
97
|
+
function FormTypeComponent({ ...props }) {
|
|
98
|
+
const renderTypes = () => {
|
|
126
99
|
switch (props.form.type) {
|
|
127
100
|
case FormTypes.COLUMN: {
|
|
128
|
-
return _jsx(ColumnForm,
|
|
101
|
+
return _jsx(ColumnForm, { ...props });
|
|
129
102
|
}
|
|
130
103
|
case FormTypes.STEPPER: {
|
|
131
|
-
return _jsx(StepperForm,
|
|
104
|
+
return _jsx(StepperForm, { ...props });
|
|
132
105
|
}
|
|
133
106
|
default: {
|
|
134
|
-
return _jsx(ColumnForm,
|
|
107
|
+
return _jsx(ColumnForm, { ...props });
|
|
135
108
|
}
|
|
136
109
|
}
|
|
137
110
|
};
|
|
138
111
|
switch (props.formStyle.type) {
|
|
139
112
|
case FormStyleTypes.MATERIAL:
|
|
140
|
-
return (_jsx(StylesProvider,
|
|
113
|
+
return (_jsx(StylesProvider, { generateClassName: generateClassName, children: _jsx(ThemeProvider, { theme: muiTheme, children: _jsx(MuiPickersUtilsProvider, { utils: DateFnsUtils, locale: getLocale(), children: renderTypes() }) }) }));
|
|
141
114
|
default:
|
|
142
115
|
return renderTypes();
|
|
143
116
|
}
|
|
@@ -1,41 +1,18 @@
|
|
|
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 __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
1
|
import { createElement as _createElement } from "react";
|
|
24
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
25
3
|
import StepComponent from '../../Step/Step';
|
|
26
4
|
import styles from './MaterialSection.module.css';
|
|
27
|
-
function MaterialSection(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return (_jsx("div", __assign({ className: styles.container, style: {
|
|
5
|
+
function MaterialSection({ form, section, widthStats, sendLabel, ...others }) {
|
|
6
|
+
const { postview, partial, originalValues } = others;
|
|
7
|
+
return (_jsx("div", { className: styles.container, style: {
|
|
31
8
|
width: (form.size.blockSize + form.size.spacingSize) *
|
|
32
9
|
form.size.blockNum,
|
|
33
10
|
justifyContent: sendLabel !== undefined &&
|
|
34
11
|
widthStats.currentBreakPoint < form.size.blockNum
|
|
35
12
|
? 'center'
|
|
36
13
|
: 'normal',
|
|
37
|
-
}
|
|
38
|
-
|
|
14
|
+
}, children: section.steps.map((idStep, index) => {
|
|
15
|
+
const step = form.steps[idStep];
|
|
39
16
|
//If partial is active only display steps with originalValues
|
|
40
17
|
if (postview &&
|
|
41
18
|
partial &&
|
|
@@ -43,12 +20,12 @@ function MaterialSection(_a) {
|
|
|
43
20
|
return _jsx("div", {}, index);
|
|
44
21
|
}
|
|
45
22
|
else if (step) {
|
|
46
|
-
return (_createElement(StepComponent,
|
|
23
|
+
return (_createElement(StepComponent, { ...others, widthStats: widthStats, form: form, step: step, handleSizeChange: () => { }, key: index, level: 0 }));
|
|
47
24
|
}
|
|
48
25
|
else {
|
|
49
26
|
console.error('Step not found:', idStep);
|
|
50
27
|
return _jsx("div", {}, index);
|
|
51
28
|
}
|
|
52
|
-
}) }))
|
|
29
|
+
}) }));
|
|
53
30
|
}
|
|
54
31
|
export default MaterialSection;
|
|
@@ -1,24 +1,13 @@
|
|
|
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
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
2
|
import { FormStyleTypes } from '../../constants/FormStepTypes';
|
|
14
3
|
import MaterialSection from './MaterialSection/MaterialSection';
|
|
15
4
|
function SectionComponent(props) {
|
|
16
5
|
switch (props.formStyle.type) {
|
|
17
6
|
case FormStyleTypes.MATERIAL: {
|
|
18
|
-
return _jsx(MaterialSection,
|
|
7
|
+
return _jsx(MaterialSection, { ...props });
|
|
19
8
|
}
|
|
20
9
|
default: {
|
|
21
|
-
return _jsx(MaterialSection,
|
|
10
|
+
return _jsx(MaterialSection, { ...props });
|
|
22
11
|
}
|
|
23
12
|
}
|
|
24
13
|
}
|
|
@@ -1,24 +1,13 @@
|
|
|
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
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
2
|
import { FormStyleTypes } from '../../../../constants/FormStepTypes';
|
|
14
3
|
import MaterialCBRIncidentsStep from './MaterialCBRIncidentsStep/MaterialCBRIncidentsStep';
|
|
15
4
|
function CBRIncidentsStep(props) {
|
|
16
5
|
switch (props.formStyle.type) {
|
|
17
6
|
case FormStyleTypes.MATERIAL: {
|
|
18
|
-
return _jsx(MaterialCBRIncidentsStep,
|
|
7
|
+
return _jsx(MaterialCBRIncidentsStep, { ...props });
|
|
19
8
|
}
|
|
20
9
|
default: {
|
|
21
|
-
return _jsx(MaterialCBRIncidentsStep,
|
|
10
|
+
return _jsx(MaterialCBRIncidentsStep, { ...props });
|
|
22
11
|
}
|
|
23
12
|
}
|
|
24
13
|
}
|
|
@@ -1,49 +1,26 @@
|
|
|
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 __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
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
2
|
import styles from './Incident.module.css';
|
|
25
3
|
import StepComponent from '../../../../Step';
|
|
26
4
|
import DeleteRoundedIcon from '@material-ui/icons/DeleteRounded';
|
|
27
5
|
import TextAreaStep from '../../../../TextAreaStep/TextAreaStep';
|
|
28
|
-
function IncidentComponent(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
var commentStep = form.steps[incident.idCommentStep];
|
|
6
|
+
function IncidentComponent({ step, form, level, incident, formStyle, handleDelete, ...others }) {
|
|
7
|
+
const spaceStep = form.steps[incident.idSpaceStep];
|
|
8
|
+
const elementStep = form.steps[incident.idElementStep];
|
|
9
|
+
const commentStep = form.steps[incident.idCommentStep];
|
|
33
10
|
if (incident.deleted) {
|
|
34
11
|
return _jsx("div", {});
|
|
35
12
|
}
|
|
36
|
-
return (_jsx("div",
|
|
13
|
+
return (_jsx("div", { className: others.widthStats.isMobile || form.size.blockNum < 3
|
|
37
14
|
? styles.mobileContainer
|
|
38
|
-
: styles.container
|
|
15
|
+
: styles.container, children: _jsxs("div", { className: styles.contentContainer, style: {
|
|
39
16
|
width: (form.size.blockSize + form.size.spacingSize) *
|
|
40
17
|
(form.size.blockNum - 1),
|
|
41
|
-
}
|
|
18
|
+
}, children: [_jsxs("div", { className: styles.titleLbl, style: { color: formStyle.textColor }, children: [step.unitLabel + ' ' + incident.num, ":"] }), _jsx("div", { className: !others.editable || others.postview
|
|
42
19
|
? styles.disabledDeleteBtn
|
|
43
|
-
: styles.deleteBtn, style: { color: formStyle.textColor }, onClick:
|
|
20
|
+
: styles.deleteBtn, style: { color: formStyle.textColor }, onClick: () => {
|
|
44
21
|
if (others.editable && !others.postview) {
|
|
45
22
|
handleDelete();
|
|
46
23
|
}
|
|
47
|
-
}
|
|
24
|
+
}, children: _jsx(DeleteRoundedIcon, { fontSize: "inherit" }) }), _jsx(StepComponent, { ...others, formStyle: formStyle, form: form, step: spaceStep, handleSizeChange: () => { }, level: level + 1 }), _jsx(StepComponent, { ...others, form: form, formStyle: formStyle, step: elementStep, handleSizeChange: () => { }, level: level + 1 }), _jsx(TextAreaStep, { ...others, form: form, backgroundColor: 'transparent', formStyle: formStyle, step: commentStep, maxLength: 200, handleSizeChange: () => { }, level: level + 1 })] }) }));
|
|
48
25
|
}
|
|
49
26
|
export default IncidentComponent;
|
|
@@ -1,34 +1,3 @@
|
|
|
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 __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
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
24
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
25
|
-
if (ar || !(i in from)) {
|
|
26
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
27
|
-
ar[i] = from[i];
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
31
|
-
};
|
|
32
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
33
2
|
/* eslint-disable no-console */
|
|
34
3
|
import { useEffect, useState } from 'react';
|
|
@@ -38,80 +7,94 @@ import IncidentComponent from './Incident/Incident';
|
|
|
38
7
|
import styles from './MaterialCBRIncidentsStep.module.css';
|
|
39
8
|
import { nanoid } from 'nanoid';
|
|
40
9
|
import RoundedButton from '../../../../../shared/RoundedButton/RoundedButton';
|
|
41
|
-
function Incidents(
|
|
42
|
-
var step = _a.step, form = _a.form, btnRef = _a.btnRef, editable = _a.editable, postview = _a.postview, onChange = _a.onChange, incidents = _a.incidents, formStyle = _a.formStyle, dependencyStore = _a.dependencyStore, setDependencyStore = _a.setDependencyStore, others = __rest(_a, ["step", "form", "btnRef", "editable", "postview", "onChange", "incidents", "formStyle", "dependencyStore", "setDependencyStore"]);
|
|
10
|
+
function Incidents({ step, form, btnRef, editable, postview, onChange, incidents, formStyle, dependencyStore, setDependencyStore, ...others }) {
|
|
43
11
|
/** Form to pass down with aditional steps */
|
|
44
|
-
|
|
45
|
-
|
|
12
|
+
const [localForm, setLocalForm] = useState({
|
|
13
|
+
...form,
|
|
14
|
+
steps: { ...form.steps },
|
|
15
|
+
});
|
|
16
|
+
useEffect(() => {
|
|
46
17
|
if (incidents.length === 0 && !postview && editable) {
|
|
47
18
|
handleAddIncident();
|
|
48
19
|
}
|
|
49
20
|
}, []);
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
var newIncident = {
|
|
21
|
+
const handleAddIncident = () => {
|
|
22
|
+
const current = incidents.filter((incident) => !incident.deleted);
|
|
23
|
+
const newIncident = {
|
|
54
24
|
idSpaceStep: CBRFormStepTypes.CBR_TIPO_ESPACIO + '-' + nanoid(),
|
|
55
25
|
idCommentStep: CBRFormStepTypes.CBR_COMENTARIO + '-' + nanoid(),
|
|
56
26
|
idElementStep: CBRFormStepTypes.CBR_LOCATIVAS + '-' + nanoid(),
|
|
57
27
|
num: current.length + 1,
|
|
58
28
|
};
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
29
|
+
const newSteps = {
|
|
30
|
+
...localForm.steps,
|
|
31
|
+
};
|
|
32
|
+
newSteps[newIncident.idSpaceStep] = {
|
|
33
|
+
...step.spaceStep,
|
|
34
|
+
id: newIncident.idSpaceStep,
|
|
35
|
+
type: CBRFormStepTypes.CBR_TIPO_ESPACIO,
|
|
36
|
+
dependencies: step.dependencies,
|
|
37
|
+
};
|
|
38
|
+
newSteps[newIncident.idCommentStep] = {
|
|
39
|
+
...step.commentStep,
|
|
40
|
+
id: newIncident.idCommentStep,
|
|
41
|
+
type: CBRFormStepTypes.CBR_COMENTARIO,
|
|
42
|
+
};
|
|
43
|
+
const deps = { ...dependencyStore };
|
|
44
|
+
addRecursiveElementStep(newIncident.idElementStep, step.elementStep, null, newSteps, deps, step.dependencies?.[0] ?? '');
|
|
45
|
+
onChange([...incidents, newIncident]);
|
|
46
|
+
setLocalForm({ ...localForm, steps: newSteps });
|
|
66
47
|
setDependencyStore(deps);
|
|
67
48
|
};
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
49
|
+
const addRecursiveElementStep = (idStep, step, idParent, steps, dependencyStore, idProjectDep) => {
|
|
50
|
+
const idSubStep = CBRFormStepTypes.CBR_LOCATIVAS + '-' + nanoid();
|
|
51
|
+
const newSubStep = step.subStep ? { ...step.subStep } : undefined;
|
|
52
|
+
const newStep = {
|
|
53
|
+
...step,
|
|
54
|
+
id: idStep,
|
|
55
|
+
type: CBRFormStepTypes.CBR_LOCATIVAS,
|
|
56
|
+
parentStep: idParent,
|
|
57
|
+
dependencies: [idProjectDep],
|
|
58
|
+
subStep: null,
|
|
59
|
+
};
|
|
73
60
|
if (newSubStep) {
|
|
74
61
|
newStep.subStep = idSubStep;
|
|
75
62
|
}
|
|
76
63
|
if (idParent) {
|
|
77
64
|
dependencyStore[idParent] = null;
|
|
78
|
-
|
|
65
|
+
newStep.dependencies?.push?.(idParent);
|
|
79
66
|
}
|
|
80
67
|
steps[idStep] = newStep;
|
|
81
68
|
if (newSubStep) {
|
|
82
69
|
addRecursiveElementStep(idSubStep, newSubStep, idStep, steps, dependencyStore, idProjectDep);
|
|
83
70
|
}
|
|
84
71
|
};
|
|
85
|
-
return (_jsxs("div",
|
|
72
|
+
return (_jsxs("div", { className: styles.container, style: { color: formStyle.textColor }, children: [_jsx("div", { className: styles.titleLbl, children: step.label }), step.description && (_jsx("p", { className: styles.descriptionPar, style: {
|
|
86
73
|
margin: step.description
|
|
87
74
|
? '10px 0px'
|
|
88
75
|
: '0px 0px 5px 0px',
|
|
89
|
-
}
|
|
90
|
-
|
|
76
|
+
}, children: step.description })), incidents.map((incident, index) => (_jsx(IncidentComponent, { incident: incident, formStyle: formStyle, step: step, form: localForm, editable: editable, postview: postview, dependencyStore: dependencyStore, setDependencyStore: setDependencyStore, handleDelete: () => {
|
|
77
|
+
const tempIncidents = [...incidents];
|
|
91
78
|
tempIncidents[index].deleted = true;
|
|
92
|
-
|
|
93
|
-
for (
|
|
94
|
-
var inc = tempIncidents_1[_i];
|
|
79
|
+
let n = 1;
|
|
80
|
+
for (const inc of tempIncidents) {
|
|
95
81
|
if (!inc.deleted) {
|
|
96
82
|
inc.num = n;
|
|
97
83
|
n++;
|
|
98
84
|
}
|
|
99
85
|
}
|
|
100
86
|
onChange(tempIncidents);
|
|
101
|
-
}
|
|
87
|
+
}, ...others }, index))), _jsxs("div", { className: styles.btnContainer, children: [_jsx("input", { ref: btnRef, className: styles.hiddenInput }), _jsx(RoundedButton, { disabled: !editable || postview, text: step.addBtnLabel, color: formStyle.primaryContrastColor, backgroundColor: formStyle.primaryColor, fontSize: '1rem', padding: '5px 15px 5px 15px', onClick: () => {
|
|
102
88
|
if (editable && !postview) {
|
|
103
89
|
handleAddIncident();
|
|
104
90
|
}
|
|
105
|
-
} })] })
|
|
91
|
+
} })] })] }));
|
|
106
92
|
}
|
|
107
93
|
function CBRIncidentsStep(props) {
|
|
108
94
|
return (_jsx(Controller, { name: props.step.id, control: props.control, defaultValue: [], rules: {
|
|
109
95
|
required: props.step.required
|
|
110
96
|
? 'Este campo es obligatorio'
|
|
111
97
|
: undefined,
|
|
112
|
-
}, shouldUnregister: true, render:
|
|
113
|
-
var field = _a.field;
|
|
114
|
-
return (_jsx(Incidents, __assign({}, props, { incidents: field.value, onChange: field.onChange, btnRef: field.ref })));
|
|
115
|
-
} }));
|
|
98
|
+
}, shouldUnregister: true, render: ({ field }) => (_jsx(Incidents, { ...props, incidents: field.value, onChange: field.onChange, btnRef: field.ref })) }));
|
|
116
99
|
}
|
|
117
100
|
export default CBRIncidentsStep;
|